How to add type annotation in let binding

前端 未结 3 748
陌清茗
陌清茗 2021-02-01 04:14

I\'m a beginner(ish) in Haskell and I find error message really hard to understand (I guess it comes with time). Anyway, to help me understanding my mistakes, I tried to add int

3条回答
  •  生来不讨喜
    2021-02-01 04:46

    For anyone who is looking to type annotate the binding instead of the expression - ScopedTypeVariables allows you to do that too!

    f1 = do
      let x :: Int = 5
      y :: Int <- someMonadicOperation
      return $ x + y
    

提交回复
热议问题