Use pattern matching instead of case

This commit is contained in:
Rnhmjoj 2015-02-27 14:04:05 +01:00
parent 108e582b35
commit 37f974ef02

View File

@ -27,9 +27,8 @@ rpn = foldM parse [] . words >=> return . head where
parse (y:x:xs) (flip lookup dyad -> Just f) = Right (f x y : xs)
parse (x:xs) (flip lookup monad -> Just f) = Right (f x : xs)
parse xs (flip lookup nilad -> Just k) = Right (k : xs)
parse xs x = case readMaybe x of
Just x -> Right (x : xs)
Nothing -> Left "syntax error"
parse xs (readMaybe -> Just x) = Right (x : xs)
parse xs _ = Left "syntax error"
-- dyadic functions