Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created August 22, 2013 10:08
Show Gist options
  • Save qoelet/6305451 to your computer and use it in GitHub Desktop.
Save qoelet/6305451 to your computer and use it in GitHub Desktop.
-- just giving functors and the applicative operators a test drive
import Control.Applicative
import Data.Char
emails :: [String]
emails = ["[email protected]", "[email protected]", "somethingthatsmellslikeSPAM", "[email protected]", "[email protected]"]
hasAt :: [Char] -> Bool
hasAt [] = False
hasAt (x:xs) | x == '@' = True
| otherwise = hasAt xs
main = print $ (++) <$> ["Maybe valid: "] <*> (filter hasAt $ [(map toLower) email | email <- emails])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment