phino 0.0.0.32 → 0.0.0.33
raw patch · 3 files changed
+25/−13 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Rule: compareAttrs :: Attribute -> Attribute -> Subst -> Bool
+ Yaml: CmpExpr :: Expression -> Comparable
Files
- phino.cabal +1/−1
- src/Rule.hs +21/−11
- src/Yaml.hs +3/−1
phino.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 name: phino-version: 0.0.0.32+version: 0.0.0.33 license: MIT synopsis: Command-Line Manipulator of 𝜑-Calculus Expressions description: Please see the README on GitHub at <https://github.com/objectionary/phino#readme>
src/Rule.hs view
@@ -43,17 +43,6 @@ attrInBinding _ _ = False attrInBindings _ _ = False --- Apply 'eq' yaml condition to attributes-compareAttrs :: Attribute -> Attribute -> Subst -> Bool-compareAttrs (AtMeta left) (AtMeta right) _ = left == right-compareAttrs attr (AtMeta meta) (Subst mp) = case M.lookup meta mp of- Just (MvAttribute found) -> attr == found- _ -> False-compareAttrs (AtMeta meta) attr (Subst mp) = case M.lookup meta mp of- Just (MvAttribute found) -> attr == found- _ -> False-compareAttrs left right subst = right == left- -- Convert Number to Integer numToInt :: Y.Number -> Subst -> Maybe Integer numToInt (Y.Ordinal (AtMeta meta)) (Subst mp) = case M.lookup meta mp of@@ -131,6 +120,27 @@ (Just left_, Just right_) -> pure [subst | left_ == right_] (_, _) -> pure [] meetCondition' (Y.Eq (Y.CmpAttr left) (Y.CmpAttr right)) subst _ = pure [subst | compareAttrs left right subst]+ where+ compareAttrs :: Attribute -> Attribute -> Subst -> Bool+ compareAttrs (AtMeta left) (AtMeta right) _ = left == right+ compareAttrs attr (AtMeta meta) (Subst mp) = case M.lookup meta mp of+ Just (MvAttribute found) -> attr == found+ _ -> False+ compareAttrs (AtMeta meta) attr (Subst mp) = case M.lookup meta mp of+ Just (MvAttribute found) -> attr == found+ _ -> False+ compareAttrs left right _ = right == left+meetCondition' (Y.Eq (Y.CmpExpr left) (Y.CmpExpr right)) subst _ = pure [subst | compareExprs left right subst]+ where+ compareExprs :: Expression -> Expression -> Subst -> Bool+ compareExprs (ExMeta left) (ExMeta right) _ = left == right+ compareExprs expr (ExMeta meta) (Subst mp) = case M.lookup meta mp of+ Just (MvExpression found _) -> expr == found+ _ -> False+ compareExprs (ExMeta meta) expr (Subst mp) = case M.lookup meta mp of+ Just (MvExpression found _) -> expr == found+ _ -> False+ compareExprs left right _ = left == right meetCondition' (Y.Eq _ _) _ _ = pure [] meetCondition' (Y.NF (ExMeta meta)) (Subst mp) ctx = case M.lookup meta mp of Just (MvExpression expr _) -> pure [Subst mp | isNF expr ctx]
src/Yaml.hs view
@@ -65,7 +65,8 @@ parseJSON v = asum [ CmpAttr <$> parseJSON v,- CmpNum <$> parseJSON v+ CmpNum <$> parseJSON v,+ CmpExpr <$> parseJSON v ] instance FromJSON Condition where@@ -136,6 +137,7 @@ data Comparable = CmpAttr Attribute | CmpNum Number+ | CmpExpr Expression deriving (Generic, Show) data Condition