[Haskell-cafe] understanding typeable

Anatoly Yakovenko aeyakovenko at gmail.com
Sun Apr 12 15:42:35 EDT 2009

i am trying to figure out how typeable works, so i have this data type

data Foo = FooC Int
         deriving (Data, Typeable, Show)

So how come this works:

> funResultTy (typeOf ((+) 1)) (typeOf 1)
Just Integer

but this doesnt:

> funResultTy (typeOf FooC) (typeOf 1)

FooC is of type t -> u and 1 is of type t so the result should be u?
I don't think t and u need to be the same since

> funResultTy (typeOf (\a -> a:[1])) (typeOf 1)
Just [Integer]

works fine.  So given a constructor, how come i cant seem to construct
a type out of it?

More information about the Haskell-Cafe mailing list