Skip to content

Instantly share code, notes, and snippets.

@exallium
Created August 11, 2017 19:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save exallium/6e9dfd662b410fd0304338277e12ff0b to your computer and use it in GitHub Desktop.
Save exallium/6e9dfd662b410fd0304338277e12ff0b to your computer and use it in GitHub Desktop.
data Parser = WebParser | DbParser
class ParseStrategy p where
parse :: p -> String -> String
instance ParseStrategy Parser where
parse WebParser s = "code for parsing web stuff goes here"
parse DbParser s = "code for parsing db stuff goes here"
fromDB = parse DbParser
fromWeb = parse WebParser
main :: IO ()
main = do
-- decide which parser to utilize
let s = fromDB "asdf"
putStrLn s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment