Skip to content

Instantly share code, notes, and snippets.

@takoeight0821
Last active August 29, 2015 14:15
Show Gist options
  • Save takoeight0821/02e7782b6704a01cf8b9 to your computer and use it in GitHub Desktop.
Save takoeight0821/02e7782b6704a01cf8b9 to your computer and use it in GitHub Desktop.
ちょっとオブジェクト指向っぽい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