Hoed-0.5.1: Lightweight algorithmic debugging.

Safe HaskellNone
LanguageHaskell2010

Debug.Hoed.Observe

Synopsis

Documentation

type UID = Int #

data Event #

Constructors

Event 

Fields

Instances
Eq Event # 
Instance details

Defined in Debug.Hoed.Observe

Methods

(==) :: Event -> Event -> Bool #

(/=) :: Event -> Event -> Bool #

Show Event # 
Instance details

Defined in Debug.Hoed.Observe

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

Generic Event # 
Instance details

Defined in Debug.Hoed.Observe

Associated Types

type Rep Event :: Type -> Type #

Methods

from :: Event -> Rep Event x #

to :: Rep Event x -> Event #

Serialize Event # 
Instance details

Defined in Debug.Hoed.Serialize

Methods

put :: Putter Event #

get :: Get Event #

Unbox Event # 
Instance details

Defined in Debug.Hoed.Observe

Vector Vector Event # 
Instance details

Defined in Debug.Hoed.Observe

MVector MVector Event # 
Instance details

Defined in Debug.Hoed.Observe

type Rep Event # 
Instance details

Defined in Debug.Hoed.Observe

type Rep Event = D1 (MetaData "Event" "Debug.Hoed.Observe" "Hoed-0.5.1-Ku78xuqdA8q8Bxkbn1e0s7" False) (C1 (MetaCons "Event" PrefixI True) (S1 (MetaSel (Just "eventParent") SourceUnpack SourceStrict DecidedStrict) (Rec0 Parent) :*: S1 (MetaSel (Just "change") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Change)))
newtype Vector Event # 
Instance details

Defined in Debug.Hoed.Observe

newtype MVector s Event # 
Instance details

Defined in Debug.Hoed.Observe

data EventWithId #

Constructors

EventWithId 

Fields

Instances
Show EventWithId # 
Instance details

Defined in Debug.Hoed.Observe

data Change #

Constructors

Observe !Text 
Cons !Word8 !Text 
ConsChar !Char 
Enter 
Fun 
Instances
Eq Change # 
Instance details

Defined in Debug.Hoed.Observe

Methods

(==) :: Change -> Change -> Bool #

(/=) :: Change -> Change -> Bool #

Show Change # 
Instance details

Defined in Debug.Hoed.Observe

Generic Change # 
Instance details

Defined in Debug.Hoed.Observe

Associated Types

type Rep Change :: Type -> Type #

Methods

from :: Change -> Rep Change x #

to :: Rep Change x -> Change #

Serialize Change # 
Instance details

Defined in Debug.Hoed.Serialize

Unbox Change # 
Instance details

Defined in Debug.Hoed.Observe

Vector Vector Change # 
Instance details

Defined in Debug.Hoed.Observe

MVector MVector Change # 
Instance details

Defined in Debug.Hoed.Observe

type Rep Change # 
Instance details

Defined in Debug.Hoed.Observe

newtype Vector Change # 
Instance details

Defined in Debug.Hoed.Observe

newtype MVector s Change # 
Instance details

Defined in Debug.Hoed.Observe

data Parent #

Constructors

Parent 
Instances
Eq Parent # 
Instance details

Defined in Debug.Hoed.Observe

Methods

(==) :: Parent -> Parent -> Bool #

(/=) :: Parent -> Parent -> Bool #

Show Parent # 
Instance details

Defined in Debug.Hoed.Observe

Generic Parent # 
Instance details

Defined in Debug.Hoed.Observe

Associated Types

type Rep Parent :: Type -> Type #

Methods

from :: Parent -> Rep Parent x #

to :: Rep Parent x -> Parent #

Serialize Parent # 
Instance details

Defined in Debug.Hoed.Serialize

Unbox Parent # 
Instance details

Defined in Debug.Hoed.Observe

Vector Vector Parent # 
Instance details

Defined in Debug.Hoed.Observe

MVector MVector Parent # 
Instance details

Defined in Debug.Hoed.Observe

type Rep Parent # 
Instance details

Defined in Debug.Hoed.Observe

type Rep Parent = D1 (MetaData "Parent" "Debug.Hoed.Observe" "Hoed-0.5.1-Ku78xuqdA8q8Bxkbn1e0s7" False) (C1 (MetaCons "Parent" PrefixI True) (S1 (MetaSel (Just "parentUID") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 UID) :*: S1 (MetaSel (Just "parentPosition") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ParentPosition)))
newtype Vector Parent # 
Instance details

Defined in Debug.Hoed.Observe

newtype MVector s Parent # 
Instance details

Defined in Debug.Hoed.Observe

sendEvent :: Int -> Parent -> Change -> IO () #

initUniq :: IO () #

class Observable a where #

A type class for observable values.

  • For Generic datatypes it can be derived automatically.
  • For opaque datatypes, use observeOpaque or rely on the catch-all ? instance.
  • Custom implementations can exclude one or more fields from the observation:
 instance (Observable a, Observable b) => Observable (excluded, a,b) where
        observe (excluded,a,b) = send "(,,)" (return (,,) excluded << a << b)

Minimal complete definition

Nothing

Methods

observer :: a -> Parent -> a #

observer :: (Generic a, GObservable (Rep a)) => a -> Parent -> a #

constrain :: a -> a -> a #

constrain :: (Generic a, GConstrain (Rep a)) => a -> a -> a #

Instances
Observable Bool # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: Bool -> Parent -> Bool #

constrain :: Bool -> Bool -> Bool #

Observable Char # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: Char -> Parent -> Char #

constrain :: Char -> Char -> Char #

Observable Double # 
Instance details

Defined in Debug.Hoed.Observe

Observable Float # 
Instance details

Defined in Debug.Hoed.Observe

Observable Int # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: Int -> Parent -> Int #

constrain :: Int -> Int -> Int #

Observable Integer # 
Instance details

Defined in Debug.Hoed.Observe

Observable () # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: () -> Parent -> () #

constrain :: () -> () -> () #

Observable a #

A catch-all instance for non observable types that produces the opaque observation ?.

Instance details

Defined in Debug.Hoed

Methods

observer :: a -> Parent -> a #

constrain :: a -> a -> a #

Observable Dynamic # 
Instance details

Defined in Debug.Hoed.Observe

Observable SomeException # 
Instance details

Defined in Debug.Hoed.Observe

Observable a => Observable [a] # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: [a] -> Parent -> [a] #

constrain :: [a] -> [a] -> [a] #

Observable a => Observable (Maybe a) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: Maybe a -> Parent -> Maybe a #

constrain :: Maybe a -> Maybe a -> Maybe a #

Observable a => Observable (IO a) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: IO a -> Parent -> IO a #

constrain :: IO a -> IO a -> IO a #

(Observable a, Observable b) => Observable (a -> b) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: (a -> b) -> Parent -> a -> b #

constrain :: (a -> b) -> (a -> b) -> a -> b #

(Observable a, Observable b) => Observable (Either a b) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: Either a b -> Parent -> Either a b #

constrain :: Either a b -> Either a b -> Either a b #

(Observable a, Observable b) => Observable (a, b) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: (a, b) -> Parent -> (a, b) #

constrain :: (a, b) -> (a, b) -> (a, b) #

(Ix a, Observable a, Observable b) => Observable (Array a b) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: Array a b -> Parent -> Array a b #

constrain :: Array a b -> Array a b -> Array a b #

(Observable a, Observable b, Observable c) => Observable (a, b, c) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: (a, b, c) -> Parent -> (a, b, c) #

constrain :: (a, b, c) -> (a, b, c) -> (a, b, c) #

(Observable a, Observable b, Observable c, Observable d) => Observable (a, b, c, d) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: (a, b, c, d) -> Parent -> (a, b, c, d) #

constrain :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) #

(Observable a, Observable b, Observable c, Observable d, Observable e) => Observable (a, b, c, d, e) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

observer :: (a, b, c, d, e) -> Parent -> (a, b, c, d, e) #

constrain :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) #

class GObservable f where #

Methods

gdmobserver :: f a -> Parent -> f a #

gdmObserveArgs :: f a -> ObserverM (f a) #

gdmShallowShow :: f a -> Text #

Instances
GObservable (U1 :: Type -> Type) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gdmobserver :: U1 a -> Parent -> U1 a #

gdmObserveArgs :: U1 a -> ObserverM (U1 a) #

gdmShallowShow :: U1 a -> Text #

Observable a => GObservable (K1 i a :: Type -> Type) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gdmobserver :: K1 i a a0 -> Parent -> K1 i a a0 #

gdmObserveArgs :: K1 i a a0 -> ObserverM (K1 i a a0) #

gdmShallowShow :: K1 i a a0 -> Text #

(GObservable a, GObservable b) => GObservable (a :+: b) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gdmobserver :: (a :+: b) a0 -> Parent -> (a :+: b) a0 #

gdmObserveArgs :: (a :+: b) a0 -> ObserverM ((a :+: b) a0) #

gdmShallowShow :: (a :+: b) a0 -> Text #

(GObservable a, GObservable b) => GObservable (a :*: b) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gdmobserver :: (a :*: b) a0 -> Parent -> (a :*: b) a0 #

gdmObserveArgs :: (a :*: b) a0 -> ObserverM ((a :*: b) a0) #

gdmShallowShow :: (a :*: b) a0 -> Text #

(FieldLimit (S (S (S (S (S (S Z)))))) a, GObservable a) => GObservable (M1 D d a) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gdmobserver :: M1 D d a a0 -> Parent -> M1 D d a a0 #

gdmObserveArgs :: M1 D d a a0 -> ObserverM (M1 D d a a0) #

gdmShallowShow :: M1 D d a a0 -> Text #

(GObservable a, Constructor c) => GObservable (M1 C c a) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gdmobserver :: M1 C c a a0 -> Parent -> M1 C c a a0 #

gdmObserveArgs :: M1 C c a a0 -> ObserverM (M1 C c a a0) #

gdmShallowShow :: M1 C c a a0 -> Text #

(GObservable a, Selector s) => GObservable (M1 S s a) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gdmobserver :: M1 S s a a0 -> Parent -> M1 S s a a0 #

gdmObserveArgs :: M1 S s a a0 -> ObserverM (M1 S s a a0) #

gdmShallowShow :: M1 S s a a0 -> Text #

constrainBase :: (Show a, Eq a) => a -> a -> a #

class GConstrain f where #

Methods

gconstrain :: f a -> f a -> f a #

Instances
GConstrain (U1 :: Type -> Type) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gconstrain :: U1 a -> U1 a -> U1 a #

Observable a => GConstrain (K1 i a :: Type -> Type) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gconstrain :: K1 i a a0 -> K1 i a a0 -> K1 i a a0 #

(GConstrain a, GConstrain b) => GConstrain (a :+: b) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gconstrain :: (a :+: b) a0 -> (a :+: b) a0 -> (a :+: b) a0 #

(GConstrain a, GConstrain b) => GConstrain (a :*: b) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gconstrain :: (a :*: b) a0 -> (a :*: b) a0 -> (a :*: b) a0 #

GConstrain a => GConstrain (M1 D d a) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gconstrain :: M1 D d a a0 -> M1 D d a a0 -> M1 D d a a0 #

(GConstrain a, Constructor c) => GConstrain (M1 C c a) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gconstrain :: M1 C c a a0 -> M1 C c a a0 -> M1 C c a a0 #

(GConstrain a, Selector s) => GConstrain (M1 S s a) # 
Instance details

Defined in Debug.Hoed.Observe

Methods

gconstrain :: M1 S s a a0 -> M1 S s a a0 -> M1 S s a a0 #

gdmFunObserver :: (Observable a, Observable b) => Parent -> (a -> b) -> a -> b #

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

observeOpaque :: Text -> a -> Parent -> a #

newtype ObserverM a #

Constructors

ObserverM 

Fields

Instances
Monad ObserverM # 
Instance details

Defined in Debug.Hoed.Observe

Methods

(>>=) :: ObserverM a -> (a -> ObserverM b) -> ObserverM b #

(>>) :: ObserverM a -> ObserverM b -> ObserverM b #

return :: a -> ObserverM a #

fail :: String -> ObserverM a #

Functor ObserverM # 
Instance details

Defined in Debug.Hoed.Observe

Methods

fmap :: (a -> b) -> ObserverM a -> ObserverM b #

(<$) :: a -> ObserverM b -> ObserverM a #

Applicative ObserverM # 
Instance details

Defined in Debug.Hoed.Observe

Methods

pure :: a -> ObserverM a #

(<*>) :: ObserverM (a -> b) -> ObserverM a -> ObserverM b #

liftA2 :: (a -> b -> c) -> ObserverM a -> ObserverM b -> ObserverM c #

(*>) :: ObserverM a -> ObserverM b -> ObserverM b #

(<*) :: ObserverM a -> ObserverM b -> ObserverM a #

thunk :: (a -> Parent -> a) -> a -> ObserverM a #

gthunk :: GObservable f => f a -> ObserverM (f a) #

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

gdMapM :: Monad m => (a -> m a) -> m (a -> b) -> a -> m b #

gobserve :: (a -> Parent -> a) -> Text -> a -> (a, Int) #

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.

observe :: Observable a => Text -> a -> a #

Functions which you suspect of misbehaving are annotated with observe and should have a cost centre set. The name of the function, the label of the cost centre and the label given to observe need to be the same.

Consider the following function:

triple x = x + x

This function is annotated as follows:

triple y = (observe "triple" (\x -> {# SCC "triple" #}  x + x)) y

To produce computation statements like:

triple 3 = 6

To observe a value its type needs to be of class Observable. We provided instances for many types already. If you have defined your own type, and want to observe a function that takes a value of this type as argument or returns a value of this type, an Observable instance can be derived as follows:

  data MyType = MyNumber Int | MyName String deriving Generic

  instance Observable MyType

observer_ :: (a -> Parent -> a) -> a -> Parent -> a #

gdmobserver_ :: GObservable f => f a -> Parent -> f a #

unsafeWithUniq :: (Int -> IO a) -> a #

generateContext :: (a -> Parent -> a) -> Text -> a -> (a, Int) #

send :: Text -> ObserverM a -> Parent -> a #

sendEnterPacket :: (a -> Parent -> a) -> a -> Parent -> a #

gsendEnterPacket :: GObservable f => f a -> Parent -> f a #

evaluate :: a -> IO a #

ourCatchAllIO :: IO a -> (SomeException -> IO a) -> IO a #