Newtype wrappers

wren ng thornton wren at freegeek.org
Tue Jan 22 07:41:37 CET 2013


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!

-- 
Live well,
~wren



More information about the Glasgow-haskell-users mailing list