[Haskell-cafe] why typeRepArgs (typeOf "hello") is [Char] ?
rmm-haskell at z.odi.ac
Mon Feb 2 15:18:34 EST 2009
The type of "hello" is String, which is [Char], which is really 
Char (that is, the list type of kind * -> *, applied to Char).
1, 'a', and True are all simple types (I'm sure there's a more
particular term, maybe "monomorphic"?) with no type arguments.
 has a type argument, Char.
Prelude Data.Typeable> typeRepArgs (typeOf (Just 1))
Prelude Data.Typeable> typeRepArgs (typeOf (Left 'a' :: Either Char
-- typeRepArgs is giving you the arguments of the root type
application,  (list) in your case, Maybe and Either for the two
examples I gave.
Does this make sense?
On Feb 2, 2009, at 3:09 PM, minh thu wrote:
> With Data.Typeable :
> *Graph> typeRepArgs (typeOf 1)
> *Graph> typeRepArgs (typeOf 'a')
> *Graph> typeRepArgs (typeOf True)
> *Graph> typeRepArgs (typeOf "hello")
> I don't understand why the latter is not . Could someone explain
> it ?
> Thank you,
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe