From ce06b94a79e201a9546f6884a3e5ef379b70d86d Mon Sep 17 00:00:00 2001 From: Erik Post Date: Fri, 23 Aug 2019 19:39:21 +0200 Subject: [PATCH] Reimplement mapVar (was really a setter) as mapTermVar. #148 --- src/Language/CQL/Schema.hs | 6 +++--- src/Language/CQL/Term.hs | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Language/CQL/Schema.hs b/src/Language/CQL/Schema.hs index 57cbec7..8bf5781 100644 --- a/src/Language/CQL/Schema.hs +++ b/src/Language/CQL/Schema.hs @@ -90,9 +90,9 @@ instance TyMap Show '[var, ty, sym, en, fk, att] , section "observation_equations " $ unlines $ eqs'' obs_eqs' ] where - fks'' = (\(k,(s,t)) -> show k ++ " : " ++ show s ++ " -> " ++ show t) <$> Map.toList fks' - atts'' = (\(k,(s,t)) -> show k ++ " : " ++ show s ++ " -> " ++ show t) <$> Map.toList atts' - eqs'' x = (\(en,EQ (l,r)) -> "forall x : " ++ show en ++ " . " ++ show (mapVar "x" l) ++ " = " ++ show (mapVar "x" r)) <$> Set.toList x + fks'' = (\(k,(s,t)) -> show k ++ " : " ++ show s ++ " -> " ++ show t) <$> Map.toList fks' + atts'' = (\(k,(s,t)) -> show k ++ " : " ++ show s ++ " -> " ++ show t) <$> Map.toList atts' + eqs'' x = (\(en,EQ (l,r)) -> "forall x : " ++ show en ++ " . " ++ show (mapTermVar (const "x") l) ++ " = " ++ show (mapTermVar (const "x") r)) <$> Set.toList x -- | Checks that the underlying theory is well-sorted. -- I.e. rule out "1" = one kind of errors. diff --git a/src/Language/CQL/Term.hs b/src/Language/CQL/Term.hs index 67db57e..07115d8 100644 --- a/src/Language/CQL/Term.hs +++ b/src/Language/CQL/Term.hs @@ -134,8 +134,11 @@ mapTerm v t r e f a g s x = case x of where mt = mapTerm v t r e f a g s -mapVar :: var -> Term () ty sym en fk att gen sk -> Term var ty sym en fk att gen sk -mapVar v = mapTerm (const v) id id id id id id id +mapTermVar + :: (var -> var') + -> Term var ty sym en fk att gen sk + -> Term var' ty sym en fk att gen sk +mapTermVar f = mapTerm f id id id id id id id -- | The number of variable and symbol occurrences in a term. size :: Term var ty sym en fk att gen sk -> Integer