From 37f974ef024b86778ce3c0144393b857720d1434 Mon Sep 17 00:00:00 2001 From: Rnhmjoj Date: Fri, 27 Feb 2015 14:04:05 +0100 Subject: [PATCH] Use pattern matching instead of case --- hsilop.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hsilop.hs b/hsilop.hs index d346229..d52ce2e 100644 --- a/hsilop.hs +++ b/hsilop.hs @@ -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