[Haskell-cafe] Re: monad subexpressions

Sebastian Sylvan sebastian.sylvan at gmail.com
Fri Aug 3 17:16:11 EDT 2007


On 03/08/07, Claus Reinke <claus.reinke at talk21.com> wrote:
> > mytransaction = do {
> >  x0 <- readTVar xvar0
> >  x1 <- readTVar xvar1
> >  :
> >  xn <- readTVar xvarn
> >  return $ foo x0 x1 .. xn
> > }
> >
> > Versus
> >
> > mytransaction = return $ foo $(readTVar xvar0) $(readTVar xvar1) ..
> > $(readTVar xvarn)
>
> ah, a concrete example. but isn't that the typical use case for ap?
>
> mytransaction = foo `liftM` r xvar0 `ap` r xvar1 ..
>     where r = readTVar

I really find it difficult to articulate why this isn't acceptable,
because it seems so obvious to me! It's short yes, but I really don't
think it's very clear...
I have a hard time believing that anyone finds that natural. After
lots and lots of mind-bending forays into various branches of
mathematics, then yes maybe you can get used to it, but it's hardly as
natural as saying "add this one symbol to your values to extract
monadic values left-to-right".


-- 
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862


More information about the Haskell-Cafe mailing list