
do r1 <- m1
r2 <- m2
return (r1 && r2)
Erik
On 6 June 2016 at 11:11, martin
Applicative does the trick. But using do-notation was my first attempts, but I could not figure it out. Can you see how to do this (other than using `ap`)?
Am 06/06/2016 um 10:20 AM schrieb Erik Hesselink:
Since `Mealy a` is an instance of `Applicative` you can do:
(&&) <$> m1 <*> m2
It's also a monad, so do notation would also work.
Erik
On 6 June 2016 at 10:00, martin
wrote: 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.