Proposal: Applicative => Monad: Call for consensus
uzytkownik2 at gmail.com
Thu Jan 6 21:09:35 CET 2011
On Thu, 2011-01-06 at 12:35 -0500, 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'
I guess that in both cases it should be written as x >>= f.
Maybe better example:
doA :: String -> String -> String -> IO String
doB :: IO String
doC = join $ doA <$> doB <*> doB <*> doB
doC = do
x <- doB
y <- doB
z <- doB
doA x y z
> Obviously both notations have their places, "do" is usually nicer if I want to
> use values multiple times, while "applicative style" is usually nicer if I am
> just unpacking values for an application. I suspect "do", however, tends to
> get overused simply because that is what monad tutorials teach.
> Cheers! -Tyson
I noticed that for people unfamiliar with Haskell the do notation is
simpler. However as they get used to they learn to appreciate:
data Function = Function Ident Args Type
function = Function <$> ident <*> args <*> returnType
or similar constructions in simpler ('applicative') cases.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 836 bytes
Desc: This is a digitally signed message part
More information about the Libraries