Skip to content

Instantly share code, notes, and snippets.

@takoeight0821 takoeight0821/Dog.hs
Last active Aug 29, 2015

Embed
What would you like to do?
ちょっとオブジェクト指向っぽいDSL
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
You can’t perform that action at this time.