GHCi “let” — what does it do?

后端 未结 4 1886
囚心锁ツ
囚心锁ツ 2020-12-05 07:05

I\'d appreciate if someone could point to docs on what "let" does in GHCi, or failing that, explain it convincingly.

So far as I can tell, "let" (

4条回答
  •  囚心锁ツ
    2020-12-05 07:39

    GHCI commands are executed in the IO monad and uses do syntax, so the desugaring rules apply. From Real World Haskell

    doNotation4 =
        do let val1 = expr1
               val2 = expr2
               {- ... etc. -}
               valN = exprN
           act1
           act2
           {- ... etc. -}
           actN
    

    translates to:

    translated4 =
        let val1 = expr1
            val2 = expr2
            {- ... etc. -}
            valN = exprN
        in do act1
              act2
              {- ... etc. -}
              actN
    

提交回复
热议问题