Last active
August 29, 2015 14:15
-
-
Save takoeight0821/02e7782b6704a01cf8b9 to your computer and use it in GitHub Desktop.
ちょっとオブジェクト指向っぽいDSL
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
newDog name message | |
| message == "bark" = "Bowwow!" | |
| message == "hey " ++ name = name ++ " came at you." | |
| otherwise = "?" | |
dog = newDog "Pochi" | |
main = mapM_ print [dog "bark", dog "hey Pochi", dog "hey John", dog "run"] | |
{- | |
output: | |
"Bowwow!" | |
"Pochi came at you." | |
"?" | |
"?" | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment