Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created August 22, 2013 10:08
Show Gist options
  • Select an option

  • Save qoelet/6305451 to your computer and use it in GitHub Desktop.

Select an option

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 = ["Kenny@northpole.sg", "Wutever@Evalution.com", "somethingthatsmellslikeSPAM", "h@iamvalidemail.org", "NOTSPAM@SPAM.NET"]
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