[Haskell-cafe] Computing sums

Luke Palmer lrpalmer at gmail.com
Sat Feb 20 05:45:22 EST 2010


On Sat, Feb 20, 2010 at 3:30 AM, Andrew Coppin
<andrewcoppin at btinternet.com> wrote:
> Have I just invented arrows?

No... you have a data type which is *an* Arrow (probably/almost).  The
pure implementation bugs me because of its use of undefined.  Might
still be okay though.  I would be more comfortable if it could not
output until it has *some* input; i.e.

data Property' a b = forall s. Property' s (a -> s -> (b,s))

Anyway, for yours: try to implement (.) :: Property b c -> Property a
b -> Property a c, and first :: Property a b -> Property (a,c) (b,c).
Then you will have an arrow.

This is a Causal Commutative Arrow, even, similar to the kinds of
things that are done in Yampa.  It might be more recognizable as the
non-recursive version of:

  newtype Property a b = Property b (a -> Property a b)

Luke


More information about the Haskell-Cafe mailing list