Binding functions that take multiple arguments

前端 未结 3 1194
梦如初夏
梦如初夏 2021-01-01 17:03

After reading some very basic haskell now I know how to \"chain\" monadic actions using bind, like:

echo = getLine >>= putStrLn
3条回答
  •  臣服心动
    2021-01-01 17:43

    It's much easier to use do notation for this, rather than asking for a combinator

    action1 :: MyMonad a
    action2 :: MyMonad b
    f :: a -> b -> MyMonad c
    
    do
        x <- action1
        y <- action2
        f x y
    

提交回复
热议问题