[Haskell-cafe] Question on declaring an instance

Luke Palmer lrpalmer at gmail.com
Sun May 18 22:11:14 EDT 2008


On Mon, May 19, 2008 at 2:02 AM, john lask <jvlask at hotmail.com> wrote:
> 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

[...]

> Can Foo be declared an instance of both Arrow and Monad ?

I think not.  However, it's not unreasonable for

    data Foo i o

To be both monad and arrow, since arrows are functors in their second argument.

Luke


More information about the Haskell-Cafe mailing list