Last active
September 20, 2017 22:55
-
-
Save benaryorg/62d3283fb50701ac6a51f3a811c4f7e9 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env stack | |
-- stack --install-ghc runghc -- -Wno-tabs | |
data Event | |
= Noop | |
| Noise | |
| Pats | |
deriving (Show,Read) | |
data Action | |
= Sleep | |
| Purr | |
| Meow | |
deriving (Show,Read) | |
main :: IO () | |
main = interact (unlines . map show . eventLoop . map read . lines) | |
eventLoop :: [Event] -> [Action] | |
eventLoop = live cat | |
live :: (Event -> [Action]) -> [Event] -> [Action] | |
live style = concat . map style | |
cat :: Event -> [Action] | |
cat Pats = [Purr] | |
cat Noop = [Sleep] | |
cat Noise = [] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment