Who is afraid of arrows, was Re: [Haskell-cafe] ANNOUNCE: Haskell XML Toolbox Version 9.0.0

Paolo G. Giarrusso p.giarrusso at gmail.com
Wed Oct 13 04:53:55 EDT 2010

On Oct 11, 3:20 pm, Uwe Schmidt <u... at fh-wedel.de> wrote:
> Hi Gregory,

> > Is there some benefit that your library gets out of using arrows that I
> > missed which makes these costs worth it?

> I thing, this is not a question of functionality, it's a question of style.
> Of course everything in hxt could have been done with monads,
> but does this also mean: Everything must have been done with monads?

I would like to answer "yes" here, following the inventor of monads,
and giving some more reasons.

1) With monads, you still get a monadic interface by using Keisli, if
you want. So your code would be strictly more reusable with monads.
Maybe there is also an inverse of Keisli defined somewhere - it still
makes more sense to use monads in your definitions.
If nothing else, I don't want to start reading a 56-page tutorial [1]
about an abstract concept to do XML processing (ArrowApply appears at
page 20).

2) Quoting from another mail:
Hughes himself said that when your arrow is an instance of
you are better off just sticking with monads, except for the usage of
point-free notation.

[See sec 2.4, page 14 of [1]]

But as argued, point-free notation is possible with monads, too - at
worst, nobody has put together a tutorial for doing it.

Given the less widespread knowledge about arrows, their bigger
complexities (twenty-seven arrow laws versus three monad laws) the
reduced number of available utilities, monads are better here.

My knowledge of arrows comes from an afternoon of study interleaved
with other stuff (so it's less than an afternoon) - but I soon started
to use "Programming with Arrows", which is _not_ linked from the
reference of Control.Arrow, just from GHC's User Guide [2]. IMHO, you
probably also chose to use arrows instead of monads because of bad
docs by - namely, Control.Arrow docs should contain the above tip by
John Hughes, together with a link to (>=>); the whole debate wouldn't
need to exist.

Best regards

[1] "Programming with Arrows", John Hughes tutorial at "5th
International Summer School on Advanced Functional Programming", 2004.
[2] http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/arrow-notation.html

More information about the Haskell-Cafe mailing list