[Haskell-cafe] Unexpected Typeable behaviour; Prelude.undefined

Ozgur Akgun ozgurakgun at gmail.com
Mon Aug 29 01:12:32 CEST 2011


Hi Philip,

On 28 August 2011 23:44, Philip Holzenspies <pkfh at st-andrews.ac.uk> wrote:
>
> import Data.Typeable
>
> data MyADT m = MyADT (m ())
>
> instance (Typeable1 m, Monad m) => Typeable (MyADT m) where
>        typeOf t@(MyADT _)
>         = mkTyCon "MyADT"
>          `mkTyConApp`
>          [typeOf1 ((return :: Monad m => MyADT m -> m (MyADT m)) t)]
>

IIRC, typeOf is supposed to work with undefined as the argument.

Try: typeOf (undefined :: Int)

See:
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Typeable.html#v:typeOf

I think the undefined is merely because the pattern matching you use in the
instance declaration fails.

Hope this helps,
Ozgur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110829/8e0e5b43/attachment.htm>


More information about the Haskell-Cafe mailing list