Skip to content

Commit

Permalink
Rename presToCol to IP.toCollage. #148
Browse files Browse the repository at this point in the history
  • Loading branch information
epost committed Aug 22, 2019
1 parent 3738b83 commit 0f77a33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Language/CQL/Instance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import Data.Void
import Language.CQL.Collage (Collage(..), assembleGens, attsFrom, fksFrom, typeOf)
import Language.CQL.Common (elem', fromListAccum, section, toMapSafely, Deps(..), Err, Kind(INSTANCE), MultiTyMap, TyMap, type (+))
import Language.CQL.Instance.Algebra (Algebra(..), aAtt, down1, evalSchTerm, evalSchTerm', nf, nf'', repr'')
import Language.CQL.Instance.Presentation (Presentation(..), presToCol)
import qualified Language.CQL.Instance.Presentation as IP (typecheck, Presentation(eqs))
import Language.CQL.Instance.Presentation (Presentation(..))
import qualified Language.CQL.Instance.Presentation as IP (toCollage, typecheck, Presentation(eqs))
import Language.CQL.Mapping as Mapping
import Language.CQL.Options
import Language.CQL.Prover
Expand Down Expand Up @@ -221,7 +221,7 @@ initialInstance p dp' sch = Instance sch p dp'' $ initialAlgebra
dp'' (EQ (lhs, rhs)) = dp' $ EQ (upp lhs, upp rhs)
initialAlgebra = simplifyAlg this
this = Algebra sch en' nf''' nf'''2 id ty' nf'''' repr'''' teqs'
col = presToCol sch p
col = IP.toCollage sch p
ens' = assembleGens col (close col dp')
en' k = ens' ! k

Expand Down Expand Up @@ -601,7 +601,7 @@ evalSigmaInst
-> Instance var ty sym en fk att gen sk x y -> Options
-> Err (Instance var ty sym en' fk' att' gen sk (Carrier en' fk' gen) (TalgGen en' fk' att' gen sk))
evalSigmaInst f i o = do
d <- createProver (presToCol s p) o
d <- createProver (IP.toCollage s p) o
return $ initialInstance p (\(EQ (l, r)) -> prove d Map.empty (EQ (l, r))) s
where
p = subs f $ pres i
Expand Down
11 changes: 5 additions & 6 deletions src/Language/CQL/Instance/Presentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,17 @@ typecheck
=> Schema var ty sym en fk att
-> Presentation var ty sym en fk att gen sk
-> Err ()
typecheck sch p = typeOfCol $ presToCol sch p
typecheck sch p = typeOfCol $ toCollage sch p

-- | Converts a presentation to a collage.
presToCol
toCollage
:: (MultiTyMap '[Show, Ord, NFData] '[var, ty, sym, en, fk, att, gen, sk])
=> Schema var ty sym en fk att
-> Presentation var ty sym en fk att gen sk
-> Collage (()+var) ty sym en fk att gen sk
presToCol sch (Presentation gens' sks' eqs') =
Collage (Set.union e1 e2) (ctys schcol)
(cens schcol) (csyms schcol) (cfks schcol) (catts schcol) gens' sks'
toCollage sch (Presentation gens' sks' eqs') =
Collage (Set.union e1 e2) (ctys schcol) (cens schcol) (csyms schcol) (cfks schcol) (catts schcol) gens' sks'
where
schcol = schToCol sch
e1 = Set.map (\( EQ (l,r)) -> (Map.empty, EQ (upp l, upp r))) eqs'
e1 = Set.map (\( EQ (l,r)) -> (Map.empty, EQ (upp l, upp r))) $ eqs'
e2 = Set.map (\(g, EQ (l,r)) -> (g, EQ (upp l, upp r))) $ ceqs schcol
8 changes: 4 additions & 4 deletions src/Language/CQL/Transform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import Data.Typeable
import Data.Void
import Language.CQL.Common
import Language.CQL.Instance as I
import Language.CQL.Instance.Presentation as IP
import qualified Language.CQL.Instance.Presentation as IP (Presentation(eqs, gens, sks), toCollage)
import Language.CQL.Instance.Algebra (Algebra(..), nf, nf'')
import Language.CQL.Mapping as M hiding (toMorphism)
import Language.CQL.Morphism (Morphism(..), translate, translate')
Expand Down Expand Up @@ -106,7 +106,7 @@ validateTransform
=> Transform var ty sym en fk att gen sk x y gen' sk' x' y'
-> Err ()
validateTransform m@(Transform src' dst' _ _) =
mapM_ f (Set.toList $ eqs $ pres src')
mapM_ f (Set.toList $ IP.eqs $ pres src')
where
f :: (EQ Void ty sym en fk att gen sk) -> Err () -- need type signature
f (EQ (l, r)) = let
Expand All @@ -121,8 +121,8 @@ toMorphism
=> Transform var ty sym en' fk' att' gen sk x1 y1 gen' sk' x2 y2
-> Morphism var ty sym en' fk' att' gen sk en' fk' att' gen' sk'
toMorphism (Transform src' dst' gens' sks') =
Morphism (presToCol (I.schema src') (pres src'))
(presToCol (I.schema src') (pres dst'))
Morphism (IP.toCollage (I.schema src') (pres src'))
(IP.toCollage (I.schema src') (pres dst'))
ens0 fks0 atts0 gens' sks'
where
ens0 = Map.fromSet id (S.ens $ I.schema src')
Expand Down

0 comments on commit 0f77a33

Please sign in to comment.