hood-0.2.1: Debugging by observing in place

Safe HaskellNone
LanguageHaskell98

Debug.Hood.Observe

Contents

Synopsis

The main Hood API

observe :: Observable a => String -> a -> a Source

observe observes data structures in flight.

An example of use is map (+1) . observe "intermeduate" . map (+2)

In this example, we observe the value that flows from the producer map (+2) to the consumer map (+1).

observe can also observe functions as well a structural values.

newtype Observer Source

Constructors

O (forall a. Observable a => String -> a -> a) 

type Observing a = a -> a Source

runO :: IO a -> IO () Source

The main entry point; run some IO code, and debug inside it.

An example of using this debugger is

runO (print [ observe "+1" (+1) x | x <- observe "xs" [1..3]])
[2,3,4]
 -- +1
  {  1  -> 2
  }
 -- +1
  {  2  -> 3
  }
 -- +1
  {  3  -> 4
  }
 -- xs
  1 : 2 : 3 : []

Which says, the return is [2,3,4], there were 3 calls to +1 (showing arguments and results), and xs, which was the list 1 : 2 : 3 : [].

printO :: Show a => a -> IO () Source

print a value, with debugging

putStrO :: String -> IO () Source

print a string, with debugging

For advanced users, that want to render their own datatypes.

(<<) :: Observable a => ObserverM (a -> b) -> a -> ObserverM b infixl 9 Source

thunk :: Observable a => a -> ObserverM a Source

send :: String -> ObserverM a -> Parent -> a Source

observeBase :: Show a => a -> Parent -> a Source

observeOpaque :: String -> a -> Parent -> a Source

For users that want to write there own render drivers.

debugO :: IO a -> IO [CDS] Source

run some code and return the CDS structure (for when you want to write your own debugger).

data CDS Source

Constructors

CDSNamed String CDSSet 
CDSCons Int String [CDSSet] 
CDSFun Int CDSSet CDSSet 
CDSEntered Int 

Instances