{-# LANGUAGE DeriveDataTypeable #-}
{- |
Module      :  ./QVTR/Sign.hs
Description :  QVTR signature and sentences
Copyright   :  (c) Daniel Calegari Universidad de la Republica, Uruguay 2013
License     :  GPLv2 or higher, see LICENSE.txt
Maintainer  :  dcalegar@fing.edu.uy
Stability   :  provisional
Portability :  portable
-}

module QVTR.Sign where

import QVTR.As
import QVTR.Print ()

import qualified CSMOF.Sign as CSMOF
import CSMOF.Print ()

import Common.Doc
import Common.DocUtils
import Common.Id

import Data.Data
import qualified Data.Map as Map


data RuleDef = RuleDef { RuleDef -> String
name :: String
                       , RuleDef -> Bool
top :: Bool
                       , RuleDef -> [TypeClass]
parameters :: [CSMOF.TypeClass]
                       } deriving (Int -> RuleDef -> ShowS
[RuleDef] -> ShowS
RuleDef -> String
(Int -> RuleDef -> ShowS)
-> (RuleDef -> String) -> ([RuleDef] -> ShowS) -> Show RuleDef
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleDef] -> ShowS
$cshowList :: [RuleDef] -> ShowS
show :: RuleDef -> String
$cshow :: RuleDef -> String
showsPrec :: Int -> RuleDef -> ShowS
$cshowsPrec :: Int -> RuleDef -> ShowS
Show, RuleDef -> RuleDef -> Bool
(RuleDef -> RuleDef -> Bool)
-> (RuleDef -> RuleDef -> Bool) -> Eq RuleDef
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleDef -> RuleDef -> Bool
$c/= :: RuleDef -> RuleDef -> Bool
== :: RuleDef -> RuleDef -> Bool
$c== :: RuleDef -> RuleDef -> Bool
Eq, Eq RuleDef
Eq RuleDef =>
(RuleDef -> RuleDef -> Ordering)
-> (RuleDef -> RuleDef -> Bool)
-> (RuleDef -> RuleDef -> Bool)
-> (RuleDef -> RuleDef -> Bool)
-> (RuleDef -> RuleDef -> Bool)
-> (RuleDef -> RuleDef -> RuleDef)
-> (RuleDef -> RuleDef -> RuleDef)
-> Ord RuleDef
RuleDef -> RuleDef -> Bool
RuleDef -> RuleDef -> Ordering
RuleDef -> RuleDef -> RuleDef
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: RuleDef -> RuleDef -> RuleDef
$cmin :: RuleDef -> RuleDef -> RuleDef
max :: RuleDef -> RuleDef -> RuleDef
$cmax :: RuleDef -> RuleDef -> RuleDef
>= :: RuleDef -> RuleDef -> Bool
$c>= :: RuleDef -> RuleDef -> Bool
> :: RuleDef -> RuleDef -> Bool
$c> :: RuleDef -> RuleDef -> Bool
<= :: RuleDef -> RuleDef -> Bool
$c<= :: RuleDef -> RuleDef -> Bool
< :: RuleDef -> RuleDef -> Bool
$c< :: RuleDef -> RuleDef -> Bool
compare :: RuleDef -> RuleDef -> Ordering
$ccompare :: RuleDef -> RuleDef -> Ordering
$cp1Ord :: Eq RuleDef
Ord, Typeable, Typeable RuleDef
Constr
DataType
Typeable RuleDef =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RuleDef -> c RuleDef)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RuleDef)
-> (RuleDef -> Constr)
-> (RuleDef -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RuleDef))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RuleDef))
-> ((forall b. Data b => b -> b) -> RuleDef -> RuleDef)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RuleDef -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RuleDef -> r)
-> (forall u. (forall d. Data d => d -> u) -> RuleDef -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RuleDef -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RuleDef -> m RuleDef)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RuleDef -> m RuleDef)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RuleDef -> m RuleDef)
-> Data RuleDef
RuleDef -> Constr
RuleDef -> DataType
(forall b. Data b => b -> b) -> RuleDef -> RuleDef
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RuleDef -> c RuleDef
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RuleDef
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RuleDef -> u
forall u. (forall d. Data d => d -> u) -> RuleDef -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RuleDef -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RuleDef -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RuleDef -> m RuleDef
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RuleDef -> m RuleDef
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RuleDef
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RuleDef -> c RuleDef
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RuleDef)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RuleDef)
$cRuleDef :: Constr
$tRuleDef :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> RuleDef -> m RuleDef
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RuleDef -> m RuleDef
gmapMp :: (forall d. Data d => d -> m d) -> RuleDef -> m RuleDef
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RuleDef -> m RuleDef
gmapM :: (forall d. Data d => d -> m d) -> RuleDef -> m RuleDef
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RuleDef -> m RuleDef
gmapQi :: Int -> (forall d. Data d => d -> u) -> RuleDef -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RuleDef -> u
gmapQ :: (forall d. Data d => d -> u) -> RuleDef -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RuleDef -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RuleDef -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RuleDef -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RuleDef -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RuleDef -> r
gmapT :: (forall b. Data b => b -> b) -> RuleDef -> RuleDef
$cgmapT :: (forall b. Data b => b -> b) -> RuleDef -> RuleDef
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RuleDef)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RuleDef)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c RuleDef)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RuleDef)
dataTypeOf :: RuleDef -> DataType
$cdataTypeOf :: RuleDef -> DataType
toConstr :: RuleDef -> Constr
$ctoConstr :: RuleDef -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RuleDef
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RuleDef
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RuleDef -> c RuleDef
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RuleDef -> c RuleDef
$cp1Data :: Typeable RuleDef
Data)

instance Pretty RuleDef where
  pretty :: RuleDef -> Doc
pretty (RuleDef nam :: String
nam to :: Bool
to pars :: [TypeClass]
pars) =
    let t :: Doc
t = String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ if Bool
to
            then "top relation"
            else "relation"
    in Doc
t Doc -> Doc -> Doc
<+> String -> Doc
text String
nam Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
lparen
    Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> (TypeClass -> Doc -> Doc) -> Doc -> [TypeClass] -> Doc
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Doc -> Doc -> Doc
(<+>) (Doc -> Doc -> Doc)
-> (TypeClass -> Doc) -> TypeClass -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeClass -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty [TypeClass]
pars
    Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
rparen


data Sign = Sign { Sign -> Sign
sourceSign :: CSMOF.Sign
                 , Sign -> Sign
targetSign :: CSMOF.Sign
                 , Sign -> Map String RuleDef
nonTopRelations :: Map.Map String RuleDef
                 , Sign -> Map String RuleDef
topRelations :: Map.Map String RuleDef
                 , Sign -> [(String, String)]
keyDefs :: [(String, String)]
                 } deriving (Int -> Sign -> ShowS
[Sign] -> ShowS
Sign -> String
(Int -> Sign -> ShowS)
-> (Sign -> String) -> ([Sign] -> ShowS) -> Show Sign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sign] -> ShowS
$cshowList :: [Sign] -> ShowS
show :: Sign -> String
$cshow :: Sign -> String
showsPrec :: Int -> Sign -> ShowS
$cshowsPrec :: Int -> Sign -> ShowS
Show, Sign -> Sign -> Bool
(Sign -> Sign -> Bool) -> (Sign -> Sign -> Bool) -> Eq Sign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sign -> Sign -> Bool
$c/= :: Sign -> Sign -> Bool
== :: Sign -> Sign -> Bool
$c== :: Sign -> Sign -> Bool
Eq, Eq Sign
Eq Sign =>
(Sign -> Sign -> Ordering)
-> (Sign -> Sign -> Bool)
-> (Sign -> Sign -> Bool)
-> (Sign -> Sign -> Bool)
-> (Sign -> Sign -> Bool)
-> (Sign -> Sign -> Sign)
-> (Sign -> Sign -> Sign)
-> Ord Sign
Sign -> Sign -> Bool
Sign -> Sign -> Ordering
Sign -> Sign -> Sign
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Sign -> Sign -> Sign
$cmin :: Sign -> Sign -> Sign
max :: Sign -> Sign -> Sign
$cmax :: Sign -> Sign -> Sign
>= :: Sign -> Sign -> Bool
$c>= :: Sign -> Sign -> Bool
> :: Sign -> Sign -> Bool
$c> :: Sign -> Sign -> Bool
<= :: Sign -> Sign -> Bool
$c<= :: Sign -> Sign -> Bool
< :: Sign -> Sign -> Bool
$c< :: Sign -> Sign -> Bool
compare :: Sign -> Sign -> Ordering
$ccompare :: Sign -> Sign -> Ordering
$cp1Ord :: Eq Sign
Ord, Typeable, Typeable Sign
Constr
DataType
Typeable Sign =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Sign -> c Sign)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Sign)
-> (Sign -> Constr)
-> (Sign -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Sign))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Sign))
-> ((forall b. Data b => b -> b) -> Sign -> Sign)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sign -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sign -> r)
-> (forall u. (forall d. Data d => d -> u) -> Sign -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Sign -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Sign -> m Sign)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Sign -> m Sign)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Sign -> m Sign)
-> Data Sign
Sign -> Constr
Sign -> DataType
(forall b. Data b => b -> b) -> Sign -> Sign
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Sign -> c Sign
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Sign
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Sign -> u
forall u. (forall d. Data d => d -> u) -> Sign -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sign -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sign -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Sign -> m Sign
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Sign -> m Sign
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Sign
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Sign -> c Sign
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Sign)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Sign)
$cSign :: Constr
$tSign :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Sign -> m Sign
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Sign -> m Sign
gmapMp :: (forall d. Data d => d -> m d) -> Sign -> m Sign
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Sign -> m Sign
gmapM :: (forall d. Data d => d -> m d) -> Sign -> m Sign
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Sign -> m Sign
gmapQi :: Int -> (forall d. Data d => d -> u) -> Sign -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Sign -> u
gmapQ :: (forall d. Data d => d -> u) -> Sign -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Sign -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sign -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sign -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sign -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sign -> r
gmapT :: (forall b. Data b => b -> b) -> Sign -> Sign
$cgmapT :: (forall b. Data b => b -> b) -> Sign -> Sign
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Sign)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Sign)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Sign)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Sign)
dataTypeOf :: Sign -> DataType
$cdataTypeOf :: Sign -> DataType
toConstr :: Sign -> Constr
$ctoConstr :: Sign -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Sign
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Sign
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Sign -> c Sign
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Sign -> c Sign
$cp1Data :: Typeable Sign
Data)

instance GetRange Sign where
  getRange :: Sign -> Range
getRange _ = Range
nullRange
  rangeSpan :: Sign -> [Pos]
rangeSpan _ = []

instance Pretty Sign where
  pretty :: Sign -> Doc
pretty (Sign souS :: Sign
souS tarS :: Sign
tarS nonRel :: Map String RuleDef
nonRel topRel :: Map String RuleDef
topRel keyD :: [(String, String)]
keyD) =
    String -> Doc
text "-- Source Metamodel"
    Doc -> Doc -> Doc
$++$
    Sign -> Doc
forall a. Pretty a => a -> Doc
pretty Sign
souS
    Doc -> Doc -> Doc
$++$
    String -> Doc
text "-- Target Metamodel"
    Doc -> Doc -> Doc
$++$
    Sign -> Doc
forall a. Pretty a => a -> Doc
pretty Sign
tarS
    Doc -> Doc -> Doc
$++$
    String -> Doc
text "-- Model Transformation"
    Doc -> Doc -> Doc
$++$
    String -> Doc
text "Definition of Relations"
    Doc -> Doc -> Doc
$+$
    (RuleDef -> Doc -> Doc) -> Doc -> Map String RuleDef -> Doc
forall a b k. (a -> b -> b) -> b -> Map k a -> b
Map.foldr (Doc -> Doc -> Doc
($+$) (Doc -> Doc -> Doc) -> (RuleDef -> Doc) -> RuleDef -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RuleDef -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty Map String RuleDef
topRel
    Doc -> Doc -> Doc
$+$
    (RuleDef -> Doc -> Doc) -> Doc -> Map String RuleDef -> Doc
forall a b k. (a -> b -> b) -> b -> Map k a -> b
Map.foldr (Doc -> Doc -> Doc
($+$) (Doc -> Doc -> Doc) -> (RuleDef -> Doc) -> RuleDef -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RuleDef -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty Map String RuleDef
nonRel
    Doc -> Doc -> Doc
$++$
    String -> Doc
text "Definition of Keys"
    Doc -> Doc -> Doc
$+$
    ((String, String) -> Doc -> Doc)
-> Doc -> [(String, String)] -> Doc
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Doc -> Doc -> Doc
($+$) (Doc -> Doc -> Doc)
-> ((String, String) -> Doc) -> (String, String) -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, String) -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty [(String, String)]
keyD

emptySign :: Sign
emptySign :: Sign
emptySign = Sign :: Sign
-> Sign
-> Map String RuleDef
-> Map String RuleDef
-> [(String, String)]
-> Sign
Sign { sourceSign :: Sign
sourceSign = Sign
CSMOF.emptySign
                 , targetSign :: Sign
targetSign = Sign
CSMOF.emptySign
                 , nonTopRelations :: Map String RuleDef
nonTopRelations = Map String RuleDef
forall k a. Map k a
Map.empty
                 , topRelations :: Map String RuleDef
topRelations = Map String RuleDef
forall k a. Map k a
Map.empty
                 , keyDefs :: [(String, String)]
keyDefs = []
                 }


data Sen = KeyConstr { Sen -> Key
keyConst :: Key }
         | QVTSen { Sen -> RelationSen
rule :: RelationSen }
         deriving (Int -> Sen -> ShowS
[Sen] -> ShowS
Sen -> String
(Int -> Sen -> ShowS)
-> (Sen -> String) -> ([Sen] -> ShowS) -> Show Sen
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sen] -> ShowS
$cshowList :: [Sen] -> ShowS
show :: Sen -> String
$cshow :: Sen -> String
showsPrec :: Int -> Sen -> ShowS
$cshowsPrec :: Int -> Sen -> ShowS
Show, Sen -> Sen -> Bool
(Sen -> Sen -> Bool) -> (Sen -> Sen -> Bool) -> Eq Sen
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sen -> Sen -> Bool
$c/= :: Sen -> Sen -> Bool
== :: Sen -> Sen -> Bool
$c== :: Sen -> Sen -> Bool
Eq, Eq Sen
Eq Sen =>
(Sen -> Sen -> Ordering)
-> (Sen -> Sen -> Bool)
-> (Sen -> Sen -> Bool)
-> (Sen -> Sen -> Bool)
-> (Sen -> Sen -> Bool)
-> (Sen -> Sen -> Sen)
-> (Sen -> Sen -> Sen)
-> Ord Sen
Sen -> Sen -> Bool
Sen -> Sen -> Ordering
Sen -> Sen -> Sen
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Sen -> Sen -> Sen
$cmin :: Sen -> Sen -> Sen
max :: Sen -> Sen -> Sen
$cmax :: Sen -> Sen -> Sen
>= :: Sen -> Sen -> Bool
$c>= :: Sen -> Sen -> Bool
> :: Sen -> Sen -> Bool
$c> :: Sen -> Sen -> Bool
<= :: Sen -> Sen -> Bool
$c<= :: Sen -> Sen -> Bool
< :: Sen -> Sen -> Bool
$c< :: Sen -> Sen -> Bool
compare :: Sen -> Sen -> Ordering
$ccompare :: Sen -> Sen -> Ordering
$cp1Ord :: Eq Sen
Ord, Typeable, Typeable Sen
Constr
DataType
Typeable Sen =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Sen -> c Sen)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Sen)
-> (Sen -> Constr)
-> (Sen -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Sen))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Sen))
-> ((forall b. Data b => b -> b) -> Sen -> Sen)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sen -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sen -> r)
-> (forall u. (forall d. Data d => d -> u) -> Sen -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Sen -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Sen -> m Sen)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Sen -> m Sen)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Sen -> m Sen)
-> Data Sen
Sen -> Constr
Sen -> DataType
(forall b. Data b => b -> b) -> Sen -> Sen
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Sen -> c Sen
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Sen
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Sen -> u
forall u. (forall d. Data d => d -> u) -> Sen -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sen -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sen -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Sen -> m Sen
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Sen -> m Sen
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Sen
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Sen -> c Sen
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Sen)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Sen)
$cQVTSen :: Constr
$cKeyConstr :: Constr
$tSen :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Sen -> m Sen
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Sen -> m Sen
gmapMp :: (forall d. Data d => d -> m d) -> Sen -> m Sen
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Sen -> m Sen
gmapM :: (forall d. Data d => d -> m d) -> Sen -> m Sen
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Sen -> m Sen
gmapQi :: Int -> (forall d. Data d => d -> u) -> Sen -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Sen -> u
gmapQ :: (forall d. Data d => d -> u) -> Sen -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Sen -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sen -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sen -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sen -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sen -> r
gmapT :: (forall b. Data b => b -> b) -> Sen -> Sen
$cgmapT :: (forall b. Data b => b -> b) -> Sen -> Sen
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Sen)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Sen)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Sen)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Sen)
dataTypeOf :: Sen -> DataType
$cdataTypeOf :: Sen -> DataType
toConstr :: Sen -> Constr
$ctoConstr :: Sen -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Sen
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Sen
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Sen -> c Sen
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Sen -> c Sen
$cp1Data :: Typeable Sen
Data)

instance GetRange Sen where
  getRange :: Sen -> Range
getRange _ = Range
nullRange
  rangeSpan :: Sen -> [Pos]
rangeSpan _ = []

instance Pretty Sen where
  pretty :: Sen -> Doc
pretty (KeyConstr con :: Key
con) = Key -> Doc
forall a. Pretty a => a -> Doc
pretty Key
con
  pretty (QVTSen rel :: RelationSen
rel) = RelationSen -> Doc
forall a. Pretty a => a -> Doc
pretty RelationSen
rel


data RelationSen = RelationSen { RelationSen -> RuleDef
ruleDef :: RuleDef
                               , RelationSen -> [RelVar]
varSet :: [RelVar]
                               , RelationSen -> [RelVar]
parSet :: [RelVar]
                               , RelationSen -> Pattern
sourcePattern :: Pattern
                               , RelationSen -> Pattern
targetPattern :: Pattern
                               , RelationSen -> Maybe WhenWhere
whenClause :: Maybe WhenWhere
                               , RelationSen -> Maybe WhenWhere
whereClause :: Maybe WhenWhere
                               } deriving (Int -> RelationSen -> ShowS
[RelationSen] -> ShowS
RelationSen -> String
(Int -> RelationSen -> ShowS)
-> (RelationSen -> String)
-> ([RelationSen] -> ShowS)
-> Show RelationSen
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelationSen] -> ShowS
$cshowList :: [RelationSen] -> ShowS
show :: RelationSen -> String
$cshow :: RelationSen -> String
showsPrec :: Int -> RelationSen -> ShowS
$cshowsPrec :: Int -> RelationSen -> ShowS
Show, RelationSen -> RelationSen -> Bool
(RelationSen -> RelationSen -> Bool)
-> (RelationSen -> RelationSen -> Bool) -> Eq RelationSen
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelationSen -> RelationSen -> Bool
$c/= :: RelationSen -> RelationSen -> Bool
== :: RelationSen -> RelationSen -> Bool
$c== :: RelationSen -> RelationSen -> Bool
Eq, Eq RelationSen
Eq RelationSen =>
(RelationSen -> RelationSen -> Ordering)
-> (RelationSen -> RelationSen -> Bool)
-> (RelationSen -> RelationSen -> Bool)
-> (RelationSen -> RelationSen -> Bool)
-> (RelationSen -> RelationSen -> Bool)
-> (RelationSen -> RelationSen -> RelationSen)
-> (RelationSen -> RelationSen -> RelationSen)
-> Ord RelationSen
RelationSen -> RelationSen -> Bool
RelationSen -> RelationSen -> Ordering
RelationSen -> RelationSen -> RelationSen
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: RelationSen -> RelationSen -> RelationSen
$cmin :: RelationSen -> RelationSen -> RelationSen
max :: RelationSen -> RelationSen -> RelationSen
$cmax :: RelationSen -> RelationSen -> RelationSen
>= :: RelationSen -> RelationSen -> Bool
$c>= :: RelationSen -> RelationSen -> Bool
> :: RelationSen -> RelationSen -> Bool
$c> :: RelationSen -> RelationSen -> Bool
<= :: RelationSen -> RelationSen -> Bool
$c<= :: RelationSen -> RelationSen -> Bool
< :: RelationSen -> RelationSen -> Bool
$c< :: RelationSen -> RelationSen -> Bool
compare :: RelationSen -> RelationSen -> Ordering
$ccompare :: RelationSen -> RelationSen -> Ordering
$cp1Ord :: Eq RelationSen
Ord, Typeable, Typeable RelationSen
Constr
DataType
Typeable RelationSen =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RelationSen -> c RelationSen)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RelationSen)
-> (RelationSen -> Constr)
-> (RelationSen -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RelationSen))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c RelationSen))
-> ((forall b. Data b => b -> b) -> RelationSen -> RelationSen)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RelationSen -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RelationSen -> r)
-> (forall u. (forall d. Data d => d -> u) -> RelationSen -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RelationSen -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RelationSen -> m RelationSen)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RelationSen -> m RelationSen)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RelationSen -> m RelationSen)
-> Data RelationSen
RelationSen -> Constr
RelationSen -> DataType
(forall b. Data b => b -> b) -> RelationSen -> RelationSen
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelationSen -> c RelationSen
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelationSen
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RelationSen -> u
forall u. (forall d. Data d => d -> u) -> RelationSen -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RelationSen -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RelationSen -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RelationSen -> m RelationSen
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RelationSen -> m RelationSen
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelationSen
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelationSen -> c RelationSen
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RelationSen)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RelationSen)
$cRelationSen :: Constr
$tRelationSen :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> RelationSen -> m RelationSen
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RelationSen -> m RelationSen
gmapMp :: (forall d. Data d => d -> m d) -> RelationSen -> m RelationSen
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RelationSen -> m RelationSen
gmapM :: (forall d. Data d => d -> m d) -> RelationSen -> m RelationSen
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RelationSen -> m RelationSen
gmapQi :: Int -> (forall d. Data d => d -> u) -> RelationSen -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RelationSen -> u
gmapQ :: (forall d. Data d => d -> u) -> RelationSen -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RelationSen -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RelationSen -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RelationSen -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RelationSen -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RelationSen -> r
gmapT :: (forall b. Data b => b -> b) -> RelationSen -> RelationSen
$cgmapT :: (forall b. Data b => b -> b) -> RelationSen -> RelationSen
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RelationSen)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RelationSen)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c RelationSen)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RelationSen)
dataTypeOf :: RelationSen -> DataType
$cdataTypeOf :: RelationSen -> DataType
toConstr :: RelationSen -> Constr
$ctoConstr :: RelationSen -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelationSen
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelationSen
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelationSen -> c RelationSen
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelationSen -> c RelationSen
$cp1Data :: Typeable RelationSen
Data)

instance GetRange RelationSen where
  getRange :: RelationSen -> Range
getRange _ = Range
nullRange
  rangeSpan :: RelationSen -> [Pos]
rangeSpan _ = []

instance Pretty RelationSen where
  pretty :: RelationSen -> Doc
pretty (RelationSen rD :: RuleDef
rD vS :: [RelVar]
vS pS :: [RelVar]
pS souP :: Pattern
souP tarP :: Pattern
tarP whenC :: Maybe WhenWhere
whenC whereC :: Maybe WhenWhere
whereC) =
    RuleDef -> Doc
forall a. Pretty a => a -> Doc
pretty RuleDef
rD
    Doc -> Doc -> Doc
$++$
    String -> Doc
text "Variables" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon Doc -> Doc -> Doc
<+> (RelVar -> Doc -> Doc) -> Doc -> [RelVar] -> Doc
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Doc -> Doc -> Doc
(<+>) (Doc -> Doc -> Doc) -> (RelVar -> Doc) -> RelVar -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelVar -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty [RelVar]
vS
    Doc -> Doc -> Doc
$++$
    String -> Doc
text "Parameters" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon Doc -> Doc -> Doc
<+> (RelVar -> Doc -> Doc) -> Doc -> [RelVar] -> Doc
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Doc -> Doc -> Doc
(<+>) (Doc -> Doc -> Doc) -> (RelVar -> Doc) -> RelVar -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelVar -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty [RelVar]
pS
    Doc -> Doc -> Doc
$++$
    Pattern -> Doc
forall a. Pretty a => a -> Doc
pretty Pattern
souP
    Doc -> Doc -> Doc
$++$
    Pattern -> Doc
forall a. Pretty a => a -> Doc
pretty Pattern
tarP
    Doc -> Doc -> Doc
$++$
    (case Maybe WhenWhere
whenC of
      Nothing -> String -> Doc
text "When" Doc -> Doc -> Doc
<+> Doc
lbrace Doc -> Doc -> Doc
$+$ Doc
rbrace
      Just w :: WhenWhere
w -> String -> Doc
text "When" Doc -> Doc -> Doc
<+> Doc
lbrace Doc -> Doc -> Doc
$+$ WhenWhere -> Doc
forall a. Pretty a => a -> Doc
pretty WhenWhere
w Doc -> Doc -> Doc
$+$ Doc
rbrace)
    Doc -> Doc -> Doc
$++$
    (case Maybe WhenWhere
whereC of
      Nothing -> String -> Doc
text "Where" Doc -> Doc -> Doc
<+> Doc
lbrace Doc -> Doc -> Doc
$+$ Doc
rbrace
      Just w :: WhenWhere
w -> String -> Doc
text "Where" Doc -> Doc -> Doc
<+> Doc
lbrace Doc -> Doc -> Doc
$+$ WhenWhere -> Doc
forall a. Pretty a => a -> Doc
pretty WhenWhere
w Doc -> Doc -> Doc
$+$ Doc
rbrace)


data Pattern = Pattern { Pattern -> [RelVar]
patVarSet :: [RelVar]
                       , Pattern -> [(PropertyT, RelVar, RelVar)]
patRels :: [(CSMOF.PropertyT, RelVar, RelVar)]
                       , Pattern -> [(String, String, OCL)]
patPreds :: [(String, String, OCL)]
                       } deriving (Int -> Pattern -> ShowS
[Pattern] -> ShowS
Pattern -> String
(Int -> Pattern -> ShowS)
-> (Pattern -> String) -> ([Pattern] -> ShowS) -> Show Pattern
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Pattern] -> ShowS
$cshowList :: [Pattern] -> ShowS
show :: Pattern -> String
$cshow :: Pattern -> String
showsPrec :: Int -> Pattern -> ShowS
$cshowsPrec :: Int -> Pattern -> ShowS
Show, Pattern -> Pattern -> Bool
(Pattern -> Pattern -> Bool)
-> (Pattern -> Pattern -> Bool) -> Eq Pattern
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pattern -> Pattern -> Bool
$c/= :: Pattern -> Pattern -> Bool
== :: Pattern -> Pattern -> Bool
$c== :: Pattern -> Pattern -> Bool
Eq, Eq Pattern
Eq Pattern =>
(Pattern -> Pattern -> Ordering)
-> (Pattern -> Pattern -> Bool)
-> (Pattern -> Pattern -> Bool)
-> (Pattern -> Pattern -> Bool)
-> (Pattern -> Pattern -> Bool)
-> (Pattern -> Pattern -> Pattern)
-> (Pattern -> Pattern -> Pattern)
-> Ord Pattern
Pattern -> Pattern -> Bool
Pattern -> Pattern -> Ordering
Pattern -> Pattern -> Pattern
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Pattern -> Pattern -> Pattern
$cmin :: Pattern -> Pattern -> Pattern
max :: Pattern -> Pattern -> Pattern
$cmax :: Pattern -> Pattern -> Pattern
>= :: Pattern -> Pattern -> Bool
$c>= :: Pattern -> Pattern -> Bool
> :: Pattern -> Pattern -> Bool
$c> :: Pattern -> Pattern -> Bool
<= :: Pattern -> Pattern -> Bool
$c<= :: Pattern -> Pattern -> Bool
< :: Pattern -> Pattern -> Bool
$c< :: Pattern -> Pattern -> Bool
compare :: Pattern -> Pattern -> Ordering
$ccompare :: Pattern -> Pattern -> Ordering
$cp1Ord :: Eq Pattern
Ord, Typeable, Typeable Pattern
Constr
DataType
Typeable Pattern =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Pattern -> c Pattern)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Pattern)
-> (Pattern -> Constr)
-> (Pattern -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Pattern))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pattern))
-> ((forall b. Data b => b -> b) -> Pattern -> Pattern)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Pattern -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Pattern -> r)
-> (forall u. (forall d. Data d => d -> u) -> Pattern -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Pattern -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pattern -> m Pattern)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pattern -> m Pattern)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pattern -> m Pattern)
-> Data Pattern
Pattern -> Constr
Pattern -> DataType
(forall b. Data b => b -> b) -> Pattern -> Pattern
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pattern -> c Pattern
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Pattern
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Pattern -> u
forall u. (forall d. Data d => d -> u) -> Pattern -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pattern -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pattern -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Pattern -> m Pattern
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Pattern -> m Pattern
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Pattern
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pattern -> c Pattern
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Pattern)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pattern)
$cPattern :: Constr
$tPattern :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Pattern -> m Pattern
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Pattern -> m Pattern
gmapMp :: (forall d. Data d => d -> m d) -> Pattern -> m Pattern
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Pattern -> m Pattern
gmapM :: (forall d. Data d => d -> m d) -> Pattern -> m Pattern
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Pattern -> m Pattern
gmapQi :: Int -> (forall d. Data d => d -> u) -> Pattern -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Pattern -> u
gmapQ :: (forall d. Data d => d -> u) -> Pattern -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Pattern -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pattern -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pattern -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pattern -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pattern -> r
gmapT :: (forall b. Data b => b -> b) -> Pattern -> Pattern
$cgmapT :: (forall b. Data b => b -> b) -> Pattern -> Pattern
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pattern)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pattern)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Pattern)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Pattern)
dataTypeOf :: Pattern -> DataType
$cdataTypeOf :: Pattern -> DataType
toConstr :: Pattern -> Constr
$ctoConstr :: Pattern -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Pattern
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Pattern
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pattern -> c Pattern
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pattern -> c Pattern
$cp1Data :: Typeable Pattern
Data)

instance GetRange Pattern where
  getRange :: Pattern -> Range
getRange _ = Range
nullRange
  rangeSpan :: Pattern -> [Pos]
rangeSpan _ = []

instance Pretty Pattern where
  pretty :: Pattern -> Doc
pretty (Pattern patVS :: [RelVar]
patVS patRel :: [(PropertyT, RelVar, RelVar)]
patRel patPre :: [(String, String, OCL)]
patPre) =
    String -> Doc
text "Pattern" Doc -> Doc -> Doc
<+> Doc
lbrace
    Doc -> Doc -> Doc
$+$
    Doc
space Doc -> Doc -> Doc
<+> Doc
space Doc -> Doc -> Doc
<+> String -> Doc
text "Variables" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon Doc -> Doc -> Doc
<+> (RelVar -> Doc -> Doc) -> Doc -> [RelVar] -> Doc
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Doc -> Doc -> Doc
(<+>) (Doc -> Doc -> Doc) -> (RelVar -> Doc) -> RelVar -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelVar -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty [RelVar]
patVS
    Doc -> Doc -> Doc
$+$
    Doc
space Doc -> Doc -> Doc
<+> Doc
space Doc -> Doc -> Doc
<+> String -> Doc
text "Relations" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon Doc -> Doc -> Doc
<+> ((PropertyT, RelVar, RelVar) -> Doc -> Doc)
-> Doc -> [(PropertyT, RelVar, RelVar)] -> Doc
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Doc -> Doc -> Doc
($+$) (Doc -> Doc -> Doc)
-> ((PropertyT, RelVar, RelVar) -> Doc)
-> (PropertyT, RelVar, RelVar)
-> Doc
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PropertyT, RelVar, RelVar) -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty [(PropertyT, RelVar, RelVar)]
patRel
    Doc -> Doc -> Doc
$+$
    Doc
space Doc -> Doc -> Doc
<+> Doc
space Doc -> Doc -> Doc
<+> String -> Doc
text "Predicates" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon Doc -> Doc -> Doc
<+> ((String, String, OCL) -> Doc -> Doc)
-> Doc -> [(String, String, OCL)] -> Doc
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Doc -> Doc -> Doc
($+$) (Doc -> Doc -> Doc)
-> ((String, String, OCL) -> Doc)
-> (String, String, OCL)
-> Doc
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, String, OCL) -> Doc
forall a. Pretty a => a -> Doc
pretty) Doc
empty [(String, String, OCL)]
patPre
    Doc -> Doc -> Doc
$+$
    Doc
rbrace