ghc-events-0.20.0.0: Library and tool for parsing .eventlog files from GHC

Safe Haskell | None
Language | Haskell2010

GHC.RTS.Events.Analysis

Synopsis

- data Machine s i = Machine {
  - initial :: s
  - final :: s -> Bool
  - alpha :: i -> Bool
  - delta :: s -> i -> Maybe s
  }
- validate :: Machine s i -> [i] -> Either (s, i) s
- validates :: Machine s i -> [i] -> [Either (s, i) s]
- simulate :: Machine s i -> [i] -> Process (s, i) (s, i)
- data Profile s = Profile {
  - profileState :: s
  - profileTime :: Timestamp
  }
- profile :: (Ord s, Eq s) => Machine s i -> (i -> Timestamp) -> [i] -> Process (Profile s, i) (s, Timestamp, Timestamp)
- profileIndexed :: (Ord k, Ord s, Eq s) => Machine s i -> (i -> Maybe k) -> (i -> Timestamp) -> [i] -> Process (Map k (Profile s), i) (k, (s, Timestamp, Timestamp))
- profileRouted :: (Ord k, Ord s, Eq s, Eq r) => Machine s i -> Machine r i -> (r -> i -> Maybe k) -> (i -> Timestamp) -> [i] -> Process ((Map k (Profile s), r), i) (k, (s, Timestamp, Timestamp))
- extractIndexed :: Ord k => (s -> i -> Maybe o) -> (i -> Maybe k) -> Map k s -> i -> Maybe (k, o)
- refineM :: (i -> j) -> Machine s j -> Machine s i
- profileM :: Ord s => (i -> Timestamp) -> Machine s i -> Machine (Profile s) i
- indexM :: Ord k => (i -> Maybe k) -> Machine s i -> Machine (Map k s) i
- toList :: Process e a -> [a]
- toMaybe :: Process e a -> Maybe e
- data Process e a
  - = Done
  - | Fail e
  - | Prod a (Process e a)
- routeM :: Ord k => Machine r i -> (r -> i -> Maybe k) -> Machine s i -> Machine (Map k s, r) i

# Documentation

data Machine s i Source #

This is based on a simple finite state machine hence the names `delta` for the state transition function. Since states might be more than simple pattern matched constructors, we use `finals :: state -> Bool`, rather than `Set state`, to indicate that the machine is in some final state. Similarly for `alpha`, which indicates the alphabet of inputs to a machine. The function `delta` returns `Maybe` values, where `Nothing` indicates that no valid transition is possible: ie, there has been an error.

Constructors

Machine |

Fields

- initial :: s

  Initial state

- final :: s -> Bool

  Valid final states

- alpha :: i -> Bool

  Valid input alphabet

- delta :: s -> i -> Maybe s

  State transition function

validate :: Machine s i -> [i] -> Either (s, i) s Source #

The `validate` function takes a machine and a list of inputs. The machine is started from its initial state and run against the inputs in turn. It returns the state and input on failure, and just the state on success.

validates :: Machine s i -> [i] -> [Either (s, i) s] Source #

This function is similar to `validate`, but outputs each intermediary state as well. For an incremental version, use `simulate`.

simulate :: Machine s i -> [i] -> Process (s, i) (s, i) Source #

This function produces a process that outputs all the states that a machine goes through.

data Profile s Source #

A state augmented by Timestamp information is held in `profileState`. When the state changes, `profileMap` stores a map between each state and its cumulative time.

Constructors

Profile |

Fields

- profileState :: s

  The current state

- profileTime :: Timestamp

  The entry time of the state

#### Instances

Instances details

Show s => Show (Profile s) Source # |
Instance details Defined in GHC.RTS.Events.Analysis Methods showsPrec :: Int -> Profile s -> ShowS Source # show :: Profile s -> String Source # showList :: [Profile s] -> ShowS Source #

profile Source #

Arguments

:: (Ord s, Eq s) |
=> Machine s i | A machine to profile
-> (i -> Timestamp) | Converts input to timestamps
-> [i] | The list of input
-> Process (Profile s, i) (s, Timestamp, Timestamp) |

profileIndexed :: (Ord k, Ord s, Eq s) => Machine s i -> (i -> Maybe k) -> (i -> Timestamp) -> [i] -> Process (Map k (Profile s), i) (k, (s, Timestamp, Timestamp)) Source #

profileRouted :: (Ord k, Ord s, Eq s, Eq r) => Machine s i -> Machine r i -> (r -> i -> Maybe k) -> (i -> Timestamp) -> [i] -> Process ((Map k (Profile s), r), i) (k, (s, Timestamp, Timestamp)) Source #

extractIndexed :: Ord k => (s -> i -> Maybe o) -> (i -> Maybe k) -> Map k s -> i -> Maybe (k, o) Source #

refineM :: (i -> j) -> Machine s j -> Machine s i Source #

Machines sometimes need to operate on coarser input than they are defined for. This function takes a function that refines input and a machine that works on refined input, and produces a machine that can work on coarse input.

profileM :: Ord s => (i -> Timestamp) -> Machine s i -> Machine (Profile s) i Source #

This function takes a machine and profiles its state.

indexM Source #

Arguments

:: Ord k |
=> (i -> Maybe k) | An indexing function
-> Machine s i | A machine to index with
-> Machine (Map k s) i | The indexed machine

An indexed machine takes a function that multiplexes the input to a key and then takes a machine description to an indexed machine.

toList :: Process e a -> [a] Source #

toMaybe :: Process e a -> Maybe e Source #

data Process e a Source #

Constructors

Done |
Fail e |
Prod a (Process e a) |

#### Instances

Instances details

(Show e, Show a) => Show (Process e a) Source # |
Instance details Defined in GHC.RTS.Events.Analysis Methods showsPrec :: Int -> Process e a -> ShowS Source # show :: Process e a -> String Source # showList :: [Process e a] -> ShowS Source #

routeM :: Ord k => Machine r i -> (r -> i -> Maybe k) -> Machine s i -> Machine (Map k s, r) i Source #

A machine can be indexed not only by the inputs, but also by the state of an intermediary routing machine. This is a generalisation of indexM.