Debug.Hood.Observe

hood-0.2.1: Debugging by observing in place

Safe Haskell | None
Language | Haskell98

Debug.Hood.Observe

Contents

- The main Hood API
- For advanced users, that want to render their own datatypes.
- For users that want to write there own render drivers.

Synopsis

- observe :: Observable a => String -> a -> a
- newtype Observer = O (forall a. Observable a => String -> a -> a)
- type Observing a = a -> a
- class Observable a where
  - observer :: a -> Parent -> a
  - observers :: String -> (Observer -> a) -> a
- runO :: IO a -> IO ()
- printO :: Show a => a -> IO ()
- putStrO :: String -> IO ()
- (<<) :: Observable a => ObserverM (a -> b) -> a -> ObserverM b
- thunk :: Observable a => a -> ObserverM a
- send :: String -> ObserverM a -> Parent -> a
- observeBase :: Show a => a -> Parent -> a
- observeOpaque :: String -> a -> Parent -> a
- debugO :: IO a -> IO [CDS]
- data CDS
  - = CDSNamed String CDSSet
  - | CDSCons Int String [CDSSet]
  - | CDSFun Int CDSSet CDSSet
  - | CDSEntered Int

# The main Hood API

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

`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

Constructors

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

type Observing a = a -> a

class Observable a where

Minimal complete definition

observer

Methods

observer :: a -> Parent -> a

observers :: String -> (Observer -> a) -> a

Instances

Observable Bool |
Observable Char |
Observable Double |
Observable Float |
Observable Int |
Observable Integer |
Observable () |
Observable Dynamic |
Observable SomeException |
Observable a => Observable [a] |
Observable a => Observable (IO a) |
Observable a => Observable (Maybe a) |
(Observable a, Observable b) => Observable (a -> b) |
(Observable a, Observable b) => Observable (Either a b) |
(Observable a, Observable b) => Observable (a, b) |
(Ix a, Observable a, Observable b) => Observable (Array a b) |
(Observable a, Observable b, Observable c) => Observable (a, b, c) |
(Observable a, Observable b, Observable c, Observable d) => Observable (a, b, c, d) |
(Observable a, Observable b, Observable c, Observable d, Observable e) => Observable (a, b, c, d, e) |

runO :: IO a -> IO ()

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 ()

print a value, with debugging

putStrO :: String -> IO ()

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

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

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

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

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

# For users that want to write there own render drivers.

debugO :: IO a -> IO [CDS]

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

data CDS

Constructors

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

Instances

Eq CDS |
Ord CDS |
Show CDS |