Miles has recently been common. Consider infinite flow
data Stream a = Stream a (Stream a)
right now we can write endless streams that can be used, for example [1..]
oneUpTo :: Stream Int
oneUpTo = go 1 where go n = Stream n (go (n+1))
but sometimes it’s useful to record streams that input may influence. To do this, we will hide the next "step" of the stream after the function
data Mealy b a = Mealy (b -> (a, Mealy b a))
, echo
echo :: a -> Mealy (Maybe a) a
echo a = Mealy go where
go Nothing = (a, echo a )
go (Just a') = (a', echo a')
switch "" . , . , () .
, Mealy a Category.
instance Category Mealy where
id = Mealy (\a -> (a, id))
Mealy bc . Mealy ab = Mealy $ \a -> case ab a of
(b, nab) -> case bc b of
(c, nbc) -> (c, nbc . nab)
Mealy, , , .
, machines Hackage.