Created
August 31, 2015 01:13
-
-
Save TheSeamau5/ac8f094774a9c87a1ad2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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