Get module contents

The commands :browse ,: :info and :type GHCi are very convenient.

Is it possible to get the same program information in a Haskell program? That is, to get exported functions from the module, file types, etc.

+6
source share
3 answers

Danielle Fisher commented :

You can use the GHC API. I do not know an easier way.

It seems to be inconvenient, but working fine. And I think this is how :info works in GHCi. Thanks for the suggestion.

0
source

:browse - when the Haskell program is compiled, (useful) information about which module comes from is not saved, so your program will not be able to access this information.

:type - If you are not using Data.Typeable , types are not displayed at all at runtime. The types in Haskell are mainly intended for the compiler to check the correctness / security of the code.

:info - See above.

+5
source

to get module functions at compile time - the language-haskell-extract package may be of interest to you. This helps you retrieve functions according to regex.

http://hackage.haskell.org/package/language-haskell-extract-0.2.1

+3
source

Source: https://habr.com/ru/post/908785/


All Articles