Re: Printing the types of definitions



About this list Date view Thread view Subject view Author view

Malcolm Wallace (malcolm-nhc@cs.york.ac.uk)
Fri, 5 May 2000 12:51:33 +0100


Forwarded message from Keith Wansbrough <Keith.Wansbrough@cl.cam.ac.uk> ---- Additional comment ---- nhc98 is the same as ghc and produces a .hi file containing the types of all functions exported from a module. However, nhc98's interface file is much more readable than GHC's. Malcolm ---- Original message ---- > I am missing a feature in nhc98 and ghc that I have in Clean > and is too useful: the ability of the compiler to print > the types of the definitions that are compiled. This helps > a lot software development. Possibly not quite what you want, but maybe useful: when you compile module Foo with GHC, two files are generated: Foo.o and Foo.hi. The latter is an `interface file', and contains the types of all the functions exported by the module, along with some others that may be required by the compiler for optimisation purposes. The interface file is really intended for machine use rather than human, but it can be read relatively easily. The syntax is not quite Haskell, but it's close. For example, here is the line for `foldr': 1 foldr :: __forall [a b] =3D> (a -> b -> b) -> b -> [a] -> b {-## __A 3 __C __S LLS __U (__inline_me (\ @ a @ b k :: (a -> b -> b) zz :: b xs :: [a] -> __letrec { go :: ([a] -> b) =3D \ ds :: [a] -> case ds of wild { P relBase.ZC x xs1 -> k x (go xs1); PrelBase.ZMZN -> zz }; } in go xs) ) ##-} ; Ignoring the comment and the `version number' at the beginning, we have: foldr :: __forall [a b] =3D> (a -> b -> b) -> b -> [a] -> b which should be clear enough. Quantification is explicit, and contexts appear a little differently. More on interface files: http://www.haskell.org/ghc/docs/latest/users_guide/separate-compilation.html : Keith Wansbrough, MSc, BSc(Hons) (Auckland) -------------------: : http://www.cl.cam.ac.uk/users/kw217/ mailto:kw217@cl.cam.ac.uk : :----------------------------------------------------------------:


About this list Date view Thread view Subject view Author view