Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kylecorbelli/c022dd63ac07f85eddbcdf472899d2c3 to your computer and use it in GitHub Desktop.

Select an option

Save kylecorbelli/c022dd63ac07f85eddbcdf472899d2c3 to your computer and use it in GitHub Desktop.
main :: IO ()
main =
putStrLn "what is your email address?" >>
getLine >>= \email ->
putStrLn . show $ runReader view email
view :: Reader Email Html
view = do
page_ <- page
return $ div
[ page_
]
page :: Reader Email Html
page = do
content_ <- content
return $ div
[ topNav
, content_
]
topNav :: Html
topNav =
div
[ h1 [ "OurSite.com" ]
]
content :: Reader Email Html
content = do
email <- ask
right_ <- right
return $ div
[ h1 [ "Custom Content for " ++ email ]
, left
, right_
]
left :: Html
left =
div
[ p [ "this is the left side" ]
]
right :: Reader Email Html
right = do
article_ <- article
return $ div
[ article_
]
article :: Reader Email Html
article = do
widget_ <- widget
return $ div
[ p [ "this is an article" ]
, widget_
]
widget :: Reader Email Html
widget = do
email <- ask
return $ div
[ p [ "Hey " ++ email ++ ", we've got a great offer for you!" ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment