
Luke Palmer wrote:
On Sat, Feb 20, 2010 at 3:30 AM, Andrew Coppin
wrote: Have I just invented arrows?
No... you have a data type which is *an* Arrow (probably/almost).
Well, OK, that's kind of what I meant. ;-)
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;
Yes, this irritates me also.
i.e.
data Property' a b = forall s. Property' s (a -> s -> (b,s))
Hmm. I hadn't thought of that. I will work though the consequences and see what happens...
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.
(.) = flip (>==>) first p = p >==< pure id
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)
...OK, I'm lost...