Is there is way in GHCi to basically get a state dump? By this I mean a list of:
Assuming that this is possible, is it also possible to do this at runtime, say during an exception?
:browse
will give you most of this information. It shows
Without any arguments, it shows this information for the currently loaded module. You can also specify a different module.
Prelude> :browse Control.Applicative
class (Functor f) => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b
(*>) :: f a -> f b -> f b
(<*) :: f a -> f b -> f a
...
To see more detail, including precedence and associativity for operators, as well as instances for a data type, use :info
.
Prelude> :info (^)
(^) :: (Num a, Integral b) => a -> b -> a -- Defined in GHC.Real
infixr 8 ^
Prelude> :info Bool
data Bool = False | True -- Defined in GHC.Bool
instance Bounded Bool -- Defined in GHC.Enum
instance Enum Bool -- Defined in GHC.Enum
instance Eq Bool -- Defined in GHC.Base
instance Ord Bool -- Defined in GHC.Base
instance Read Bool -- Defined in GHC.Read
These commands are also available while debugging.
For more information, type :help
or see the GHCi chapter of the GHC user's guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With