BSD-3-Clause licensed by Tony Day
Maintained by [email protected]
This version can be pinned in stack with:mealy-0.5.1.1@sha256:97b6608923bce7008997b8a8ec473cb44466d307a04ce0be50f8b3bb7e955f13,2052

Module documentation for 0.5.1.1

mealy

Hackage Build Status

A ‘Mealy’ is a triple of functions

  • (a -> b) inject: Convert (initial) input into the (initial) state type.
  • (b -> a -> b) step: Update state given prior state and (new) input.
  • (c -> b) extract: Convert state to the output type.

A sum, for example, looks like M id (+) id where the first id is the initial injection and the second id is the covariant extraction.

This library provides support for computing statistics (such as an average or a standard deviation) as current state within a mealy context.

Usage

Usage is to supply a decay function representing the relative weights of recent values versus older ones, in the manner of exponentially-weighted averages. The library attempts to be polymorphic in the statistic which can be combined in applicative style.

import Prelude
import Data.Mealy
fold ((,) <$> ma 0.9 <*> std 0.9) [1..100::Double]
(91.00265621044142,9.472822805289121)

Reference

Finite State Transducers

Changes

0.5

  • Switched to harpie, away from numhask-array

0.4.4

  • Added some common patterns