Skip to content

Instantly share code, notes, and snippets.

@wayneseymour
Forked from exallium/strategy.hs
Created March 11, 2021 19:28
Show Gist options
  • Save wayneseymour/d207351156b08845fa0f78727508a4b2 to your computer and use it in GitHub Desktop.
Save wayneseymour/d207351156b08845fa0f78727508a4b2 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