(Just c) -> ": " ++ show c
t1 == t2 = theoryId t1 == theoryId t2
instance Ord Theory where
t1 `compare` t2 = theoryId t1 `compare` theoryId t2
showTheory :: Theory -> String
showTheory t = show (t { theoryPresentations = [] })
-- | Type (scope) of import
data ImportsType = ITLocal | ITGlobal
deriving (Show, Typeable, Data)
-- | Imports (for Theory)
, importsMorphism :: Maybe Morphism
, importsId :: Maybe XmlId
, importsType :: ImportsType
, importsConservativity :: Conservativity
deriving (Show, Typeable, Data)
presentationForId :: XmlId
, presentationSystem :: Maybe XmlString
, presentationUses :: [Use]
deriving (Show, Eq, Typeable, Data)
mkPresentationS :: XmlId -> XmlString -> [Use] -> Presentation
mkPresentationS forid presSystem = Presentation forid (Just presSystem)
mkPresentation :: XmlId -> [Use] -> Presentation
mkPresentation forid = Presentation forid Nothing
addUse :: Presentation -> Use -> Presentation
addUse pres use = pres { presentationUses = presentationUses pres ++ [use] }
-- | Use for Presentation
deriving (Show, Eq, Typeable, Data)
mkUse :: XmlString -> String -> Use
-- | SymbolRole for Symbol
deriving (Eq, Ord, Typeable, Data)
instance Show SymbolRole where
show SRAttribution = "attribution"
show SRSemanticAttribution = "semantic-attribution"
instance Read SymbolRole where
"object" -> [(SRObject, [])]
"binder" -> [(SRBinder, [])]
"attribution" -> [(SRAttribution, [])]
"semantic-attribution" -> [(SRSemanticAttribution, [])]
"error" -> [(SRError, [])]
symbolGeneratedFrom :: Maybe XmlId
, symbolRole :: SymbolRole
, symbolType :: Maybe Type
deriving (Show, Eq, Ord, Typeable, Data)
instance Pretty Symbol where
mkSymbolE :: Maybe XmlId -> XmlId -> SymbolRole -> Maybe Type -> Symbol
mkSymbol :: XmlId -> SymbolRole -> Symbol
mkSymbol xid sr = mkSymbolE Nothing xid sr Nothing
, typeOMDocMathObject :: OMDocMathObject
deriving (Show, Eq, Ord, Typeable, Data)
mkType :: Maybe OMDocRef -> OMDocMathObject -> Type
OMDoc Theory constitutive elements + convenience additions (ADT)
| CCo { conComCmt :: String, conComCon :: Constitutive }
deriving (Show, Typeable, Data)
mkCAx :: Axiom -> Constitutive
mkCDe :: Definition -> Constitutive
mkCSy :: Symbol -> Constitutive
mkCIm :: Imports -> Constitutive
mkCAd :: ADT -> Constitutive
mkCCo :: String -> Constitutive -> Constitutive
isAxiom :: Constitutive -> Bool
isDefinition :: Constitutive -> Bool
isDefinition (CDe {}) = True
isSymbol :: Constitutive -> Bool
isImports :: Constitutive -> Bool
isImports (CIm {}) = True
isADT :: Constitutive -> Bool
isCommented :: Constitutive -> Bool
isCommented (CCo {}) = True
getIdsForPresentation :: Constitutive -> [XmlId]
getIdsForPresentation (CAx a) = [axiomName a]
getIdsForPresentation (CDe _) = []
getIdsForPresentation (CSy s) = [symbolId s]
getIdsForPresentation (CIm _) = []
getIdsForPresentation (CAd a) = map sortDefName (adtSortDefs a)
getIdsForPresentation (CCo {}) = []
deriving (Show, Typeable, Data)
mkAxiom :: XmlId -> [CMP] -> [FMP] -> Axiom
deriving (Show, Typeable, Data)
fmpLogic :: Maybe XmlString
, fmpContent :: Either OMObject ([Assumption], [Conclusion])
deriving (Show, Typeable, Data)
-- | Assumption (incomplete)
data Assumption = Assumption
deriving (Show, Typeable, Data)
data Conclusion = Conclusion
deriving (Show, Typeable, Data)
-- | Definition (incomplete)
, definitionCMPs :: [CMP]
, definitionFMPs :: [FMP]
deriving (Show, Typeable, Data)
mkDefinition :: XmlId -> [CMP] -> [FMP] -> Definition
mkDefinition = Definition
, adtSortDefs :: [SortDef]
deriving (Show, Typeable, Data)
data SortType = STFree | STGenerated | STLoose deriving (Typeable, Data)
mkADT :: [SortDef] -> ADT
mkADTEx :: Maybe XmlId -> [SortDef] -> ADT
instance Show SortType where
show STGenerated = "generated"
instance Read SortType where
| s == "free" = [(STFree, "")]
| s == "generated" = [(STGenerated, "")]
| s == "loose" = [(STLoose, "")]
, sortDefRole :: SymbolRole
, sortDefType :: SortType
, sortDefConstructors :: [Constructor]
, sortDefInsorts :: [Insort]
, sortDefRecognizers :: [Recognizer]
deriving (Show, Typeable, Data)
mkSortDefE :: XmlId -> SymbolRole -> SortType -> [Constructor] -> [Insort] -> [Recognizer] -> SortDef
mkSortDef :: XmlId -> [Constructor] -> [Insort] -> [Recognizer] -> SortDef
mkSortDef xid = mkSortDefE xid SRSort STFree
, constructorRole :: SymbolRole
, constructorArguments :: [Type]
deriving (Show, Typeable, Data)
mkConstructorE :: XmlId -> SymbolRole -> [Type] -> Constructor
mkConstructorE = Constructor
mkConstructor :: XmlId -> [Type] -> Constructor
mkConstructor xid = Constructor xid SRObject
deriving (Show, Typeable, Data)
mkInsort :: OMDocRef -> Insort
deriving (Show, Typeable, Data)
mkRecognizer :: XmlId -> Recognizer
mkRecognizer = Recognizer
-- | Inclusion-Conservativity
data Conservativity = CNone | CMonomorphism | CDefinitional | CConservative
deriving (Eq, Ord, Typeable, Data)
instance Show Conservativity where
show CMonomorphism = "monomorphism"
show CDefinitional = "definitional"
show CConservative = "conservative"
instance Read Conservativity where
"monomorphism" -> [(CMonomorphism, "")]
"definitional" -> [(CDefinitional, "")]
"conservative" -> [(CConservative, "")]
inclusionFrom :: OMDocRef
, inclusionTo :: OMDocRef
, inclusionMorphism :: Maybe Morphism
, inclusionId :: Maybe XmlId
, inclusionConservativity :: Conservativity
inclusionFrom :: OMDocRef
, inclusionTo :: OMDocRef
, inclusionMorphism :: Maybe Morphism
, inclusionId :: Maybe XmlId
, inclusionConservativity :: Conservativity
deriving (Show, Eq, Ord, Typeable, Data)
instance Pretty Inclusion where
morphismId :: Maybe XmlId
, morphismHiding :: [XmlId]
, morphismBase :: [XmlId]
, morphismRequations :: [ ( MText, MText ) ]
deriving (Show, Eq, Ord, Typeable, Data)
instance Pretty Morphism where
-- Mathematical Text (incomplete)
data MText = MTextText String | MTextTerm String | MTextPhrase String | MTextOM OMObject
deriving (Show, Eq, Ord, Typeable, Data)
-- OMDoc Mathematical Object
data OMDocMathObject = OMOMOBJ OMObject | OMLegacy String | OMMath String
deriving (Show, Eq, Ord, Typeable, Data)
data OMObject = OMObject OMElement
deriving (Show, Eq, Ord, Typeable, Data)
mkOMOBJ :: OMElementClass e => e -> OMObject
mkOMOBJ e = OMObject (toElement e)
omsCDBase :: Maybe OMDocRef
deriving (Show, Eq, Ord, Typeable, Data)
mkOMS :: Maybe OMDocRef -> XmlId -> XmlId -> OMSymbol
mkOMSE :: Maybe OMDocRef -> XmlId -> XmlId -> OMElement
mkOMSE mref xcd xid = toElement $ mkOMS mref xcd xid
deriving (Show, Eq, Ord, Typeable, Data)
mkOMI :: Int -> OMInteger
mkOMIE :: Int -> OMElement
mkOMIE i = toElement $ mkOMI i
-- | A Variable can be a OMV or an OMATTR
data OMVariable = OMVS OMSimpleVariable | OMVA OMAttribution
deriving (Show, Eq, Ord, Typeable, Data)
-- | Class to use something as a Variable
class OMVariableClass a where
toVariable :: a -> OMVariable
fromVariable :: OMVariable -> Maybe a
instance OMVariableClass OMVariable where
instance OMVariableClass OMSimpleVariable where
fromVariable (OMVS x) = Just x
mkOMVar :: Either OMSimpleVariable OMAttribution -> OMVariable
mkOMVar (Left oms) = OMVS oms
mkOMVar (Right omattr) = OMVA omattr
mkOMVarE :: Either OMSimpleVariable OMAttribution -> OMElement
mkOMVarE v = toElement $ mkOMVar v
deriving (Show, Eq, Ord, Typeable, Data)
mkOMSimpleVar :: XmlString -> OMSimpleVariable
mkOMSimpleVarE :: XmlString -> OMElement
mkOMSimpleVarE xid = toElement $ mkOMSimpleVar xid
mkOMVSVar :: XmlString -> OMVariable
mkOMVSVar = OMVS . mkOMSimpleVar
mkOMVSVarE :: XmlString -> OMElement
mkOMVSVarE xid = toElement $ OMVS $ mkOMSimpleVar xid
omattrATP :: OMAttributionPart
, omattrElem :: OMElement
deriving (Show, Eq, Ord, Typeable, Data)
instance OMVariableClass OMAttribution where
fromVariable (OMVA x) = Just x
mkOMATTR :: OMElementClass e => OMAttributionPart -> e -> OMAttribution
mkOMATTR omatp ome = OMATTR { omattrATP = omatp , omattrElem = toElement ome }
mkOMATTRE :: OMElementClass e => OMAttributionPart -> e -> OMElement
mkOMATTRE omatp ome = toElement $ mkOMATTR omatp ome
omatpAttribs :: [(OMSymbol, OMElement)]
deriving (Show, Eq, Ord, Typeable, Data)
mkOMATP :: OMElementClass e => [(OMSymbol, e)] -> OMAttributionPart
mkOMATP = OMATP . map (\ (s, e) -> (s, toElement e))
data OMBindingVariables =
ombvarVars :: [OMVariable]
deriving (Show, Eq, Ord, Typeable, Data)
mkOMBVAR :: OMVariableClass e => [e] -> OMBindingVariables
mkOMBVAR = OMBVAR . map toVariable
OMB is actually just a bytearray for storing data.
deriving (Show, Eq, Ord, Typeable, Data)
mkOMBE = toElement . mkOMB
mkOMBWordsE = toElement . mkOMBWords
deriving (Show, Eq, Ord, Typeable, Data)
mkOMSTR :: String -> OMString
mkOMSTRE :: String -> OMElement
mkOMSTRE = toElement . mkOMSTR
deriving (Show, Eq, Ord, Typeable, Data)
mkOMF :: Float -> OMFloat
mkOMFE :: Float -> OMElement
mkOMFE = toElement . mkOMF
omaElements :: [OMElement]
deriving (Show, Eq, Ord, Typeable, Data)
mkOMA :: OMElementClass e => [e] -> OMApply
mkOMA [] = error "Empty list of elements for OMA!"
mkOMA l = OMA (map toElement l)
mkOMAE :: OMElementClass e => [e] -> OMElement
mkOMAE = toElement . mkOMA
, omeExtra :: [OMElement]
deriving (Show, Eq, Ord, Typeable, Data)
mkOME :: OMElementClass e => OMSymbol -> [e] -> OMError
mkOME _ [] = error "Empty list of elements for OME!"
mkOME s e = OME s (map toElement e)
mkOMEE :: OMElementClass e => OMSymbol -> [e] -> OMElement
mkOMEE s e = toElement $ mkOME s e
deriving (Show, Eq, Ord, Typeable, Data)
mkOMRE = toElement . mkOMR
ombindBinder :: OMElement
, ombindVariables :: OMBindingVariables
, ombindExpression :: OMElement
deriving (Show, Eq, Ord, Typeable, Data)
mkOMBIND :: (OMElementClass e1, OMElementClass e2)
=> e1 -> OMBindingVariables -> e2 -> OMBind
mkOMBIND binder bvars expr =
ombindBinder = toElement binder
, ombindVariables = bvars
, ombindExpression = toElement expr
mkOMBINDE :: (OMElementClass e1, OMElementClass e2)
=> e1 -> OMBindingVariables -> e2 -> OMElement
mkOMBINDE binder vars expr = toElement $ mkOMBIND binder vars expr
-- | Elements for Open Math
| OMEC (Maybe OMElement) String
deriving (Show, Eq, Ord, Typeable, Data)
-- | insert a comment into an open-math structure (use with caution...)
mkOMComment :: String -> OMElement
mkOMComment = OMEC Nothing
mkOMCommented :: OMElementClass e => String -> e -> OMElement
mkOMCommented cmt e = OMEC (Just (toElement e)) cmt
-- | Class of Elements for Open Math
class OMElementClass a where
toElement :: a -> OMElement
fromElement :: OMElement -> Maybe a
instance OMElementClass OMSymbol where
fromElement (OMES oms) = Just oms
instance OMElementClass OMInteger where
fromElement (OMEI x) = Just x
instance OMElementClass OMVariable where
toElement (OMVS omv) = OMEV omv
toElement (OMVA omattr) = OMEATTR omattr
fromElement (OMEV omv) = Just (OMVS omv)
fromElement (OMEATTR omattr) = Just (OMVA omattr)
instance OMElementClass OMSimpleVariable where
fromElement (OMEV omv) = Just omv
instance OMElementClass OMAttribution where
fromElement (OMEATTR x) = Just x
instance OMElementClass OMBase64 where
fromElement (OMEB x) = Just x
instance OMElementClass OMString where
fromElement (OMESTR x) = Just x
instance OMElementClass OMFloat where
fromElement (OMEF x) = Just x
instance OMElementClass OMApply where
fromElement (OMEA x) = Just x
instance OMElementClass OMError where
fromElement (OMEE x) = Just x
instance OMElementClass OMReference where
fromElement (OMER x) = Just x
instance OMElementClass OMBind where
fromElement (OMEBIND x) = Just x
instance OMElementClass OMElement where