[Haskell-cafe] an instance in other than the last type parameters
Geoffrey Marchant
geoffrey.marchant at gmail.com
Fri Jul 17 16:08:08 EDT 2009
> data X a b = X a b> instance Functor (X a) where
> fmap f (X a b) = X a (f b)
Yeah, that works just fine.
On Fri, Jul 17, 2009 at 1:14 PM, Petr Pudlak <deb at pudlak.name> wrote:
> Hi, I have probably a very simple question, but I wasn't able to figure it
> out
> myself.
>
> Consider a two-parameter data type:
>
> > data X a b = X a b
>
> If I want to make it a functor in the last type variable (b), I can just
> define
>
> > instance Functor (X a) where
> > fmap f (X a b) = X a (f b)
>
> But how do I write it if I want X to be a functor in its first type
> variable?
> Is that possible at all?
> Something like:
>
> > instance Functor ??? where
> > fmap f (X a b) = X (f a) b
>
> Thanks in advance,
> Petr
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/2c44c1e7/attachment.html
More information about the Haskell-Cafe
mailing list