Permalink
Browse files

refactored parseBird'

  • Loading branch information...
1 parent 9406a97 commit d9720d7d35edb44dc690c99ec86bb0d1c9e62faf Hakim Cassimally committed May 17, 2011
Showing with 5 additions and 7 deletions.
  1. +5 −7 scratch/haskell/bird.hs
View
@@ -32,13 +32,11 @@ parseExprOuter = ((try parseSong) <|> parseExprAux) <* eof
parseExprAux = (try parseList) <|> (try parseBird) <|> (try parseBirdV)
-parseBirdV = do f <- lower
- r <- many (digit <|> oneOf "*^")
- return $ BirdV (f:r)
-
-parseBird = do f <- upper
- r <- many (digit <|> oneOf "*^")
- return $ Bird (f:r)
+parseBird = parseBird' upper Bird
+parseBirdV = parseBird' lower BirdV
+parseBird' s c = do f <- s
+ r <- many (digit <|> oneOf "*^")
+ return $ c (f:r)
parseList = char '(' *> parseSong <* char ')'

0 comments on commit d9720d7

Please sign in to comment.