# HG changeset patch # User Markus Kaiser # Date 1357861788 -3600 # Node ID 53732b9605c75aa384e5190b03ad4a3231f63b69 # Parent e0ae5d8b55d36df0ca29f3b84a0251a3e6e6b979 add AdditionParser diff -r e0ae5d8b55d3 -r 53732b9605c7 exercises/src/AdditionParser.hs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exercises/src/AdditionParser.hs Fri Jan 11 00:49:48 2013 +0100 @@ -0,0 +1,18 @@ +module AdditionParser where + +import Data.Char +import Parser + +digit :: Parser Char Char +digit = one isDigit + +number :: Parser Char String +number = list1(one isDigit) + +addition :: Parser Char [String] +addition = number *** optional (item '+' *** addition >>> snd) >>> ints + where + ints (x, Just y) = x : y + ints (x, _) = [x] + +test = addition "2134+123+1+2+3" \ No newline at end of file