Skip to content

Instantly share code, notes, and snippets.

@mmhelloworld
Created December 26, 2013 06:13
Show Gist options
  • Save mmhelloworld/8130374 to your computer and use it in GitHub Desktop.
Save mmhelloworld/8130374 to your computer and use it in GitHub Desktop.
Frege Regex
frege> pure native groupCount :: Matcher -> Int
frege> match s regex = groups <$> (s =~ regex) where groups m = [m.group i | i <- [1..groupCount m]]
frege> Just (Just year: Just month: Just day: _) = "2011-07-15" `match` #(\d\d\d\d)-(\d\d)-(\d\d)#
frege> println [year, month, day]
["2011", "07", "15"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment