[Haskell-cafe] Typeable and fancy types

Luke Palmer lrpalmer at gmail.com
Fri Jul 11 19:59:41 EDT 2008


On Fri, Jul 11, 2008 at 5:13 PM, Roberto Zunino <zunino at di.unipi.it> wrote:
> Ron Alford wrote:
>>
>> instance Typeable1 f => Typeable (Expr f) where
>>    typeOf (In x) = mkTyConApp (mkTyCon "TypeTest.Expr") [typeOf1 x]
>
>      typeOf ~(In x) = mkTyConApp (mkTyCon "TypeTest.Expr") [typeOf1 x]

Yes, that works, but what would also work is this:

newtype Expr f = In (f (Expr f))

Keeping the typeOf code the same as the original.  I would consider
this more correct, since this is a type trick, not a value trick.  The
data definition makes your model have an extra bottom, which can't be
very attractive!

Luke


More information about the Haskell-Cafe mailing list