[Haskell-cafe] Non-recursive let [Was: GHC bug? Let with guards loops]

Andreas Abel andreas.abel at ifi.lmu.de
Wed Jul 10 10:42:24 CEST 2013


On 10.07.2013 10:16, Ertugrul Söylemez wrote:
> oleg at okmij.org wrote:
>
>> Hear, hear! In OCaml, I can (and often do) write
>>
>>          let (x,s) = foo 1 [] in
>>          let (y,s) = bar x s in
>>          let (z,s) = baz x y s in ...
>>
>> In Haskell I'll have to uniquely number the s's:
>>
>>          let (x,s1)  = foo 1 [] in
>>          let (y,s2)  = bar x s1 in
>>          let (z,s3)  = baz x y s2 in ...
>
> This isn't a case for non-recursive let.  It is one of the rare cases
> where you might actually consider using a state monad.

Except when you are implementing the state monad (giggle):

 
http://hackage.haskell.org/packages/archive/mtl/2.1/doc/html/src/Control-Monad-State-Class.html#state


-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.abel at ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/



More information about the Haskell-Cafe mailing list