machines-0.6.3: Networked stream transducers

Copyright(C) 2012 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Machine.Mealy

Description

Synopsis

Documentation

newtype Mealy a b Source #

Mealy machines

Examples

We can enumerate inputs:

>>> let countingMealy = unfoldMealy (\i x -> ((i, x), i + 1)) 0
>>> run (auto countingMealy <~ source "word")
[(0,'w'),(1,'o'),(2,'r'),(3,'d')]

Constructors

Mealy 

Fields

Instances

Arrow Mealy Source # 

Methods

arr :: (b -> c) -> Mealy b c #

first :: Mealy b c -> Mealy (b, d) (c, d) #

second :: Mealy b c -> Mealy (d, b) (d, c) #

(***) :: Mealy b c -> Mealy b' c' -> Mealy (b, b') (c, c') #

(&&&) :: Mealy b c -> Mealy b c' -> Mealy b (c, c') #

ArrowChoice Mealy Source # 

Methods

left :: Mealy b c -> Mealy (Either b d) (Either c d) #

right :: Mealy b c -> Mealy (Either d b) (Either d c) #

(+++) :: Mealy b c -> Mealy b' c' -> Mealy (Either b b') (Either c c') #

(|||) :: Mealy b d -> Mealy c d -> Mealy (Either b c) d #

ArrowApply Mealy Source # 

Methods

app :: Mealy (Mealy b c, b) c #

Corepresentable Mealy Source # 

Associated Types

type Corep (Mealy :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep Mealy d -> c) -> Mealy d c #

Closed Mealy Source # 

Methods

closed :: Mealy a b -> Mealy (x -> a) (x -> b) #

Choice Mealy Source # 

Methods

left' :: Mealy a b -> Mealy (Either a c) (Either b c) #

right' :: Mealy a b -> Mealy (Either c a) (Either c b) #

Strong Mealy Source # 

Methods

first' :: Mealy a b -> Mealy (a, c) (b, c) #

second' :: Mealy a b -> Mealy (c, a) (c, b) #

Costrong Mealy Source # 

Methods

unfirst :: Mealy (a, d) (b, d) -> Mealy a b #

unsecond :: Mealy (d, a) (d, b) -> Mealy a b #

Profunctor Mealy Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> Mealy b c -> Mealy a d #

lmap :: (a -> b) -> Mealy b c -> Mealy a c #

rmap :: (b -> c) -> Mealy a b -> Mealy a c #

(#.) :: Coercible * c b => (b -> c) -> Mealy a b -> Mealy a c #

(.#) :: Coercible * b a => Mealy b c -> (a -> b) -> Mealy a c #

Automaton Mealy Source # 

Methods

auto :: Mealy a b -> Process a b Source #

Cosieve Mealy NonEmpty Source # 

Methods

cosieve :: Mealy a b -> NonEmpty a -> b #

Monad (Mealy a) Source #

slow diagonalization

Methods

(>>=) :: Mealy a a -> (a -> Mealy a b) -> Mealy a b #

(>>) :: Mealy a a -> Mealy a b -> Mealy a b #

return :: a -> Mealy a a #

fail :: String -> Mealy a a #

Functor (Mealy a) Source # 

Methods

fmap :: (a -> b) -> Mealy a a -> Mealy a b #

(<$) :: a -> Mealy a b -> Mealy a a #

MonadFix (Mealy a) Source # 

Methods

mfix :: (a -> Mealy a a) -> Mealy a a #

Applicative (Mealy a) Source # 

Methods

pure :: a -> Mealy a a #

(<*>) :: Mealy a (a -> b) -> Mealy a a -> Mealy a b #

(*>) :: Mealy a a -> Mealy a b -> Mealy a b #

(<*) :: Mealy a a -> Mealy a b -> Mealy a a #

Distributive (Mealy a) Source # 

Methods

distribute :: Functor f => f (Mealy a a) -> Mealy a (f a) #

collect :: Functor f => (a -> Mealy a b) -> f a -> Mealy a (f b) #

distributeM :: Monad m => m (Mealy a a) -> Mealy a (m a) #

collectM :: Monad m => (a -> Mealy a b) -> m a -> Mealy a (m b) #

Representable (Mealy a) Source # 

Associated Types

type Rep (Mealy a :: * -> *) :: * #

Methods

tabulate :: (Rep (Mealy a) -> a) -> Mealy a a #

index :: Mealy a a -> Rep (Mealy a) -> a #

MonadZip (Mealy a) Source # 

Methods

mzip :: Mealy a a -> Mealy a b -> Mealy a (a, b) #

mzipWith :: (a -> b -> c) -> Mealy a a -> Mealy a b -> Mealy a c #

munzip :: Mealy a (a, b) -> (Mealy a a, Mealy a b) #

Pointed (Mealy a) Source # 

Methods

point :: a -> Mealy a a #

Extend (Mealy a) Source # 

Methods

duplicated :: Mealy a a -> Mealy a (Mealy a a) #

extended :: (Mealy a a -> b) -> Mealy a a -> Mealy a b #

Category * Mealy Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

MonadReader (NonEmpty a) (Mealy a) Source # 

Methods

ask :: Mealy a (NonEmpty a) #

local :: (NonEmpty a -> NonEmpty a) -> Mealy a a -> Mealy a a #

reader :: (NonEmpty a -> a) -> Mealy a a #

type Corep Mealy Source # 
type Rep (Mealy a) Source # 
type Rep (Mealy a) = NonEmpty a

unfoldMealy :: (s -> a -> (b, s)) -> s -> Mealy a b Source #

A Mealy machine modeled with explicit state.

logMealy :: Semigroup a => Mealy a a Source #

Accumulate history.