News for hackers. Stuff that matters.
Re:8 months of OCaml after 8 years of Haskell in production ... by solomonb on Tuesday December 03, 2024 @01:13AM (#42303426)

    mySubroutine = do
      foo <- mkFoo
      bar <- mkbar foo
      mkBaz bar
    
    mySubroutineV2 =
      mkFoo >>= \foo ->
        mkBar foo >>= \bar ->
          mkBaz bar
Re:8 months of OCaml after 8 years of Haskell in production ... by edflsafoiewq on Tuesday December 03, 2024 @01:48AM (#42303567)
Note that this is same desugaring for normal let

  let x = y in F   <===>   (\x.F)(y)
just replacing function application with a different function (>>=).
Re:8 months of OCaml after 8 years of Haskell in production ... by Athas on Tuesday December 03, 2024 @02:44AM (#42303838)
This is not the case in Haskell, because let-bindings can be self-referential, while lambdas cannot (without using a fixed point combinator). Also, in most functional languages, a let-binding causes type generalisation, which is not the case for a lambda.
Re:8 months of OCaml after 8 years of Haskell in production ... by chombier on Tuesday December 03, 2024 @02:47AM (#42303863)
Not exactly the same: `x` is given a polymorphic type (in F) in Haskell (restricted to values in ML) whereas the unannotated let-over-lambda will give `x`a monomorphic type.
Re:8 months of OCaml after 8 years of Haskell in production ... by solomonb on Tuesday December 03, 2024 @02:25AM (#42303752)
You can desugar let bindings that way but often times (as I believe is the case in GHC) you have a `Let` term in your AST.