mealy

Mealy machines for processing time-series and ordered data.

https://github.com/tonyday567/mealy#readme

Stackage Nightly 2024-11-08:0.5.0.0
Latest on Hackage:0.5.0.0

See all snapshots mealy appears in

BSD-3-Clause licensed by Tony Day
Maintained by [email protected]
This version can be pinned in stack with:mealy-0.5.0.0@sha256:5bca910c6f8193d129b0e59a42fb77a3fe3f5766f0dd3b42f583148df5ed1cb0,2621

Module documentation for 0.5.0.0

#+TITLE: mealy

[[https://hackage.haskell.org/package/mealy][file:https://img.shields.io/hackage/v/mealy.svg]] [[https://github.com/tonyday567/mealy/actions?query=workflow%3Ahaskell-ci][file:https://github.com/tonyday567/mealy/workflows/haskell-ci/badge.svg]]

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.

#+begin_src haskell :results output
import Prelude
import Data.Mealy
#+end_src

#+begin_src haskell :results output
fold ((,) <$> ma 0.9 <*> std 0.9) [1..100::Double]
#+end_src

#+RESULTS:
: (91.00265621044142,9.472822805289121)

* Reference

[[https://stackoverflow.com/questions/27997155/finite-state-transducers-in-haskell][Finite State Transducers]]

Changes

0.5

  • Switched to harpie, away from numhask-array

0.4.4

  • Added some common patterns