Newtype wrappers

Gábor Lehel illissius at gmail.com
Tue Jan 22 09:51:14 CET 2013


On Tue, Jan 22, 2013 at 7:41 AM, wren ng thornton <wren at freegeek.org> wrote:
> On 1/21/13 1:40 AM, Shachaf Ben-Kiki wrote:
>>
>> For example:
>>
>>      {-# LANGUAGE TypeFamilies #-}
>>      import Unsafe.Coerce
>>
>>      newtype Id a = MkId { unId :: a }
>>
>>      {-# RULES "fmap unId" fmap unId = unsafeCoerce #-}
>>
>>      data family Foo x y a
>>      data instance Foo x y (Id a) = FooI x
>>      data instance Foo x y Bool   = FooB { unB :: y }
>>
>>      instance Functor (Foo x y) where fmap = undefined
>
>
> You can define instances for type functions? Eek!
>

Only for data families / instances.

-- 
Your ship was destroyed in a monadic eruption.



More information about the Glasgow-haskell-users mailing list