phino 0.0.0.47 → 0.0.0.48
raw patch · 14 files changed
+107/−102 lines, 14 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Rewriter: [_program] :: RewriteContext -> Program
- Rule: [_program] :: RuleContext -> Program
- Rule: data RuleContext
+ Printer: logPrintConfig :: (SugarType, Encoding, LineFormat)
+ Printer: printExpression' :: Expression -> PrintConfig -> String
+ Rule: newtype RuleContext
- Builder: contextualize :: Expression -> Expression -> Program -> Expression
+ Builder: contextualize :: Expression -> Expression -> Expression
- Deps: type BuildTermMethod = [ExtraArgument] -> Subst -> Program -> IO Term
+ Deps: type BuildTermMethod = [ExtraArgument] -> Subst -> IO Term
- Rewriter: RewriteContext :: Program -> Integer -> Integer -> Bool -> Bool -> BuildTermFunc -> Must -> SaveStepFunc -> RewriteContext
+ Rewriter: RewriteContext :: Integer -> Integer -> Bool -> Bool -> BuildTermFunc -> Must -> SaveStepFunc -> RewriteContext
- Rewriter: rewrite :: [Rewritten] -> [Rule] -> Set Program -> Integer -> RewriteContext -> IO ([Rewritten], Set Program)
+ Rewriter: rewrite :: RewriteState -> [Rule] -> Integer -> RewriteContext -> IO RewriteState
- Rule: RuleContext :: Program -> BuildTermFunc -> RuleContext
+ Rule: RuleContext :: BuildTermFunc -> RuleContext
Files
- phino.cabal +1/−1
- src/Builder.hs +9/−9
- src/CLI.hs +3/−4
- src/Dataize.hs +2/−3
- src/Deps.hs +1/−1
- src/Functions.hs +46/−51
- src/Printer.hs +5/−0
- src/Rewriter.hs +22/−20
- src/Rule.hs +13/−7
- test/CLISpec.hs +2/−2
- test/DataizeSpec.hs +1/−1
- test/FunctionsSpec.hs +1/−1
- test/RewriterSpec.hs +0/−1
- test/RuleSpec.hs +1/−1
phino.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: phino-version: 0.0.0.47+version: 0.0.0.48 license: MIT synopsis: Command-Line Manipulator of 𝜑-Calculus Expressions description: Please see the README on GitHub at <https://github.com/objectionary/phino#readme>
src/Builder.hs view
@@ -69,15 +69,15 @@ (printBytes _bts) _msg -contextualize :: Expression -> Expression -> Program -> Expression-contextualize ExGlobal _ (Program expr) = expr-contextualize ExThis expr _ = expr-contextualize ExTermination _ _ = ExTermination-contextualize (ExFormation bds) _ _ = ExFormation bds-contextualize (ExDispatch expr attr) context prog = ExDispatch (contextualize expr context prog) attr-contextualize (ExApplication expr (BiTau attr bexpr)) context prog =- let expr' = contextualize expr context prog- bexpr' = contextualize bexpr context prog+contextualize :: Expression -> Expression -> Expression+contextualize ExGlobal _ = ExGlobal+contextualize ExThis expr = expr+contextualize ExTermination _ = ExTermination+contextualize (ExFormation bds) _ = ExFormation bds+contextualize (ExDispatch expr attr) context = ExDispatch (contextualize expr context) attr+contextualize (ExApplication expr (BiTau attr bexpr)) context =+ let expr' = contextualize expr context+ bexpr' = contextualize bexpr context in ExApplication expr' (BiTau attr bexpr') buildAttribute :: Attribute -> Subst -> Built Attribute
src/CLI.hs view
@@ -331,7 +331,7 @@ let listing = if null rules' then const input else (\prog -> P.printProgram' prog (sugarType, UNICODE, flat)) xmirCtx = XmirContext omitListing omitComments listing printProgCtx = PrintProgCtx sugarType flat xmirCtx nonumber- rewrittens <- rewrite' program rules' (context program printProgCtx)+ rewrittens <- rewrite' program rules' (context printProgCtx) logDebug (printf "Printing rewritten 𝜑-program as %s" (show outputFormat)) progs <- printRewrittens printProgCtx rewrittens output targetFile progs@@ -364,10 +364,9 @@ (False, Nothing, _) -> do logDebug "The option '--target' is not specified, printing to console..." putStrLn prog- context :: Program -> PrintProgramContext -> RewriteContext- context program ctx =+ context :: PrintProgramContext -> RewriteContext+ context ctx = RewriteContext- program maxDepth maxCycles depthSensitive
src/Dataize.hs view
@@ -31,7 +31,6 @@ switchContext :: DataizeContext -> RewriteContext switchContext DataizeContext {..} = RewriteContext- _program _maxDepth _maxCycles _depthSensitive@@ -128,7 +127,7 @@ case resolved of Just obj -> morph obj ctx _ ->- if isNF expr (RuleContext (_program ctx) (_buildTerm ctx))+ if isNF expr (RuleContext (_buildTerm ctx)) then pure Nothing else do [Rewritten {program = Program expr'}] <- rewrite' (Program expr) normalizationRules (switchContext ctx) -- NMZ@@ -151,7 +150,7 @@ (Just (BiTau AtPhi expr), bds') -> case maybeLambda bds' of (Just (BiLambda _), _) -> throwIO (userError "The 𝜑 and λ can't be present in formation at the same time") (_, _) ->- let expr' = contextualize expr (ExFormation bds) (_program ctx)+ let expr' = contextualize expr (ExFormation bds) in dataize' expr' ctx (Nothing, _) -> case maybeLambda bds of (Just (BiLambda _), _) -> do
src/Deps.hs view
@@ -23,7 +23,7 @@ | TeBytes Bytes | TeBindings [Binding] -type BuildTermMethod = [ExtraArgument] -> Subst -> Program -> IO Term+type BuildTermMethod = [ExtraArgument] -> Subst -> IO Term type BuildTermFunc = String -> BuildTermMethod
src/Functions.hs view
@@ -10,29 +10,24 @@ import Control.Exception (throwIO) import Control.Monad (replicateM, when) import qualified Data.ByteString.Char8 as B-import Data.Char (intToDigit) import Data.Functor-import Data.Set (Set)-import qualified Data.Set import qualified Data.Set as Set+import Deps import GHC.IO (unsafePerformIO)+import Logger (logDebug) import Matcher import Misc-import Numeric (showHex) import Parser (parseAttributeThrows, parseNumberThrows)+import Printer (printAttribute, printExpression, printExtraArg) import Random (randomString) import Regexp-import System.Random (randomRIO)-import Deps import Text.Printf (printf) import qualified Yaml as Y-import Printer (printAttribute, printExpression, printExtraArg)-import Logger (logDebug) buildTerm :: BuildTermFunc-buildTerm func args subst prog = do+buildTerm func args subst = do logDebug (printf "Building new term using '%s' function..." func)- buildTerm' func args subst prog+ buildTerm' func args subst buildTerm' :: BuildTermFunc buildTerm' "contextualize" = _contextualize@@ -50,34 +45,34 @@ buildTerm' "join" = _join buildTerm' func = _unsupported func -argToBytes :: Y.ExtraArgument -> Subst -> Program -> IO Bytes-argToBytes (Y.ArgBytes bytes) subst _ = buildBytesThrows bytes subst-argToBytes (Y.ArgExpression expr) subst prog = do- (TeBytes bts) <- _dataize [Y.ArgExpression expr] subst prog+argToBytes :: Y.ExtraArgument -> Subst -> IO Bytes+argToBytes (Y.ArgBytes bytes) subst = buildBytesThrows bytes subst+argToBytes (Y.ArgExpression expr) subst = do+ (TeBytes bts) <- _dataize [Y.ArgExpression expr] subst pure bts-argToBytes arg _ _ = throwIO (userError (printf "Can't extract bytes from given argument: %s" (printExtraArg arg)))+argToBytes arg _ = throwIO (userError (printf "Can't extract bytes from given argument: %s" (printExtraArg arg))) -argToString :: Y.ExtraArgument -> Subst -> Program -> IO String-argToString arg subst prog = argToBytes arg subst prog <&> btsToUnescapedStr+argToString :: Y.ExtraArgument -> Subst -> IO String+argToString arg subst = argToBytes arg subst <&> btsToUnescapedStr -argToNumber :: Y.ExtraArgument -> Subst -> Program -> IO Double-argToNumber arg subst prog = argToBytes arg subst prog <&> either toDouble id . btsToNum+argToNumber :: Y.ExtraArgument -> Subst -> IO Double+argToNumber arg subst = argToBytes arg subst <&> either toDouble id . btsToNum _contextualize :: BuildTermMethod-_contextualize [Y.ArgExpression expr, Y.ArgExpression context] subst prog = do+_contextualize [Y.ArgExpression expr, Y.ArgExpression context] subst = do (expr', _) <- buildExpressionThrows expr subst (context', _) <- buildExpressionThrows context subst- pure (TeExpression (contextualize expr' context' prog))-_contextualize _ _ _ = throwIO (userError "Function contextualize() requires exactly 2 arguments as expression")+ pure (TeExpression (contextualize expr' context'))+_contextualize _ _ = throwIO (userError "Function contextualize() requires exactly 2 arguments as expression") _scope :: BuildTermMethod-_scope [Y.ArgExpression expr] subst _ = do+_scope [Y.ArgExpression expr] subst = do (_, scope) <- buildExpressionThrows expr subst pure (TeExpression scope)-_scope _ _ _ = throwIO (userError "Function scope() requires exactly 1 argument as expression")+_scope _ _ = throwIO (userError "Function scope() requires exactly 1 argument as expression") _randomTau :: BuildTermMethod-_randomTau args subst _ = do+_randomTau args subst = do attrs <- argsToAttrs args tau <- randomTau attrs pure (TeAttribute (AtLabel tau))@@ -101,28 +96,28 @@ if tau `elem` attrs then randomTau attrs else pure tau _dataize :: BuildTermMethod-_dataize [Y.ArgBytes bytes] subst _ = do+_dataize [Y.ArgBytes bytes] subst = do bts <- buildBytesThrows bytes subst pure (TeBytes bts)-_dataize [Y.ArgExpression expr] subst _ = do+_dataize [Y.ArgExpression expr] subst = do (expr', _) <- buildExpressionThrows expr subst case expr' of DataObject _ bytes -> pure (TeBytes bytes) _ -> throwIO (userError "Only data objects and bytes are supported by 'dataize' function now")-_dataize _ _ _ = throwIO (userError "Function dataize() requires exactly 1 argument as expression or bytes")+_dataize _ _ = throwIO (userError "Function dataize() requires exactly 1 argument as expression or bytes") _concat :: BuildTermMethod-_concat args subst prog = do- args' <- traverse (\arg -> argToString arg subst prog) args+_concat args subst = do+ args' <- traverse (\arg -> argToString arg subst) args pure (TeExpression (DataString (strToBts (concat args')))) _sed :: BuildTermMethod-_sed args subst prog = do+_sed args subst = do when (length args < 2) (throwIO (userError "Function sed() requires at least two arguments")) args' <- traverse ( \arg -> do- bts <- argToString arg subst prog+ bts <- argToString arg subst pure (B.pack bts) ) args@@ -162,27 +157,27 @@ | otherwise -> nextUntilSlash rest (B.snoc acc h) escape _randomString :: BuildTermMethod-_randomString [arg] subst prog = do- pat <- argToString arg subst prog+_randomString [arg] subst = do+ pat <- argToString arg subst str <- randomString pat pure (TeExpression (DataString (strToBts str)))-_randomString _ _ _ = throwIO (userError "Function random-string() requires exactly 1 dataizable argument")+_randomString _ _ = throwIO (userError "Function random-string() requires exactly 1 dataizable argument") _size :: BuildTermMethod-_size [Y.ArgBinding (BiMeta meta)] subst _ = do+_size [Y.ArgBinding (BiMeta meta)] subst = do bds <- buildBindingThrows (BiMeta meta) subst pure (TeExpression (DataNumber (numToBts (fromIntegral (length bds)))))-_size _ _ _ = throwIO (userError "Function size() requires exactly 1 meta binding")+_size _ _ = throwIO (userError "Function size() requires exactly 1 meta binding") _tau :: BuildTermMethod-_tau [Y.ArgExpression expr] subst prog = do- TeBytes bts <- _dataize [Y.ArgExpression expr] subst prog+_tau [Y.ArgExpression expr] subst = do+ TeBytes bts <- _dataize [Y.ArgExpression expr] subst attr <- parseAttributeThrows (btsToUnescapedStr bts) pure (TeAttribute attr)-_tau _ _ _ = throwIO (userError "Function tau() requires exactly 1 argument as expression")+_tau _ _ = throwIO (userError "Function tau() requires exactly 1 argument as expression") _string :: BuildTermMethod-_string [Y.ArgExpression expr] subst _ = do+_string [Y.ArgExpression expr] subst = do (expr', _) <- buildExpressionThrows expr subst str <- case expr' of DataNumber bts -> pure (DataString (strToBts (either show show (btsToNum bts))))@@ -196,29 +191,29 @@ ) ) pure (TeExpression str)-_string [Y.ArgAttribute attr] subst _ = do+_string [Y.ArgAttribute attr] subst = do attr' <- buildAttributeThrows attr subst pure (TeExpression (DataString (strToBts (printAttribute attr'))))-_string _ _ _ = throwIO (userError "Function string() requires exactly 1 argument as attribute or data expression (Φ̇.number or Φ̇.string)")+_string _ _ = throwIO (userError "Function string() requires exactly 1 argument as attribute or data expression (Φ̇.number or Φ̇.string)") _number :: BuildTermMethod-_number [Y.ArgExpression expr] subst _ = do+_number [Y.ArgExpression expr] subst = do (expr', _) <- buildExpressionThrows expr subst case expr' of DataString bts -> do num <- parseNumberThrows (btsToUnescapedStr bts) pure (TeExpression num) _ -> throwIO (userError (printf "Function number() expects expression to be 'Φ̇.string', but got:\n%s" (printExpression expr')))-_number _ _ _ = throwIO (userError "Function number() requires exactly 1 argument as 'Φ̇.string'")+_number _ _ = throwIO (userError "Function number() requires exactly 1 argument as 'Φ̇.string'") _sum :: BuildTermMethod-_sum args subst prog = do- nums <- traverse (\arg -> argToNumber arg subst prog) args+_sum args subst = do+ nums <- traverse (`argToNumber` subst) args pure (TeExpression (DataNumber (numToBts (sum nums)))) _join :: BuildTermMethod-_join [] _ _ = pure (TeBindings [])-_join args subst _ = do+_join [] _ = pure (TeBindings [])+_join args subst = do bds <- buildBindings args pure (TeBindings (join' bds Set.empty)) where@@ -245,8 +240,8 @@ else bd : join' bds (Set.insert attr attrs) updated :: Attribute -> Set.Set Attribute -> Attribute updated attr attrs =- let (TeAttribute attr') = unsafePerformIO (_randomTau (map Y.ArgAttribute (Set.toList attrs)) subst (Program ExGlobal))+ let (TeAttribute attr') = unsafePerformIO (_randomTau (map Y.ArgAttribute (Set.toList attrs)) subst) in attr' _unsupported :: BuildTermFunc-_unsupported func _ _ _ = throwIO (userError (printf "Function %s() is not supported or does not exist" func))+_unsupported func _ _ = throwIO (userError (printf "Function %s() is not supported or does not exist" func))
src/Printer.hs view
@@ -8,12 +8,14 @@ ( printProgram, printProgram', printExpression,+ printExpression', printAttribute, printBinding, printBytes, printExtraArg, printSubsts, PrintConfig (..),+ logPrintConfig, ) where @@ -33,6 +35,9 @@ defaultPrintConfig :: PrintConfig defaultPrintConfig = (SWEET, UNICODE, MULTILINE)++logPrintConfig :: (SugarType, Encoding, LineFormat)+logPrintConfig = (SWEET, UNICODE, SINGLELINE) printProgram' :: Program -> PrintConfig -> String printProgram' prog (sugar, encoding, line) = render (withLineFormat line $ withEncoding encoding $ withSugarType sugar $ programToCST prog)
src/Rewriter.hs view
@@ -31,6 +31,8 @@ import Yaml (ExtraArgument (..)) import qualified Yaml as Y +type RewriteState = ([Rewritten], Set.Set Program)+ data Rewritten = Rewritten { program :: Program, maybeRule :: Maybe Y.Rule@@ -40,8 +42,7 @@ left == right = program left == program right data RewriteContext = RewriteContext- { _program :: Program,- _maxDepth :: Integer,+ { _maxDepth :: Integer, _maxCycles :: Integer, _depthSensitive :: Bool, _sequence :: Bool,@@ -133,14 +134,14 @@ -- - X is sequence of programs; for more details about this sequence see description of rewrite' function -- - Y is Set of unique programs after each rule application. It allows to stop the rewriting if we're getting -- into loop and get back to program which we've already got before-rewrite :: [Rewritten] -> [Y.Rule] -> Set.Set Program -> Integer -> RewriteContext -> IO ([Rewritten], Set.Set Program)-rewrite rewrittens [] unique _ _ = pure (rewrittens, unique)-rewrite rewrittens (rule : rest) unique iteration ctx@RewriteContext {..} = do- (rewrittens', unique') <- _rewrite rewrittens 1 unique- rewrite rewrittens' rest unique' iteration ctx+rewrite :: RewriteState -> [Y.Rule] -> Integer -> RewriteContext -> IO RewriteState+rewrite state [] _ _ = pure state+rewrite state (rule : rest) iteration ctx@RewriteContext {..} = do+ state' <- _rewrite state 1+ rewrite state' rest iteration ctx where- _rewrite :: [Rewritten] -> Integer -> Set.Set Program -> IO ([Rewritten], Set.Set Program)- _rewrite _rewrittens _count _unique =+ _rewrite :: RewriteState -> Integer -> IO RewriteState+ _rewrite (_rewrittens, _unique) _count = let ruleName = fromMaybe "unknown" (Y.name rule) ptn = Y.pattern rule res = Y.result rule@@ -153,7 +154,7 @@ else pure (_rewrittens, _unique) else do logDebug (printf "Starting rewriting cycle for rule '%s': %d out of %d" ruleName _count _maxDepth)- matched <- R.matchProgramWithRule program rule (RuleContext _program _buildTerm)+ matched <- R.matchProgramWithRule program rule (RuleContext _buildTerm) if null matched then do logDebug (printf "Rule '%s' does not match, rewriting is stopped" ruleName)@@ -171,13 +172,14 @@ else do logDebug ( printf- "Applied '%s' (%d nodes -> %d nodes)"+ "Applied '%s' (%d nodes -> %d nodes)\n%s" ruleName (countNodes program) (countNodes prog)+ (printProgram prog) ) _saveStep prog (((iteration - 1) * _maxDepth) + _count)- _rewrite (rewriteSequence prog) (_count + 1) (Set.insert prog _unique)+ _rewrite (rewriteSequence prog, Set.insert prog _unique) (_count + 1) where rewriteSequence :: Program -> [Rewritten] rewriteSequence _prog@@ -191,12 +193,12 @@ -- programs after each rule application are included into sequence -- Otherwise sequence contains only one program rewrite' :: Program -> [Y.Rule] -> RewriteContext -> IO [Rewritten]-rewrite' prog rules ctx = _rewrite [Rewritten prog Nothing] 1 Set.empty <&> reverse+rewrite' prog rules ctx = _rewrite ([Rewritten prog Nothing], Set.empty) 1 ctx <&> reverse where- _rewrite :: [Rewritten] -> Integer -> Set.Set Program -> IO [Rewritten]- _rewrite rewrittens count unique = do- let cycles = _maxCycles ctx- must = _must ctx+ _rewrite :: RewriteState -> Integer -> RewriteContext -> IO [Rewritten]+ _rewrite state@(rewrittens, unique) count ctx@RewriteContext{..} = do+ let cycles = _maxCycles+ must = _must current = count - 1 if not (inRange must current) && current > 0 && exceedsUpperBound must current then throwIO (MustStopBefore must current)@@ -204,16 +206,16 @@ if current == cycles then do logDebug (printf "Max amount of rewriting cycles for all rules (%d) has been reached, rewriting is stopped" cycles)- if _depthSensitive ctx+ if _depthSensitive then throwIO (StoppedOnLimit "max-cycles" cycles) else pure rewrittens else do logDebug (printf "Starting rewriting cycle for all rules: %d out of %d" count cycles)- (rewrittens', unique') <- rewrite rewrittens rules unique count ctx+ state'@(rewrittens', unique') <- rewrite state rules count ctx if head rewrittens' == head rewrittens then do logDebug "Rewriting is stopped since it has no effect" if not (inRange must current) then throwIO (MustBeGoing must current) else pure rewrittens'- else _rewrite rewrittens' (count + 1) unique'+ else _rewrite state' (count + 1) ctx
src/Rule.hs view
@@ -27,9 +27,8 @@ import Yaml (normalizationRules) import qualified Yaml as Y -data RuleContext = RuleContext- { _program :: Program,- _buildTerm :: BuildTermFunc+newtype RuleContext = RuleContext+ { _buildTerm :: BuildTermFunc } -- Returns True if given expression matches with any of given normalization rules@@ -182,7 +181,7 @@ Just (MvExpression expr _) -> _matches pat expr (Subst mp) ctx _ -> pure [] _matches pat expr subst ctx = do- (TeBytes tgt) <- _buildTerm ctx "dataize" [Y.ArgExpression expr] subst (Program expr)+ (TeBytes tgt) <- _buildTerm ctx "dataize" [Y.ArgExpression expr] subst matched <- match (B.pack pat) (B.pack (btsToUnescapedStr tgt)) pure [subst | matched] @@ -234,7 +233,7 @@ extraSubstitutions substs extras RuleContext {..} = case extras of Nothing -> pure substs Just extras' -> do- logDebug "Building extra substitutions..."+ logDebug (printf "Building %d sets of extra substitutions.." (length substs)) res <- sequence [ foldlM@@ -247,7 +246,7 @@ _ -> Nothing func = Y.function extra args = Y.args extra- term <- _buildTerm func args subst' _program+ term <- _buildTerm func args subst' meta <- case term of TeExpression expr -> do logDebug (printf "Function %s() returned expression:\n%s" func (printExpression expr))@@ -269,15 +268,21 @@ extras' | subst <- substs ]+ logDebug "Extra substitutions have been built" pure (catMaybes res) +-- @todo #432:30min Fix log for not matched pattern. Right now we print+-- the name of the rule if pattern is not matched. It would be better to print+-- the pattern itself. To achieve that we should extend CST so it supports meta+-- attributes, expressions and so on. Don't forget to remove the puzzle matchProgramWithRule :: Program -> Y.Rule -> RuleContext -> IO [Subst] matchProgramWithRule program rule ctx = let ptn = Y.pattern rule matched = matchProgram ptn program+ name = fromMaybe "unknown" (Y.name rule) in if null matched then do- logDebug "Pattern was not matched"+ logDebug (printf "Pattern from rule '%s' was not matched" name) pure [] else do when' <- meetMaybeCondition (Y.when rule) matched ctx@@ -286,6 +291,7 @@ logDebug "The 'when' condition wasn't met" pure [] else do+ logDebug (printf "Rule %s" (fromMaybe "unknown" (Y.name rule))) extended <- extraSubstitutions when' (Y.where_ rule) ctx if null extended then do
test/CLISpec.hs view
@@ -125,7 +125,7 @@ it "with --normalize and --must=1" $ withStdin "Q -> [[ x -> [[ y -> 5 ]].y ]].x" $ testCLIFailed- ["rewrite", "--max-depth=2", "--normalize", "--must=1"]+ ["rewrite", "--max-cycles=2", "--max-depth=1", "--normalize", "--must=1"] ["it's expected rewriting cycles to be in range [1], but rewriting has already reached 2"] it "when --in-place is used without input file" $@@ -362,7 +362,7 @@ it "when cycles exceed range ..1" $ withStdin "Q -> [[ x -> [[ y -> 5 ]].y ]].x" $ testCLIFailed- ["rewrite", "--max-depth=2", "--normalize", "--must=..1"]+ ["rewrite", "--max-depth=1", "--max-cycles=2", "--normalize", "--must=..1"] ["it's expected rewriting cycles to be in range [..1], but rewriting has already reached 2"] it "when cycles below range 2.." $
test/DataizeSpec.hs view
@@ -12,7 +12,7 @@ import Test.Hspec defaultDataizeContext :: Program -> DataizeContext-defaultDataizeContext prog = DataizeContext prog 25 1 False buildTerm dontSaveStep+defaultDataizeContext prog = DataizeContext prog 25 25 False buildTerm dontSaveStep test :: (Eq a, Show a) => (Expression -> DataizeContext -> IO (Maybe a)) -> [(String, Expression, Expression, Maybe a)] -> Spec test func useCases =
test/FunctionsSpec.hs view
@@ -22,7 +22,7 @@ second = ("B2", MvBindings [BiTau AtRho ExThis, BiLambda "Func", BiDelta (BtOne "00"), BiVoid (AtAlpha 1)]) third = ("B3", MvBindings [BiLambda "Some", BiTau (AtLabel "y") ExThis, BiTau (AtLabel "x") ExThis, BiVoid (AtAlpha 0)]) subst = Subst (Map.fromList [first, second, third])- TeBindings bds <- buildTerm "join" [ArgBinding (BiMeta "B1"), ArgBinding (BiMeta "B2"), ArgBinding (BiMeta "B3")] subst (Program ExGlobal)+ TeBindings bds <- buildTerm "join" [ArgBinding (BiMeta "B1"), ArgBinding (BiMeta "B2"), ArgBinding (BiMeta "B3")] subst bds' <- uniqueBindings' bds logDebug (printf "Joined bindings:\n%s" (printExpression (ExFormation bds'))) length bds' `shouldBe` 9
test/RewriterSpec.hs view
@@ -104,7 +104,6 @@ prog rules' ( RewriteContext- prog repeat' repeat' False
test/RuleSpec.hs view
@@ -39,7 +39,7 @@ let prog = Program (expression pack) let matched = matchProgram (pattern pack) prog unless (matched /= []) (expectationFailure "List of matched substitutions is empty which is not expected")- met <- meetCondition (condition pack) matched (RuleContext prog buildTerm)+ met <- meetCondition (condition pack) matched (RuleContext buildTerm) case failure pack of Just True -> unless