This repository has been archived on 2020-07-05. You can view files and clone it, but cannot push or open issues or pull requests.
zurihac2020/test/app/Main.hs
Claudio Maggioni (maggicl) 4dd2cdfaad Bump Zurihac stuff
2020-07-05 18:15:49 +02:00

24 lines
No EOL
672 B
Haskell

database :: [(Integer, String)]
database = [(1, "Julie"),
(2, "Chris"),
(3, "Alonzo"),
(4, "Melman")]
greetUser :: Integer -> Maybe String
greetUser record = fmap ("Hello, " ++) ((lookup record database) >>= makeUsername)
removeSpaces :: String -> Maybe String
removeSpaces string =
case (filter (/= ' ') string) of
"" -> Nothing
result -> Just result
validateLength :: String -> Maybe String
validateLength string =
case (length string > 25) of
True -> Nothing
False -> Just string
makeUsername :: String -> Maybe String
makeUsername string = removeSpaces string >>= validateLength