[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: Re: [Haskell-cafe] Fundeps and overlapping instances
From: Gábor_Lehel <illissius () gmail ! com>
Date: 2012-06-09 23:16:06
Message-ID: CAPNUp0_7tGq+24Lt8m=dFQujF19YPokduNgaR8oPqxTSiNCcMw () mail ! gmail ! com
[Download RAW message or body]
On Tue, Jun 5, 2012 at 2:25 PM, Gábor Lehel <illissius@gmail.com> wrote:
> The encoded version would be:
>
> instance (f a b) => FMap f (HJust a) (HJust b)
> where type f :<$>: (HJust a) = HJust b
>
> and I think this actually demonstrates a *different* limitation, namely that
>
>> The RHS of an associated type declaration mentions type variable `b'
>> All such variables must be bound on the LHS
>
> which means that the standard encoding doesn't work for this case.
From a reddit comment[1] by Reiner Pope it turns out you can actually do this:
instance (f a b) => FMap f (HJust a) (HJust b) where
type f :<$>: (HJust a) = HJust (f :<$>: a)
A bit more awkward to write, but we're back to TFs not having any
expressivity problem in this department.
[1] http://www.reddit.com/r/haskell/comments/ut85i/a_few_typefamilies_nuggets/c4ygefh
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic