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 committed Aug 23, 2019
1 parent 4dca7a5 commit ce06b94
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 ce06b94

Please sign in to comment.