hs-carbon-0.1.1.0: A Haskell framework for parallel monte carlo simulations

Safe HaskellSafe
LanguageHaskell98

Data.Result

Contents

Synopsis

Describing Simulation Results with Type Annotations

Carbon simulations are built up from MonteCarlo actions. A MonteCarlo action describes how to arrive at an observation, but not how to aggregate observations. This functionality is specified with a type annotation telling Haskell which instance of the type family Result should be used.

For example, given a MonteCarlo action, mySim, with type:

mySim :: RandomGen g => MonteCarlo g Bool

We get different results based on the instance of Result chosen:

experimentS mySimulation 100 g :: [Bool]
experimentS mySimulation 100 g :: BoolSumm

class Result r where Source

Result is the type family used to describe the aggregation techniques to be used in a Monte Carlo simulation. Instances of Result should specify the type of a single observation and how to include one. The value of a Result without any observations should be specified. Additionally, Results should be joinable.

Note that almost all instances of Result will be monoidal.

Associated Types

type Obs r :: * Source

The type of a single observation

Methods

addObs :: r -> Obs r -> r Source

How to add a single observation to the result

rjoin :: r -> r -> r Source

How to join two results together

rzero :: r Source

The value of a result without any observations

Instances

Result BoolSumm Source 
Result DoubleSumm Source 
NFData a => Result [a] Source

One common aggregation technique is appending observations to a list. In the interest of preventing thunks from building up, we force deep evaluation of observations.