[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

More information about the Haskell-Cafe mailing list