[Haskell-cafe] Question on declaring an instance
john lask
jvlask at hotmail.com
Sun May 18 22:02:32 EDT 2008
Consider the data type:
Foo i o a = ...
we want to declare an instance of Monad and Arrow for Foo without using a newtype (repackaging).
The effect we want is to be able to construct an expression like:
( f>> g )>>> ( h>> i )
where f, g, h, i :: Foo i o a, for some i o a
it is easy to declare
instance Monad (Foo i o) where
...
but how do we declare instance Arrow (Foo ... ), this instance takes a kind * -> * -> *
it is easy to declare
instance Arrow (Bar a) where
...
where Bar a i o is a flipping of the order of the arguments to Foo
i.e. Bar = ((flip . (flip .)) Foo
Can Foo be declared an instance of both Arrow and Monad ?
_________________________________________________________________
It's simple! Sell your car for just $30 at CarPoint.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT
More information about the Haskell-Cafe
mailing list