Skip to content

Instantly share code, notes, and snippets.

@shapr
Last active April 26, 2017 15:57
Show Gist options
  • Select an option

  • Save shapr/e33a9dd61b5800b8141939e7b0768764 to your computer and use it in GitHub Desktop.

Select an option

Save shapr/e33a9dd61b5800b8141939e7b0768764 to your computer and use it in GitHub Desktop.
module Main where
import Data.Char
main = do
text <- getContents
let linesList = lines text
let results = map doThing linesList
mapM_ print results
let other = map doOtherThing linesList
mapM_ print other
doThing oneline = map toUpper oneline
doOtherThing ('a':_) = "starts with a"
doOtherThing ('b':_) = "start with b"
doOtherThing ('t':_) = "starts with t"
doOtherThing x = "we don't handle this case: " ++ x
doThatThing thatLine = case (head thatLine) of
'a' -> "probably starts with a"
x -> "we don't handle this thing: " ++ [x]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment