[Haskell-cafe] |> vs. $ (was: request for code review)

Brian Hulley brianh at metamilk.com
Tue Mar 7 09:08:21 EST 2006


Brian Hulley wrote:
> translate :: (Monad m) => String -> m String
> translate = do
>                       createParseContext
>                       readToFirstIdentifier
>                       dealWithDeclarator
>                       consolidateOutput

The type signature above doesn't match the do block. It would either have to 
be changed to something like:

translate :: Control.Monad.State.MonadState String m => m ()

(storing the string in the monad's state instead of using a monad which 
returns it) or the do block could be replaced with the >>= operator as 
below, to thread the returned string between the components of the "pipe":

translate :: Monad m => String -> m String
translate x =
                      return x >>=
                      createParseContext >>=
                      readToFirstIdentifier >>=
                     dealWithDeclarator >>=
                     consolidateOutput



More information about the Haskell-Cafe mailing list