| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Debug.Hoed.Observe
Synopsis
- type UID = Int
- data Event = Event {
- eventParent :: !Parent
- change :: !Change
- data EventWithId = EventWithId {}
- data Change
- type ParentPosition = Word8
- data Parent = Parent {
- parentUID :: !UID
- parentPosition :: !ParentPosition
- root :: Parent
- isRootEvent :: Event -> Bool
- type Trace = Vector Event
- endEventStream :: IO Trace
- sendEvent :: Int -> Parent -> Change -> IO ()
- lookupOrAddString :: Text -> IO Int
- events :: Rope IO MVector Event
- strings :: MVar (Pair Int (HashMap Text Int))
- stringsLookupTable :: IORef (Vector Text)
- lookupString :: Int -> Text
- initUniq :: IO ()
- getUniq :: IO UID
- peepUniq :: IO UID
- uniq :: IORef UID
- class Observable a where
- class GObservable f where
- constrainBase :: (Show a, Eq a) => a -> a -> a
- class GConstrain f where
- gdmFunObserver :: (Observable a, Observable b) => Parent -> (a -> b) -> a -> b
- observeBase :: Show a => a -> Parent -> a
- observeOpaque :: Text -> a -> Parent -> a
- newtype ObserverM a = ObserverM {}
- thunk :: (a -> Parent -> a) -> a -> ObserverM a
- gthunk :: GObservable f => f a -> ObserverM (f a)
- (<<) :: Observable a => ObserverM (a -> b) -> a -> ObserverM b
- gdMapM :: Monad m => (a -> m a) -> m (a -> b) -> a -> m b
- gobserve :: (a -> Parent -> a) -> Text -> a -> (a, Int)
- observe :: Observable a => Text -> a -> a
- 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
- sendObserveFnPacket :: ObserverM a -> Parent -> a
- ourCatchAllIO :: IO a -> (SomeException -> IO a) -> IO a
- handleExc :: Parent -> SomeException -> IO a
Documentation
Constructors
| Event | |
Fields
| |
Instances
data EventWithId #
Constructors
| EventWithId | |
Instances
| Show EventWithId # | |
Defined in Debug.Hoed.Observe Methods showsPrec :: Int -> EventWithId -> ShowS # show :: EventWithId -> String # showList :: [EventWithId] -> ShowS # | |
Instances
type ParentPosition = Word8 #
Constructors
| Parent | |
Fields
| |
Instances
isRootEvent :: Event -> Bool #
endEventStream :: IO Trace #
lookupOrAddString :: Text -> IO Int #
stringsLookupTable :: IORef (Vector Text) #
lookupString :: Int -> Text #
class Observable a where #
A type class for observable values.
- For
Genericdatatypes it can be derived automatically. - For opaque datatypes, use
observeOpaqueor 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)
Methods
observer :: a -> Parent -> a #
observer :: (Generic a, GObservable (Rep a)) => a -> Parent -> a #
constrain :: (Generic a, GConstrain (Rep a)) => a -> a -> a #
Instances
class GObservable f where #
Minimal complete definition
Methods
gdmobserver :: f a -> Parent -> f a #
gdmObserveArgs :: f a -> ObserverM (f a) #
gdmShallowShow :: f a -> Text #
Instances
constrainBase :: (Show a, Eq a) => a -> a -> a #
class GConstrain f where #
Minimal complete definition
Methods
gconstrain :: f a -> f a -> f a #
Instances
| GConstrain (U1 :: * -> *) # | |
Defined in Debug.Hoed.Observe Methods gconstrain :: U1 a -> U1 a -> U1 a # | |
| Observable a => GConstrain (K1 i a :: * -> *) # | |
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) # | |
Defined in Debug.Hoed.Observe Methods gconstrain :: (a :+: b) a0 -> (a :+: b) a0 -> (a :+: b) a0 # | |
| (GConstrain a, GConstrain b) => GConstrain (a :*: b) # | |
Defined in Debug.Hoed.Observe Methods gconstrain :: (a :*: b) a0 -> (a :*: b) a0 -> (a :*: b) a0 # | |
| GConstrain a => GConstrain (M1 D d a) # | |
Defined in Debug.Hoed.Observe | |
| (GConstrain a, Constructor c) => GConstrain (M1 C c a) # | |
Defined in Debug.Hoed.Observe | |
| (GConstrain a, Selector s) => GConstrain (M1 S s a) # | |
Defined in Debug.Hoed.Observe | |
gdmFunObserver :: (Observable a, Observable b) => Parent -> (a -> b) -> a -> b #
observeBase :: Show a => a -> Parent -> a #
observeOpaque :: Text -> a -> Parent -> a #
gthunk :: GObservable f => f a -> ObserverM (f a) #
(<<) :: Observable a => ObserverM (a -> b) -> a -> ObserverM b infixl 9 #
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)) yTo 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
gdmobserver_ :: GObservable f => f a -> Parent -> f a #
unsafeWithUniq :: (Int -> IO a) -> a #
generateContext :: (a -> Parent -> a) -> Text -> a -> (a, Int) #
sendEnterPacket :: (a -> Parent -> a) -> a -> Parent -> a #
gsendEnterPacket :: GObservable f => f a -> Parent -> f a #
sendObserveFnPacket :: ObserverM a -> Parent -> a #
ourCatchAllIO :: IO a -> (SomeException -> IO a) -> IO a #
handleExc :: Parent -> SomeException -> IO a #