Shannon -jj Behrens wrote:
I find "ctx |> currTok |> tokenType" to be more readable than
"tokenType $ currTok $ ctx" because you're not reading the code in
reverse. That's my primary complaint with "." and "$". That's
especially the case when I'm spreading the code over multiple lines:
-- Translate a C type declaration into English.
translate :: String -> String
translate s =
s |>
createParseContext |>
readToFirstIdentifier |>
dealWithDeclarator |>
consolidateOutput
If you were wanting to be able to deal with exceptions/ errors etc during
the translation process, you'd usually use a monad (Haskell's version of a
pipe), in which case the operations could still be read left to right eg:
translate :: (Monad m) => String -> m String
translate = do
createParseContext
readToFirstIdentifier
dealWithDeclarator
consolidateOutput
So while . and $ are useful for combining functions together in parts of a
program, and are consistent with the idea that the function always comes
first followed by its argument, the top level (at least) would usually be
monadic and hence not require |> to get left-to-right readability. I've
copied the links on monads below from a previous post by Jared:
http://www.nomaware.com/monads/html/
http://haskell.org/hawiki/Monad
Regards, Brian.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe