Skip to content

Commit

Permalink
Reimplement mapVar (was really a setter) as mapTermVar. #148
Browse files Browse the repository at this point in the history
  • Loading branch information
epost authored and marcosh committed Jan 21, 2020
1 parent e58ca07 commit d681402
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Language/CQL/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions src/Language/CQL/Term.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d681402

Please sign in to comment.