fix-parser-simple 15318.1 → 15318.2
raw patch · 2 files changed
+14/−11 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Parser.Fix.Simple: foldfix :: (t -> a, t -> t -> a, t -> t -> t -> a) -> (t -> TokenType) -> [t] -> [a]
+ Parser.Fix.Simple: foldfix :: (t -> a, t -> a -> a, t -> a -> a -> a) -> (t -> TokenType) -> [t] -> a
- Parser.Fix.Simple: parsefix :: (t -> a, t -> t -> a, t -> t -> t -> a) -> (t -> TokenType) -> [t] -> [a]
+ Parser.Fix.Simple: parsefix :: (t -> a, t -> a -> a, t -> a -> a -> a) -> (t -> TokenType) -> [t] -> a
Files
- Parser/Fix/Simple.hs +13/−10
- fix-parser-simple.cabal +1/−1
Parser/Fix/Simple.hs view
@@ -22,24 +22,23 @@ deriving Eq; -- | Shunt and Fold-parsefix :: (t -> a, t -> t -> a, t -> t -> t -> a) -> (t -> TokenType) -> [t] -> [a];+parsefix :: (t -> a, t -> a -> a, t -> a -> a -> a) -> (t -> TokenType) -> [t] -> a; parsefix apply = liftM2 (.) (foldfix apply) shunt; -- | Fold expression in postfix form-foldfix :: (t -> a, t -> t -> a, t -> t -> t -> a) -> (t -> TokenType) -> [t] -> [a];+foldfix :: (t -> a, t -> a -> a, t -> a -> a -> a) -> (t -> TokenType) -> [t] -> a; foldfix (apply0, apply1, apply2) lookup_t = let {- foldfix' _ [] = [];- foldfix' stack (t:ts) =+ foldfix' stack = flip list (list const (error "Empty Stack!") stack) $ \ t -> case lookup_t t of {- TokenPlain -> foldfix' (t:stack) ts;+ TokenPlain -> foldfix' (apply0 t:stack); TokenOper fix p | fix_arity fix == 2,- (x:y:stack') <- stack -> apply2 t x y : foldfix' stack' ts+ (x:y:stack') <- stack -> foldfix' (apply2 t x y : stack') | fix_arity fix == 1,- (x:stack') <- stack -> apply1 t x : foldfix' stack' ts- | otherwise -> error "Malformed fix expression";- TokenLParenth -> error "Mismatched Parentheses";- TokenRParenth -> error "Mismatched Parentheses";+ (x:stack') <- stack -> foldfix' (apply1 t x : stack')+ | otherwise -> const $ error "Malformed fix expression";+ TokenLParenth -> const $ error "Mismatched Parentheses";+ TokenRParenth -> const $ error "Mismatched Parentheses"; }; fix_arity Prefix = 1;@@ -75,3 +74,7 @@ (ts, _) -> (error "Mismatched Parentheses", ts); }; }) [];++list :: (a -> [a] -> b) -> b -> [a] -> b;+list f y [] = y;+list f y (x:xs) = f x xs;
fix-parser-simple.cabal view
@@ -1,5 +1,5 @@ Name:fix-parser-simple-Version:15318.1+Version:15318.2 Description:Simple fix-expression parser License:LGPL License-File:license.txt