[Haskell-cafe] arr considered harmful

Ertugrul Soeylemez es at ertes.de
Wed Nov 2 11:37:48 CET 2011

Ryan Ingram <ryani.spam at gmail.com> wrote:

> I know it's a bit of an 'intentionally provocative' title, but with
> the recent discussions on Arrows I thought it timely to bring this up.
> Most of the conversion from arrow syntax into arrows uses 'arr' to
> move components around. However, arr is totally opaque to the arrow
> itself, and prevents describing some very useful objects as arrows.

I can totally understand your frustration, but on the other hand I have
to say that /not/ having 'arr' would break a lot of useful things at
least for me and probably for most programmers using AFRP.

One possible compromise is to move it into its own type class and also
offer specialized versions of it for plumbing in a yet simpler class.

    class Arrow (>~) => ArrowPair (>~)
        dup  :: a >~ (a, a)
        swap :: (a, b) >~ (b, a)

    class Arrow (>~) => ArrowArr (>~) where
        arr :: (a -> b) -> (a >~ b)

This would enable some interesting optimization opportunities.  Perhaps
it also makes sense to turn ArrowArr into a subclass of ArrowPair.


nightmare = unsafePerformIO (getWrongWife >>= sex)

More information about the Haskell-Cafe mailing list