Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (47 sloc) 1.27 KB
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module PoemWriter where
import Data.Text
import Data.Text (pack)
import NeatInterpolation
helpText :: Text
helpText =
help see this menu, obviously
say say some text placed in a ascii banner
poem say a little poem for your muse
exit say bye!
decorate :: Text -> Text
decorate message =
writePoem :: Text -> Text
writePoem muse =
Dear $muse,
Roses are not blue
Violets are not red
Whatever you do
It trumps being dead
exec :: [Text] -> Text
exec ["poem", muse] = writePoem muse
exec ("say":message) = decorate $ Data.Text.unwords message
exec ["exit"] = decorate "Bye cruel world!"
exec ["help"] = helpText
exec x = [text|"'${input}' was an example of an incorrect command"|]
input = Data.Text.unwords x
userInputs =
[ "Incorrect command"
, "say Welcome to the mean poem machine"
, "poem reader"
, "exit"
main = do
let textOutputs = (exec . Data.Text.words) userInputs
mapM_ (putStrLn . unpack) textOutputs
You can’t perform that action at this time.