2026/04/14

Newest at the top

2026-04-14 07:35:20 +0000 <[exa]> yeah there's some optimizations that are able to uniquify common sub-expressions a little, so chances are it might do this for you. But that's hard to rely upon tbh.
2026-04-14 07:34:42 +0000 <Milan_Vanca> You said it "may" be evaluated once as ghc does some rewriting.
2026-04-14 07:34:20 +0000 <Milan_Vanca> I mean "length a"
2026-04-14 07:33:59 +0000 <Milan_Vanca> If I want to be sure it wont be evaluated twice I need to bound it myself right?
2026-04-14 07:33:56 +0000 <[exa]> that's ok, the list is going to get materialized only once
2026-04-14 07:33:43 +0000 <Milan_Vanca> [exa]: Yeah.. I can follow that.. but my example bound only list to variable "let a = [1..3] :: [Int]"
2026-04-14 07:33:26 +0000Sgeo(~Sgeo@user/sgeo) (Read error: Connection reset by peer)
2026-04-14 07:31:54 +0000 <[exa]> Milan_Vanca: the rule of thumb is "let-bindings create exactly one thunk". Once thunks get evaluated for the first time, they are _rewritten_ to their results, so evaluating them for the second time "does nothing". Which gives you a pretty good tool to make sure the `length` isn't going to execute twice
2026-04-14 07:30:49 +0000leppard(~noOne@ipservice-092-208-182-236.092.208.pools.vodafone-ip.de) (Ping timeout: 248 seconds)
2026-04-14 07:29:32 +0000 <[exa]> Milan_Vanca: in this case you don't do anything to tell the compiler to NOT evaluate it twice; but ghc may quite safely transform the code to something like `let a=[1..3] in let tmp=length a in tmp == tmp`
2026-04-14 07:27:56 +0000 <Milan_Vanca> My expectation is that as "a" is same.. so "length a" must be same.. and thus it will be evaluated only once and then passed to comparsion
2026-04-14 07:26:31 +0000 <Milan_Vanca> Will length a be evaluated twice? In means will the list be traversed twice?
2026-04-14 07:26:26 +0000 <monochrom> That example is not confusing.
2026-04-14 07:25:58 +0000 <lambdabot> True
2026-04-14 07:25:56 +0000 <Milan_Vanca> > let a = [1..3] :: [Int] in (length a :: Int) == (length a :: Int)
2026-04-14 07:25:43 +0000 <Milan_Vanca> Good morning guyz! The more I read, the more confusing all sharing and evaluation is :-(
2026-04-14 07:22:17 +0000uli-fem(~uli-fem@203.87.114.209) (Ping timeout: 248 seconds)
2026-04-14 07:20:58 +0000sord937(~sord937@gateway/tor-sasl/sord937) sord937
2026-04-14 07:20:55 +0000CiaoSen(~Jura@p549cbfb1.dip0.t-ipconnect.de) CiaoSen
2026-04-14 07:19:25 +0000sord937(~sord937@gateway/tor-sasl/sord937) (Remote host closed the connection)
2026-04-14 07:18:21 +0000Milan_Vanca(~milan@user/Milan-Vanca:32634) Milan_Vanca
2026-04-14 07:17:36 +0000uli-fem(~uli-fem@203.87.114.209)
2026-04-14 07:11:49 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 244 seconds)
2026-04-14 07:05:08 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-04-14 06:56:09 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 248 seconds)
2026-04-14 06:51:05 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-04-14 06:48:05 +0000 <[exa]> mornin'
2026-04-14 06:47:45 +0000sord937(~sord937@gateway/tor-sasl/sord937) sord937
2026-04-14 06:43:53 +0000michalz(~michalz@185.246.207.203)
2026-04-14 06:40:52 +0000uli-fem(~uli-fem@203.87.114.209) (Ping timeout: 268 seconds)
2026-04-14 06:40:32 +0000michalz(~michalz@185.246.207.193) (Read error: Connection reset by peer)
2026-04-14 06:40:12 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 244 seconds)
2026-04-14 06:40:04 +0000Tikosh(~Tikosh@user/Tikosh) (Quit: Client closed)
2026-04-14 06:36:06 +0000uli-fem(~uli-fem@203.87.114.209)
2026-04-14 06:35:42 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-04-14 06:35:04 +0000bryanv(~quassel@2603:c028:4503:7500:45b7:933:ab17:bc10)
2026-04-14 06:34:11 +0000czan(~czan@user/mange) (Remote host closed the connection)
2026-04-14 06:29:33 +0000tusko(~uwu@user/tusko) tusko
2026-04-14 06:29:18 +0000tusko(~uwu@user/tusko) (Remote host closed the connection)
2026-04-14 06:27:19 +0000tromp(~textual@2001:1c00:340e:2700:f5bd:97ff:8f76:c38c)
2026-04-14 06:25:19 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 276 seconds)
2026-04-14 06:21:00 +0000uli-fem(~uli-fem@203.87.114.209) (Ping timeout: 245 seconds)
2026-04-14 06:19:55 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-04-14 06:14:55 +0000bryanv(~quassel@2603:c028:4503:7500:45b7:933:ab17:bc10) (Ping timeout: 276 seconds)
2026-04-14 06:13:47 +0000uli-fem(~uli-fem@203.87.114.209)
2026-04-14 06:09:06 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 256 seconds)
2026-04-14 06:04:09 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-04-14 06:00:54 +0000 <Tikosh> still learning, of course
2026-04-14 06:00:39 +0000 <Tikosh> this haskell stuff melts brains. but I'm glad i learn it!
2026-04-14 06:00:25 +0000 <Tikosh> i was attempting to use recursion and was enlightened about the thing called mutual recursion