Hi Lennart, This is not a real solution, but maybe helpful. The hint package (wrapping the ghc API) has its typeOf:
cabal install hint > import Language.Haskell.Interpreter > runInterpreter (typeOf "\\x -> x") Right "t -> t" Best, Roland On Wed, Mar 25, 2009 at 7:33 PM, Lennart Augustsson <lenn...@augustsson.net> wrote: > Using Data.Typeable.typeOf we can get a representation of the the type > of a monomorphic value, for instance > Prelude Data.Typeable> typeOf not > Bool -> Bool > > But if we try using it on a polymorphic value it fails > Prelude Data.Typeable> typeOf id > > <interactive>:1:0: > Ambiguous type variable `a' in the constraint: > `Typeable a' arising from a use of `typeOf' at <interactive>:1:0-8 > Probable fix: add a type signature that fixes these type variable(s) > > And understandably so. Does anyone know of a trick to accomplish `typeOf id'? > Using something else than TypeRep as the representation, of course. > > Any tricks and existing language extensions are welcome. > (As ghc moves towards first class polymorphic values this question > gets more interesting.) > > -- Lennart > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- http://roland.zumkeller.googlepages.com/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe