[Haskell-cafe] Type-level GCD [Instance Chains]

Anthony Clayden anthony_clayden at clear.net.nz
Thu Jun 1 13:01:46 UTC 2017


> On Thu Jun 1 12:44:32 UTC 2017, Anthony Clayden wrote:

>> For example, consider the simple chain:
>>
>>    class C t u where f :: t -> u
>>    instance C Int Int where
>>      f = M
>>    else C t u where
>>      f = N

Ah, silly me. There's a neater way to achieve that.

> I think Instance Guards both have less lexical clutter,
> and help the compiler see what's coherent:

>    instance  C Int Int                    where f = M
>    instance  C t u     | (t, u) /~ (Int, Int)  where f = N


AntC


More information about the Haskell-Cafe mailing list