AS.hs revision a03c109eabfe250e4b57bdf44f37f53751a65df4
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek{- |
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekModule : $Header$
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekCopyright : (c) C. Maeder, Felix Gabriel Mance
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekLicense : GPLv2 or higher, see LICENSE.txt
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekMaintainer : Christian.Maeder@dfki.de
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekStability : provisional
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekPortability : portable
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekOWL 2 Functional Syntax constructs
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekReferences:
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek <http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/#Functional-Style_Syntax>
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek <http://www.w3.org/TR/owl2-manchester-syntax/>
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek-}
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekmodule OWL2.AS where
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekimport Common.Id
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekimport OWL2.ColonKeywords
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekimport OWL2.Keywords
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekimport Data.Char (intToDigit)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekimport Data.List
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekimport Data.Maybe
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekimport qualified Data.Map as Map
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekdata IRIType = Full | Abbreviated | NodeID
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina deriving (Show, Eq, Ord)
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina{- | full or abbreviated IRIs with a possible uri for the prefix
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina or a local part following a hash sign -}
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinadata QName = QN
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek { namePrefix :: String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek -- ^ the name prefix part of a qualified name \"namePrefix:localPart\"
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek , localPart :: String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek -- ^ the local part of a qualified name \"namePrefix:localPart\"
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek , iriType :: IRIType
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek , expandedIRI :: String
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek -- ^ the associated namespace uri (not printed)
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek , iriPos :: Range
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek } deriving Show
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekinstance Eq QName where
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek p == q = compare p q == EQ
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekinstance Ord QName where
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek compare (QN p1 l1 b1 n1 _) (QN p2 l2 b2 n2 _) =
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek if null n1 || null n2 then compare (b1, p1, l1) (b2, p2, l2) else
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek compare n1 n2 -- compare fully expanded names only
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekinstance GetRange QName where
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek getRange = iriPos
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekshowQN :: QName -> String
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekshowQN q = (if iriType q /= Abbreviated then showQI else showQU) q
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek-- | show QName as abbreviated iri
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekshowQU :: QName -> String
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekshowQU (QN pre local _ _ _) =
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek if null pre then local else pre ++ ":" ++ local
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek-- | show QName in ankle brackets as full iris
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekshowQI :: QName -> String
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekshowQI = ('<' :) . (++ ">") . showQU
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozeknullQName :: QName
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozeknullQName = QN "" "" Abbreviated "" nullRange
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekisNullQName :: QName -> Bool
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekisNullQName qn = case qn of
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek QN "" "" _ "" _ -> True
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek _ -> False
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekdummyQName :: QName
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekdummyQName =
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek QN "http" "//www.dfki.de/sks/hets/ontology/unamed" Full "" nullRange
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekmkQName :: String -> QName
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekmkQName s = nullQName { localPart = s }
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozeksetQRange :: Range -> QName -> QName
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozeksetQRange r q = q { iriPos = r }
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozeksetPrefix :: String -> QName -> QName
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozeksetPrefix s q = q { namePrefix = s }
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozeksetFull :: QName -> QName
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozeksetFull q = q {iriType = Full}
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozektype IRI = QName
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek-- | checks if an IRI is an anonymous individual
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekisAnonymous :: IRI -> Bool
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekisAnonymous iri = iriType iri == NodeID
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek-- | checks if a string (bound to be localPart of an IRI) contains \":\/\/\"
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekcssIRI :: String -> IRIType
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub HrozekcssIRI iri = if isInfixOf "://" iri then Full else Abbreviated
3660f49f81e4db07be66fe0887af9d62065f1f2cJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek-- | prefix -> localname
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype PrefixMap = Map.Map String String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekpredefPrefixes :: PrefixMap
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekpredefPrefixes = Map.fromList
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek [ ("owl", "http://www.w3.org/2002/07/owl#")
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek , ("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek , ("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek , ("xsd", "http://www.w3.org/2001/XMLSchema#")
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek , ("", showQU dummyQName ++ "#") ]
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype LexicalForm = String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype LanguageTag = String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype ImportIRI = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype OntologyIRI = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype Class = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype Datatype = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype ObjectProperty = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype DataProperty = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype AnnotationProperty = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype NamedIndividual = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozektype Individual = IRI
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekdata EquivOrDisjoint = Equivalent | Disjoint
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek deriving (Show, Eq, Ord)
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekshowEquivOrDisjoint :: EquivOrDisjoint -> String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekshowEquivOrDisjoint ed = case ed of
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek Equivalent -> equivalentToC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek Disjoint -> disjointWithC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekdata DomainOrRange = ADomain | ARange
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek deriving (Show, Eq, Ord)
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekshowDomainOrRange :: DomainOrRange -> String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekshowDomainOrRange dr = case dr of
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek ADomain -> domainC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek ARange -> rangeC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekdata SameOrDifferent = Same | Different
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek deriving (Show, Eq, Ord)
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekshowSameOrDifferent :: SameOrDifferent -> String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekshowSameOrDifferent sd = case sd of
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek Same -> sameAsC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek Different -> differentFromC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozekdata Relation =
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek EDRelation EquivOrDisjoint
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek | SubPropertyOf
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek | InverseOf
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek | SubClass
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek | Types
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek | DRRelation DomainOrRange
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek | SDRelation SameOrDifferent
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek deriving (Show, Eq, Ord)
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekshowRelation :: Relation -> String
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekshowRelation r = case r of
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek EDRelation ed -> showEquivOrDisjoint ed
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek SubPropertyOf -> subPropertyOfC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek InverseOf -> inverseOfC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek SubClass -> subClassOfC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek Types -> typesC
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek DRRelation dr -> showDomainOrRange dr
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek SDRelation sd -> showSameOrDifferent sd
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekgetED :: Relation -> EquivOrDisjoint
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekgetED r = case r of
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek EDRelation ed -> ed
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek _ -> error "not domain or range"
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekgetDR :: Relation -> DomainOrRange
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekgetDR r = case r of
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek DRRelation dr -> dr
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek _ -> error "not domain or range"
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub Hrozek
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekgetSD :: Relation -> SameOrDifferent
f92ace4a52602e8c38a34f2392bec3deeac2ddddJakub HrozekgetSD s = case s of
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek SDRelation sd -> sd
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek _ -> error "not same or different"
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek
770dc892f867639f36f84455d65be6287935a529Jakub Hrozekdata Character =
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek Functional
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek | InverseFunctional
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek | Reflexive
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek | Irreflexive
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek | Symmetric
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek | Asymmetric
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek | Antisymmetric
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek | Transitive
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek deriving (Enum, Bounded, Show, Eq, Ord)
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek
770dc892f867639f36f84455d65be6287935a529Jakub Hrozekdata PositiveOrNegative = Positive | Negative
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek deriving (Show, Eq, Ord)
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek
770dc892f867639f36f84455d65be6287935a529Jakub Hrozekdata QuantifierType = AllValuesFrom | SomeValuesFrom
770dc892f867639f36f84455d65be6287935a529Jakub Hrozek deriving (Show, Eq, Ord)
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinashowQuantifierType :: QuantifierType -> String
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinashowQuantifierType ty = case ty of
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina AllValuesFrom -> onlyS
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina SomeValuesFrom -> someS
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina-- * Predefined IRI checkings
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisThing :: IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisThing = isOWLPredef predefClass
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefObjProp :: IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefObjProp = isOWLPredef predefObjProp
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefDataProp :: IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefDataProp = isOWLPredef predefDataProp
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefRDFSAnnoProp :: IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefRDFSAnnoProp = checkPredef predefRDFSAnnoProps "rdfs"
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefOWLAnnoProp :: IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefOWLAnnoProp = isOWLPredef predefOWLAnnoProps
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefAnnoProp :: IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefAnnoProp iri = isPredefOWLAnnoProp iri || isPredefRDFSAnnoProp iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefPropOrClass :: IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisPredefPropOrClass iri = isPredefAnnoProp iri || isPredefDataProp iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina || isPredefObjProp iri || isThing iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinapredefIRIs :: [IRI]
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinapredefIRIs = map (setPrefix "xsd" . mkQName) xsdKeys
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ++ map (setPrefix "owl" . mkQName) owlNumbers
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ++ [setPrefix "rdf" (mkQName rdfsLiteral),
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina setPrefix "rdfs" $ mkQName xmlLiteral]
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisDatatypeKey :: IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisDatatypeKey iri = any (\ (l, p) -> checkPredef l p iri) [(xsdKeys, "xsd"),
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina (owlNumbers, "owl"), ([xmlLiteral], "rdf"), ([rdfsLiteral], "rdfs")]
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinacheckPredef :: [String] -> String -> IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinacheckPredef sl pref u =
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina localPart u `elem` sl && elem (namePrefix u) ["", pref]
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina || showQU u `elem` map (Map.findWithDefault
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina (error $ "not predefined prefix: " ++ show pref)
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina pref (predefPrefixes `Map.difference`
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina Map.fromList [("", showQU dummyQName ++ "#")]) ++) sl
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisOWLPredef :: [String] -> IRI -> Bool
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinaisOWLPredef sl = checkPredef sl "owl"
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina-- | sets the correct prefix for the predefined datatypes
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinasetDatatypePrefix :: IRI -> IRI
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinasetDatatypePrefix iri = let lp = localPart iri in
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina if lp `elem` xsdKeys
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina then setPrefix "xsd" iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina else if lp `elem` owlNumbers
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina then setPrefix "owl" iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina else case lp of
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina "XMLLiteral" -> setPrefix "rdf" iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina "Literal" -> setPrefix "rdfs" iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina _ -> error $ showQU iri ++ " is not a predefined datatype"
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina-- | checks if the IRI is part of the built-in ones and puts the correct prefix
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinasetReservedPrefix :: IRI -> IRI
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinasetReservedPrefix iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina | isDatatypeKey iri && null (namePrefix iri) = setDatatypePrefix iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina | (isThing iri || isPredefDataProp iri || isPredefOWLAnnoProp iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina || isPredefObjProp iri) && null (namePrefix iri) = setPrefix "owl" iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina | isPredefRDFSAnnoProp iri = setPrefix "rdfs" iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina | otherwise = iri
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinastripReservedPrefix :: IRI -> IRI
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel BřezinastripReservedPrefix = mkQName . getPredefName
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek{- | returns the name of the predefined IRI (e.g <xsd:string> returns "string"
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek or <http://www.w3.org/2002/07/owl#real> returns "real") -}
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekgetPredefName :: IRI -> String
ef7de95fc4827a660254a942fa394f34ed9694a9Pavel BřezinagetPredefName iri =
ef7de95fc4827a660254a942fa394f34ed9694a9Pavel Březina if namePrefix iri `elem` ["", "xsd", "rdf", "rdfs", "owl"]
ef7de95fc4827a660254a942fa394f34ed9694a9Pavel Březina then localPart iri
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek else case mapMaybe (flip stripPrefix $ showQU iri)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek $ Map.elems predefPrefixes of
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek [s] -> s
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek _ -> error $ showQU iri ++ " is not a predefined IRI"
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekprintDatatype :: IRI -> String
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekprintDatatype dt = showQU $
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek if isDatatypeKey dt then stripReservedPrefix dt else dt
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekdata DatatypeCat = OWL2Number | OWL2String | OWL2Bool | Other
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek deriving (Show, Eq, Ord)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekgetDatatypeCat :: IRI -> DatatypeCat
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekgetDatatypeCat iri = case isDatatypeKey iri of
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek True
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek | hasPrefXSD [booleanS] iri -> OWL2Bool
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek | hasPrefXSD xsdNumbers iri || checkPredef owlNumbers "owl" iri
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek -> OWL2Number
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek | hasPrefXSD xsdStrings iri -> OWL2String
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek | otherwise -> Other
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek False -> Other
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekhasPrefXSD :: [String] -> IRI -> Bool
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekhasPrefXSD sl = checkPredef sl "xsd"
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekfacetToIRI :: DatatypeFacet -> ConstrainingFacet
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekfacetToIRI = setPrefix "xsd" . mkQName . showFacet
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek-- * Cardinalities
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekdata CardinalityType = MinCardinality | MaxCardinality | ExactCardinality
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek deriving (Show, Eq, Ord)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekshowCardinalityType :: CardinalityType -> String
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub HrozekshowCardinalityType ty = case ty of
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek MinCardinality -> minS
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek MaxCardinality -> maxS
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek ExactCardinality -> exactlyS
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekdata Cardinality a b = Cardinality CardinalityType Int a (Maybe b)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek deriving (Show, Eq, Ord)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekdata JunctionType = UnionOf | IntersectionOf
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek deriving (Show, Eq, Ord)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozektype ConstrainingFacet = IRI
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozektype RestrictionValue = Literal
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek-- * ENTITIES
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekdata Entity = Entity EntityType IRI deriving (Show, Eq, Ord)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekinstance GetRange Entity where
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek getRange (Entity _ iri) = iriPos iri
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekdata EntityType =
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek Datatype
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek | Class
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek | ObjectProperty
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek | DataProperty
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek | AnnotationProperty
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek | NamedIndividual
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek deriving (Enum, Bounded, Show, Read, Eq, Ord)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekshowEntityType :: EntityType -> String
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekshowEntityType e = case e of
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek Datatype -> datatypeC
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek Class -> classC
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek ObjectProperty -> objectPropertyC
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek DataProperty -> dataPropertyC
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek AnnotationProperty -> annotationPropertyC
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek NamedIndividual -> individualC
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekentityTypes :: [EntityType]
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekentityTypes = [minBound .. maxBound]
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekcutIRI :: Entity -> IRI
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekcutIRI (Entity _ iri) = iri
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek-- * LITERALS
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekdata TypedOrUntyped = Typed Datatype | Untyped (Maybe LanguageTag)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek deriving (Show, Eq, Ord)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekdata Literal = Literal LexicalForm TypedOrUntyped | NumberLit FloatLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek deriving (Show, Eq, Ord)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek-- | non-negative integers given by the sequence of digits
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekdata NNInt = NNInt [Int] deriving (Eq, Ord)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekinstance Show NNInt where
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek show (NNInt l) = map intToDigit l
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekzeroNNInt :: NNInt
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekzeroNNInt = NNInt []
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekisZeroNNInt :: NNInt -> Bool
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekisZeroNNInt (NNInt l) = null l
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekdata IntLit = IntLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek { absInt :: NNInt
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek , isNegInt :: Bool }
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek deriving (Eq, Ord)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekinstance Show IntLit where
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek show (IntLit n b) = (if b then ('-' :) else id) $ show n
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekzeroInt :: IntLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekzeroInt = IntLit zeroNNInt False
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekisZeroInt :: IntLit -> Bool
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekisZeroInt (IntLit n _) = isZeroNNInt n
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozeknegNNInt :: Bool -> NNInt -> IntLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozeknegNNInt b n = IntLit n b
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozeknegInt :: IntLit -> IntLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozeknegInt (IntLit n b) = IntLit n $ not b
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekdata DecLit = DecLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek { truncDec :: IntLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek , fracDec :: NNInt }
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek deriving (Eq, Ord)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekinstance Show DecLit where
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek show (DecLit t f) = show t
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek ++ if isZeroNNInt f then "" else
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek '.' : show f
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekisDecInt :: DecLit -> Bool
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozekisDecInt = isZeroNNInt . fracDec
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozeknegDec :: Bool -> DecLit -> DecLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub HrozeknegDec b (DecLit t f) = DecLit (if b then negInt t else t) f
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekdata FloatLit = FloatLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek { floatBase :: DecLit
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek , floatExp :: IntLit }
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek deriving (Eq, Ord)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekinstance Show FloatLit where
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek show (FloatLit b e) = show b
++ if isZeroInt e then "" else
'E' : show e ++ "F"
isFloatDec :: FloatLit -> Bool
isFloatDec = isZeroInt . floatExp
isFloatInt :: FloatLit -> Bool
isFloatInt f = isFloatDec f && isDecInt (floatBase f)
floatToInt :: FloatLit -> IntLit
floatToInt = truncDec . floatBase
intToDec :: IntLit -> DecLit
intToDec i = DecLit i zeroNNInt
decToFloat :: DecLit -> FloatLit
decToFloat d = FloatLit d zeroInt
intToFloat :: IntLit -> FloatLit
intToFloat = decToFloat . intToDec
abInt :: IntLit -> IntLit
abInt int = int {isNegInt = False}
abDec :: DecLit -> DecLit
abDec dec = dec {truncDec = abInt $ truncDec dec}
abFloat :: FloatLit -> FloatLit
abFloat f = f {floatBase = abDec $ floatBase f}
isNegDec :: DecLit -> Bool
isNegDec d = isNegInt $ truncDec d
numberName :: FloatLit -> String
numberName f
| isFloatInt f = integerS
| isFloatDec f = decimalS
| otherwise = floatS
cTypeS :: String
cTypeS = "^^"
-- * PROPERTY EXPRESSIONS
type InverseObjectProperty = ObjectPropertyExpression
data ObjectPropertyExpression = ObjectProp ObjectProperty
| ObjectInverseOf InverseObjectProperty
deriving (Show, Eq, Ord)
type DataPropertyExpression = DataProperty
-- * DATA RANGES
data DataRange =
DataType Datatype [(ConstrainingFacet, RestrictionValue)]
| DataJunction JunctionType [DataRange]
| DataComplementOf DataRange
| DataOneOf [Literal]
deriving (Show, Eq, Ord)
-- * CLASS EXPERSSIONS
data ClassExpression =
Expression Class
| ObjectJunction JunctionType [ClassExpression]
| ObjectComplementOf ClassExpression
| ObjectOneOf [Individual]
| ObjectValuesFrom QuantifierType ObjectPropertyExpression ClassExpression
| ObjectHasValue ObjectPropertyExpression Individual
| ObjectHasSelf ObjectPropertyExpression
| ObjectCardinality (Cardinality ObjectPropertyExpression ClassExpression)
| DataValuesFrom QuantifierType DataPropertyExpression DataRange
| DataHasValue DataPropertyExpression Literal
| DataCardinality (Cardinality DataPropertyExpression DataRange)
deriving (Show, Eq, Ord)
-- * ANNOTATIONS
data Annotation = Annotation [Annotation] AnnotationProperty AnnotationValue
deriving (Show, Eq, Ord)
data AnnotationValue =
AnnValue IRI
| AnnValLit Literal
deriving (Show, Eq, Ord)