
On Thu, 6 Jan 2011, Tyson Whitehead wrote:
On January 6, 2011 11:42:09 Iavor Diatchki wrote:
AFAIU, In applicative style programming "join" has proven to be a lot more useful than "bind".
I am not sure what you mean here, I find the "do" notation quite useful.
I think he was meaning when you are using monads in a more "function style" (applicative) than "imperative style" (do notation).
As an example, consider the definition of ">>=" using join and the "$" and "<$>" application operators
x >>= f = join $ f <$> x
versus that using "do" notation
x >>= f = do x' <- x f x'
Notice that in the applicative style we didn't need to name the "x'" value. To add to this excellet comment, the idea of applicative style is to use a long string of functions and parameters with various <$> and <*> in between them with the occassional peppering of join and other combinators. I understand this is becomming quite popular with parser combinators. e.g. (this example is from mm_freak): char '(' *> skipSpace *> someToken <* skipSpace <* char ')' Haskell is famous for allowing users the choice of multiple programming styles: * matching on the LHS vs case statements on the RHS * where clauses vs let statements * 2-D layout vs braces and semi-colons Given this, it seems only appropriate to support both applicative style and do notation programming. -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''