Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Created August 31, 2015 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheSeamau5/ac8f094774a9c87a1ad2 to your computer and use it in GitHub Desktop.
Save TheSeamau5/ac8f094774a9c87a1ad2 to your computer and use it in GitHub Desktop.
type Automaton a b = Automaton (a -> (b, Automaton a b))
arr : (a -> b) -> Automaton a b
arr f =
Automaton (\a -> (f a, arr f))
(>>>) : Automaton a b -> Automaton b c -> Automaton a c
(>>>) (Automaton f) (Automaton g) =
Automaton <|
\a ->
case f a of
(b, autoA) ->
case g b of
(c, autoB) ->
(c, autoA >>> autoB)
first : Automaton a b -> Automaton (a, c) (b, c)
first (Automaton f) =
Automaton <|
\(a,c) ->
case f a of
(b, autoAb) ->
((b,c), first autoAb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment