[Haskell-cafe] New version of itself
martin
martin.drautzburg at web.de
Mon Jun 6 08:00:31 UTC 2016
Carl,
thanks for pointing me towards mealy machines.
Maybe you can help me with this one: I am trying to compose two mealy machines into one. Suppose I have
m1 :: Mealy a Bool
m2 :: Mealy a Bool
now I want a combinded mealy machine which outputs True when both m1 and m2 return True and False otherwise. I can write
this using runMealy. But this looks awkward, because it is a bare-bones implementation and doesn't make use of any of
the typeclasses Mealy is a member of. I.e. the machines package is basically not used at all.
Am 06/04/2016 um 07:10 PM schrieb Carl Howells:
> That's basically a Mealy machine. See
> https://hackage.haskell.org/package/machines-0.6/docs/Data-Machine-Mealy.html
>
> newtype Logger a l = Logger (Mealy (a, Log l) (Log l))
>
> Not quite an exact isomorphism since (,) is lifted, but it's close.
>
> You're not actually doing anything weird there. That's a pretty
> standard functional representation of a state machine.
>
More information about the Haskell-Cafe
mailing list