How to get all functions in a package?

Hello everyone,

I want to get all functions in a package (like Prelude) and print them out on the screen. Is that possible?

Hello notooth, maybe what you are looking for is :browse in ghci?

> :browse Prelude
(!!) :: [a] -> Int -> a
($) :: (a -> b) -> a -> b
($!) :: (a -> b) -> a -> b
(&&) :: Bool -> Bool -> Bool
(++) :: [a] -> [a] -> [a]
⋮

How can I do that in Haskell code? I want to get the functions and use them at run-time too.

The hint package can do this, but it won’t be very pretty. It depends on GHC itself, so it is a pretty heavyweight solution. There is an example on the linked page which includes a function that gets all functions from a module.

1 Like

Thank you. I will take a look.