Skip to content

Instantly share code, notes, and snippets.

@hanshoglund
Created October 5, 2017 16:07
Show Gist options
  • Save hanshoglund/712eddfb95262e0b47655dcc68b77d59 to your computer and use it in GitHub Desktop.
Save hanshoglund/712eddfb95262e0b47655dcc68b77d59 to your computer and use it in GitHub Desktop.
data Moore a b = forall r . Moore (r -> b) (r -> a -> r) r
data Moore2 a b = Moore2 b (a -> Moore2 a b)
l :: Moore2 a b -> Moore a b
l machine = L (\(Moore2 state _) -> state) (\(Moore2 _ step) input -> step input) machine
r :: Moore a n -> Moore2 a b
r (Moore view step state) = Moore2 (view state) (\input -> r $ Moore view step $ step state input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment