Last active
July 28, 2017 16:02
-
-
Save masaeedu/30adb29ad4b1d0cfd1ae65aaedf7ad9e 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
newtype Visitor e r = Visitor { visit :: e -> r } | |
data Employee = PermanentEmployee | Contractor | |
xmlvisitor :: Visitor Employee String | |
xmlvisitor = Visitor { visit = visitEmp } | |
where visitEmp PermanentEmployee = "<employee />" | |
visitEmp Contractor = "<contractor />" | |
class Visitee e where | |
accept :: e -> Visitor e r -> r | |
instance Visitee Employee where | |
accept e v = visit v e | |
main = do putStrLn (accept PermanentEmployee xmlvisitor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment