On Sunday 12 April 2009 3:42:35 pm Anatoly Yakovenko wrote: > 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) > > Nothing > > 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?
Judging from the other types, 'typeOf 1' is defaulting to Integer. FooC, per your declaration, has type 'Int -> Foo'. So, you're probably asking it what happens when you apply an Int -> Foo to an Integer, which would be a type error, and explains the Nothing, I think. -- Dan _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
