From 0f77a33e646571dd3af0854d15d14b0ed85803be Mon Sep 17 00:00:00 2001 From: Erik Post Date: Thu, 22 Aug 2019 14:58:44 +0200 Subject: [PATCH] Rename presToCol to IP.toCollage. #148 --- src/Language/CQL/Instance.hs | 8 ++++---- src/Language/CQL/Instance/Presentation.hs | 11 +++++------ src/Language/CQL/Transform.hs | 8 ++++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Language/CQL/Instance.hs b/src/Language/CQL/Instance.hs index 053272d..f9f091d 100644 --- a/src/Language/CQL/Instance.hs +++ b/src/Language/CQL/Instance.hs @@ -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 @@ -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 @@ -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 diff --git a/src/Language/CQL/Instance/Presentation.hs b/src/Language/CQL/Instance/Presentation.hs index 28555fd..e309994 100644 --- a/src/Language/CQL/Instance/Presentation.hs +++ b/src/Language/CQL/Instance/Presentation.hs @@ -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 diff --git a/src/Language/CQL/Transform.hs b/src/Language/CQL/Transform.hs index 38cf7f7..cd54185 100644 --- a/src/Language/CQL/Transform.hs +++ b/src/Language/CQL/Transform.hs @@ -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') @@ -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 @@ -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')