[Haskell-fr] a function which return the type of element

Dan Weston westondan at imageworks.com
Thu Nov 15 22:38:41 EST 2007


There are several possibilities. The one that maps most closely to the 
expression you wrote is:

 > import Data.Typeable(typeOf)
 > if typeOf a == typeOf (undefined :: Int) then f else g

Of course, f and g must have the same type.

See 
http://haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Typeable.html 
for more details.

Dan

BOUNEB ZINE EL ABIDINE wrote:
> 
> Dear All ;
> 
> I look for the function which return the type of un element in Haskell :
> 
> For example
> 
>    If  type(a) = Int then f else g
> 
> Regards




More information about the Haskell-fr mailing list