AS.hs revision 669b3375925f7a145d287fa89f3a815708dbe7a1
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder{- |
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian MaederModule : $Header$
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiCopyright : (c) C. Maeder, Felix Gabriel Mance
1549f3abf73c1122acff724f718b615c82fa3648Till MossakowskiLicense : GPLv2 or higher, see LICENSE.txt
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maeder
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian MaederMaintainer : Christian.Maeder@dfki.de
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederStability : provisional
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian MaederPortability : portable
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaederOWL 2 Functional Syntax constructs
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski
1549f3abf73c1122acff724f718b615c82fa3648Till MossakowskiReferences:
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder <http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/#Functional-Style_Syntax>
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder <http://www.w3.org/TR/owl2-manchester-syntax/>
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder-}
f8b715ab2993083761c0aedb78f1819bcf67b6ccChristian Maeder
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maedermodule OWL2.AS where
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder
ad270004874ce1d0697fb30d7309f180553bb315Christian Maederimport Common.Id
ad270004874ce1d0697fb30d7309f180553bb315Christian Maederimport OWL2.ColonKeywords
5e46b572ed576c0494768998b043d9d340594122Till Mossakowskiimport OWL2.Keywords
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang
23a00c966f2aa8da525d7a7c51933c99964426c0Christian Maederimport Data.Char (intToDigit)
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maederimport Data.List
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maederimport Data.Maybe
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wangimport qualified Data.Map as Map
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maederdata IRIType = Full | Abbreviated | NodeID
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder deriving (Show, Eq, Ord)
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder{- | full or abbreviated IRIs with a possible uri for the prefix
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski or a local part following a hash sign -}
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maederdata QName = QN
0e2ae85e2453466d03c1fc5884a3d693235bb9d9Christian Maeder { namePrefix :: String
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder -- ^ the name prefix part of a qualified name \"namePrefix:localPart\"
90c174bac60a72ffd81bc3bf5ae2dd9a61943b8bChristian Maeder , localPart :: String
2561b4bfc45d280ee2be8a7870314670e4e682e4Christian Maeder -- ^ the local part of a qualified name \"namePrefix:localPart\"
ca020e82eb3567e7bdbb1cf70729efbd07e9caa4Klaus Luettich , iriType :: IRIType
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder , expandedIRI :: String
ca020e82eb3567e7bdbb1cf70729efbd07e9caa4Klaus Luettich -- ^ the associated namespace uri (not printed)
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder , iriPos :: Range
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder } deriving Show
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maederinstance Eq QName where
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu p == q = compare p q == EQ
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
986d3f255182539098a97ac86da9eeee5b7a72e3Christian Maederinstance Ord QName where
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder compare (QN p1 l1 b1 n1 _) (QN p2 l2 b2 n2 _) =
8e80792f474d154ff11762fac081a422e34f1accChristian Maeder if null n1 || null n2 then compare (b1, p1, l1) (b2, p2, l2) else
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder compare n1 n2 -- compare fully expanded names only
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian Maederinstance GetRange QName where
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder getRange = iriPos
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian MaedershowQN :: QName -> String
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian MaedershowQN q = (if iriType q /= Abbreviated then showQI else showQU) q
4c7f058cdd19ce67b2b5d4b7f69703d0f8a21e38Christian Maeder
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maeder-- | show QName as abbreviated iri
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian MaedershowQU :: QName -> String
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian MaedershowQU (QN pre local _ _ _) =
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maeder if null pre then local else pre ++ ":" ++ local
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maeder
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maeder-- | show QName in ankle brackets as full iris
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian MaedershowQI :: QName -> String
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian MaedershowQI = ('<' :) . (++ ">") . showQU
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maeder
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian MaedernullQName :: QName
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian MaedernullQName = QN "" "" Abbreviated "" nullRange
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaederisNullQName :: QName -> Bool
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian MaederisNullQName qn = case qn of
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder QN "" "" _ "" _ -> True
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder _ -> False
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian MaederdummyQName :: QName
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian MaederdummyQName =
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder QN "http" "//www.dfki.de/sks/hets/ontology/unamed" Full "" nullRange
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian MaedermkQName :: String -> QName
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaedermkQName s = nullQName { localPart = s }
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski
5e46b572ed576c0494768998b043d9d340594122Till MossakowskisetQRange :: Range -> QName -> QName
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaedersetQRange r q = q { iriPos = r }
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian MaedersetPrefix :: String -> QName -> QName
03136b84a0c70d877e227444f0875e209506b9e4Christian MaedersetPrefix s q = q { namePrefix = s }
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaedersetFull :: QName -> QName
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaedersetFull q = q {iriType = Full}
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maedertype IRI = QName
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski-- | checks if an IRI is an anonymous individual
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian MaederisAnonymous :: IRI -> Bool
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill MossakowskiisAnonymous iri = iriType iri == NodeID || namePrefix iri == "_"
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski-- | checks if a string (bound to be localPart of an IRI) contains \":\/\/\"
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian MaedercssIRI :: String -> IRIType
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian MaedercssIRI iri = if isInfixOf "://" iri then Full else Abbreviated
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder-- | prefix -> localname
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maedertype PrefixMap = Map.Map String String
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaederpredefPrefixes :: PrefixMap
4601edb679f0ba530bbb085b25d82a411cd070aaChristian MaederpredefPrefixes = Map.fromList
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder [ ("owl", "http://www.w3.org/2002/07/owl#")
26d11a256b1433604a3dbc69913b520fff7586acChristian Maeder , ("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder , ("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder , ("xsd", "http://www.w3.org/2001/XMLSchema#")
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder , ("", showQU dummyQName ++ "#") ]
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian Maedertype LexicalForm = String
03136b84a0c70d877e227444f0875e209506b9e4Christian Maedertype LanguageTag = String
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maedertype ImportIRI = IRI
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maedertype OntologyIRI = IRI
03136b84a0c70d877e227444f0875e209506b9e4Christian Maedertype Class = IRI
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maedertype Datatype = IRI
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maedertype ObjectProperty = IRI
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maedertype DataProperty = IRI
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maedertype AnnotationProperty = IRI
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maedertype NamedIndividual = IRI
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowskitype Individual = IRI
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maederdata EquivOrDisjoint = Equivalent | Disjoint
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder deriving (Show, Eq, Ord)
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian MaedershowEquivOrDisjoint :: EquivOrDisjoint -> String
03136b84a0c70d877e227444f0875e209506b9e4Christian MaedershowEquivOrDisjoint ed = case ed of
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder Equivalent -> equivalentToC
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder Disjoint -> disjointWithC
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski
74d9a385499bf903b24848dff450a153f525bda7Christian Maederdata DomainOrRange = ADomain | ARange
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder deriving (Show, Eq, Ord)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian MaedershowDomainOrRange :: DomainOrRange -> String
03136b84a0c70d877e227444f0875e209506b9e4Christian MaedershowDomainOrRange dr = case dr of
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder ADomain -> domainC
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder ARange -> rangeC
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian Maederdata SameOrDifferent = Same | Different
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder deriving (Show, Eq, Ord)
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill MossakowskishowSameOrDifferent :: SameOrDifferent -> String
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill MossakowskishowSameOrDifferent sd = case sd of
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder Same -> sameAsC
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder Different -> differentFromC
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maederdata Relation =
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder EDRelation EquivOrDisjoint
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder | SubPropertyOf
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder | InverseOf
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder | SubClass
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder | Types
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder | DRRelation DomainOrRange
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder | SDRelation SameOrDifferent
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder deriving (Show, Eq, Ord)
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian MaedershowRelation :: Relation -> String
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian MaedershowRelation r = case r of
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski EDRelation ed -> showEquivOrDisjoint ed
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder SubPropertyOf -> subPropertyOfC
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder InverseOf -> inverseOfC
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder SubClass -> subClassOfC
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder Types -> typesC
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder DRRelation dr -> showDomainOrRange dr
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder SDRelation sd -> showSameOrDifferent sd
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder
99476ac2689c74251219db4782e57fe713a24a52Christian MaedergetED :: Relation -> EquivOrDisjoint
99476ac2689c74251219db4782e57fe713a24a52Christian MaedergetED r = case r of
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder EDRelation ed -> ed
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder _ -> error "not domain or range"
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder
99476ac2689c74251219db4782e57fe713a24a52Christian MaedergetDR :: Relation -> DomainOrRange
99476ac2689c74251219db4782e57fe713a24a52Christian MaedergetDR r = case r of
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder DRRelation dr -> dr
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder _ -> error "not domain or range"
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian MaedergetSD :: Relation -> SameOrDifferent
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian MaedergetSD s = case s of
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder SDRelation sd -> sd
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder _ -> error "not same or different"
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maederdata Character =
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder Functional
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder | InverseFunctional
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder | Reflexive
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder | Irreflexive
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski | Symmetric
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder | Asymmetric
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder | Antisymmetric
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder | Transitive
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski deriving (Enum, Bounded, Show, Eq, Ord)
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
03136b84a0c70d877e227444f0875e209506b9e4Christian Maederdata PositiveOrNegative = Positive | Negative
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder deriving (Show, Eq, Ord)
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maederdata QuantifierType = AllValuesFrom | SomeValuesFrom
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder deriving (Show, Eq, Ord)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian MaedershowQuantifierType :: QuantifierType -> String
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian MaedershowQuantifierType ty = case ty of
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder AllValuesFrom -> onlyS
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder SomeValuesFrom -> someS
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder-- * Predefined IRI checkings
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder
99476ac2689c74251219db4782e57fe713a24a52Christian MaederisThing :: IRI -> Bool
99476ac2689c74251219db4782e57fe713a24a52Christian MaederisThing = isOWLPredef predefClass
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder
99476ac2689c74251219db4782e57fe713a24a52Christian MaederisPredefObjProp :: IRI -> Bool
99476ac2689c74251219db4782e57fe713a24a52Christian MaederisPredefObjProp = isOWLPredef predefObjProp
3df765bba27034f17ba60ee9b90d7dbd3643ea9eChristian Maeder
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian MaederisPredefDataProp :: IRI -> Bool
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian MaederisPredefDataProp = isOWLPredef predefDataProp
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian MaederisPredefRDFSAnnoProp :: IRI -> Bool
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian MaederisPredefRDFSAnnoProp = checkPredef predefRDFSAnnoProps "rdfs"
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian MaederisPredefOWLAnnoProp :: IRI -> Bool
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian MaederisPredefOWLAnnoProp = isOWLPredef predefOWLAnnoProps
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill MossakowskiisPredefAnnoProp :: IRI -> Bool
03136b84a0c70d877e227444f0875e209506b9e4Christian MaederisPredefAnnoProp iri = isPredefOWLAnnoProp iri || isPredefRDFSAnnoProp iri
0e2ae85e2453466d03c1fc5884a3d693235bb9d9Christian Maeder
200849122a9c65773e5b2ba8084ac3490d0490b5Christian MaederisPredefPropOrClass :: IRI -> Bool
200849122a9c65773e5b2ba8084ac3490d0490b5Christian MaederisPredefPropOrClass iri = isPredefAnnoProp iri || isPredefDataProp iri
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder || isPredefObjProp iri || isThing iri
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder
200849122a9c65773e5b2ba8084ac3490d0490b5Christian MaederpredefIRIs :: [IRI]
200849122a9c65773e5b2ba8084ac3490d0490b5Christian MaederpredefIRIs = map (setPrefix "xsd" . mkQName) xsdKeys
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder ++ map (setPrefix "owl" . mkQName) owlNumbers
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder ++ [setPrefix "rdf" (mkQName rdfsLiteral),
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder setPrefix "rdfs" $ mkQName xmlLiteral]
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaederisDatatypeKey :: IRI -> Bool
200849122a9c65773e5b2ba8084ac3490d0490b5Christian MaederisDatatypeKey iri = any (\ (l, p) -> checkPredef l p iri) [(xsdKeys, "xsd"),
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder (owlNumbers, "owl"), ([xmlLiteral], "rdf"), ([rdfsLiteral], "rdfs")]
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
200849122a9c65773e5b2ba8084ac3490d0490b5Christian MaedercheckPredef :: [String] -> String -> IRI -> Bool
0b6f6d3eeb7b3b36292e60f1b3da5a5ce42eef1aChristian MaedercheckPredef sl pref u =
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder localPart u `elem` sl && elem (namePrefix u) ["", pref]
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder || showQU u `elem` map (Map.findWithDefault
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder (error $ "not predefined prefix: " ++ show pref)
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder pref (predefPrefixes `Map.difference`
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder Map.fromList [("", showQU dummyQName ++ "#")]) ++) sl
200849122a9c65773e5b2ba8084ac3490d0490b5Christian Maeder
0b6f6d3eeb7b3b36292e60f1b3da5a5ce42eef1aChristian MaederisOWLPredef :: [String] -> IRI -> Bool
200849122a9c65773e5b2ba8084ac3490d0490b5Christian MaederisOWLPredef sl = checkPredef sl "owl"
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder-- | sets the correct prefix for the predefined datatypes
03136b84a0c70d877e227444f0875e209506b9e4Christian MaedersetDatatypePrefix :: IRI -> IRI
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaedersetDatatypePrefix iri = let lp = localPart iri in
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder if lp `elem` xsdKeys
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder then setPrefix "xsd" iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder else if lp `elem` owlNumbers
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder then setPrefix "owl" iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder else case lp of
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder "XMLLiteral" -> setPrefix "rdf" iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder "Literal" -> setPrefix "rdfs" iri
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder _ -> error $ showQU iri ++ " is not a predefined datatype"
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder-- | checks if the IRI is part of the built-in ones and puts the correct prefix
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian MaedersetReservedPrefix :: IRI -> IRI
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian MaedersetReservedPrefix iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder | isDatatypeKey iri && null (namePrefix iri) = setDatatypePrefix iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder | (isThing iri || isPredefDataProp iri || isPredefOWLAnnoProp iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder || isPredefObjProp iri) && null (namePrefix iri) = setPrefix "owl" iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder | isPredefRDFSAnnoProp iri = setPrefix "rdfs" iri
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder | otherwise = iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian MaederstripReservedPrefix :: IRI -> IRI
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian MaederstripReservedPrefix = mkQName . getPredefName
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder{- | returns the name of the predefined IRI (e.g <xsd:string> returns "string"
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder or <http://www.w3.org/2002/07/owl#real> returns "real") -}
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian MaedergetPredefName :: IRI -> String
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian MaedergetPredefName iri =
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder if namePrefix iri `elem` ["", "xsd", "rdf", "rdfs", "owl"]
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder then localPart iri
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder else case mapMaybe (`stripPrefix` showQU iri)
2561b4bfc45d280ee2be8a7870314670e4e682e4Christian Maeder $ Map.elems predefPrefixes of
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder [s] -> s
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder _ -> showQN iri
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder-- | Extracts Token from IRI
aea143fff7a50aceb809845fbc42698b0b3f545aChristian MaederuriToTok :: IRI -> Token
aea143fff7a50aceb809845fbc42698b0b3f545aChristian MaederuriToTok urI = mkSimpleId $ getPredefName urI
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder-- | Extracts Id from IRI
aea143fff7a50aceb809845fbc42698b0b3f545aChristian MaederuriToId :: IRI -> Id
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian MaederuriToId = simpleIdToId . uriToTok
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder-- | Extracts Id from Entities
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian MaederentityToId :: Entity -> Id
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian MaederentityToId = uriToId . cutIRI
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian MaederprintDatatype :: IRI -> String
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian MaederprintDatatype dt = showQU $
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder if isDatatypeKey dt then stripReservedPrefix dt else dt
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maederdata DatatypeCat = OWL2Number | OWL2String | OWL2Bool | Other
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder deriving (Show, Eq, Ord)
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian MaedergetDatatypeCat :: IRI -> DatatypeCat
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaedergetDatatypeCat iri = case isDatatypeKey iri of
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder True
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder | hasPrefXSD [booleanS] iri -> OWL2Bool
44d2a211a352759ee988ed8353026f5fa9511209Christian Maeder | hasPrefXSD xsdNumbers iri || checkPredef owlNumbers "owl" iri
44d2a211a352759ee988ed8353026f5fa9511209Christian Maeder -> OWL2Number
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder | hasPrefXSD xsdStrings iri -> OWL2String
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder | otherwise -> Other
4fc727afa544a757d1959ce77c02208f8bf330dcChristian Maeder False -> Other
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaederhasPrefXSD :: [String] -> IRI -> Bool
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaederhasPrefXSD sl = checkPredef sl "xsd"
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian MaederfacetToIRI :: DatatypeFacet -> ConstrainingFacet
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian MaederfacetToIRI = setPrefix "xsd" . mkQName . showFacet
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder-- * Cardinalities
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder
4fc727afa544a757d1959ce77c02208f8bf330dcChristian Maederdata CardinalityType = MinCardinality | MaxCardinality | ExactCardinality
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder deriving (Show, Eq, Ord)
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian MaedershowCardinalityType :: CardinalityType -> String
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian MaedershowCardinalityType ty = case ty of
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder MinCardinality -> minS
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder MaxCardinality -> maxS
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder ExactCardinality -> exactlyS
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maederdata Cardinality a b = Cardinality CardinalityType Int a (Maybe b)
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder deriving (Show, Eq, Ord)
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maederdata JunctionType = UnionOf | IntersectionOf
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder deriving (Show, Eq, Ord)
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski
74d9a385499bf903b24848dff450a153f525bda7Christian Maedertype ConstrainingFacet = IRI
5e46b572ed576c0494768998b043d9d340594122Till Mossakowskitype RestrictionValue = Literal
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder-- * ENTITIES
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maederdata Entity = Entity
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski { entityKind :: EntityType
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder , cutIRI :: IRI }
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski deriving (Show, Eq, Ord)
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski
5e46b572ed576c0494768998b043d9d340594122Till Mossakowskiinstance GetRange Entity where
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder getRange = iriPos . cutIRI
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maederdata EntityType =
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski Datatype
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder | Class
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder | ObjectProperty
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder | DataProperty
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder | AnnotationProperty
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder | NamedIndividual
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder deriving (Enum, Bounded, Show, Read, Eq, Ord)
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder
d058429727dd696a0327cdc28cadd268c34c36baChristian MaedershowEntityType :: EntityType -> String
d058429727dd696a0327cdc28cadd268c34c36baChristian MaedershowEntityType e = case e of
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder Datatype -> datatypeC
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder Class -> classC
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder ObjectProperty -> objectPropertyC
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder DataProperty -> dataPropertyC
329d1810c6d5a5a0827e1d07503d94431578d176Christian Maeder AnnotationProperty -> annotationPropertyC
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski NamedIndividual -> individualC
329d1810c6d5a5a0827e1d07503d94431578d176Christian Maeder
329d1810c6d5a5a0827e1d07503d94431578d176Christian MaederentityTypes :: [EntityType]
d058429727dd696a0327cdc28cadd268c34c36baChristian MaederentityTypes = [minBound .. maxBound]
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder-- * LITERALS
5a9a06d23910b9521e1d1cd39865ac7912ccee4bChristian Maeder
5a9a06d23910b9521e1d1cd39865ac7912ccee4bChristian Maederdata TypedOrUntyped = Typed Datatype | Untyped (Maybe LanguageTag)
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder deriving (Show, Eq, Ord)
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder
329d1810c6d5a5a0827e1d07503d94431578d176Christian Maederdata Literal = Literal LexicalForm TypedOrUntyped | NumberLit FloatLit
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski deriving (Show, Eq, Ord)
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder-- | non-negative integers given by the sequence of digits
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maederdata NNInt = NNInt [Int] deriving (Eq, Ord)
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maederinstance Show NNInt where
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder show (NNInt l) = map intToDigit l
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian MaederzeroNNInt :: NNInt
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian MaederzeroNNInt = NNInt []
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian MaederisZeroNNInt :: NNInt -> Bool
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian MaederisZeroNNInt (NNInt l) = null l
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder
27b37f8e6b165f7abb653a54b45ffcdb81cec561Christian Maederdata IntLit = IntLit
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder { absInt :: NNInt
0e2ae85e2453466d03c1fc5884a3d693235bb9d9Christian Maeder , isNegInt :: Bool }
27b37f8e6b165f7abb653a54b45ffcdb81cec561Christian Maeder deriving (Eq, Ord)
0e2ae85e2453466d03c1fc5884a3d693235bb9d9Christian Maeder
27b37f8e6b165f7abb653a54b45ffcdb81cec561Christian Maederinstance Show IntLit where
27b37f8e6b165f7abb653a54b45ffcdb81cec561Christian Maeder show (IntLit n b) = (if b then ('-' :) else id) $ show n
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder
27b37f8e6b165f7abb653a54b45ffcdb81cec561Christian MaederzeroInt :: IntLit
27b37f8e6b165f7abb653a54b45ffcdb81cec561Christian MaederzeroInt = IntLit zeroNNInt False
27b37f8e6b165f7abb653a54b45ffcdb81cec561Christian Maeder
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill MossakowskiisZeroInt :: IntLit -> Bool
32562a567baac248a00782d2727716c13117dc4aChristian MaederisZeroInt (IntLit n _) = isZeroNNInt n
32562a567baac248a00782d2727716c13117dc4aChristian Maeder
32562a567baac248a00782d2727716c13117dc4aChristian MaedernegNNInt :: Bool -> NNInt -> IntLit
32562a567baac248a00782d2727716c13117dc4aChristian MaedernegNNInt b n = IntLit n b
32562a567baac248a00782d2727716c13117dc4aChristian Maeder
32562a567baac248a00782d2727716c13117dc4aChristian MaedernegInt :: IntLit -> IntLit
0e2ae85e2453466d03c1fc5884a3d693235bb9d9Christian MaedernegInt (IntLit n b) = IntLit n $ not b
4601edb679f0ba530bbb085b25d82a411cd070aaChristian Maeder
32562a567baac248a00782d2727716c13117dc4aChristian Maederdata DecLit = DecLit
32562a567baac248a00782d2727716c13117dc4aChristian Maeder { truncDec :: IntLit
32562a567baac248a00782d2727716c13117dc4aChristian Maeder , fracDec :: NNInt }
32562a567baac248a00782d2727716c13117dc4aChristian Maeder deriving (Eq, Ord)
32562a567baac248a00782d2727716c13117dc4aChristian Maeder
32562a567baac248a00782d2727716c13117dc4aChristian Maederinstance Show DecLit where
746440cc1b984a852f5864235b8fa3930963a081Christian Maeder show (DecLit t f) = show t
32562a567baac248a00782d2727716c13117dc4aChristian Maeder ++ if isZeroNNInt f then "" else
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder '.' : show f
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederisDecInt :: DecLit -> Bool
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederisDecInt = isZeroNNInt . fracDec
e68f45f355ed9d4026ee9baff5aa75aa7c911cc2Christian Maeder
e68f45f355ed9d4026ee9baff5aa75aa7c911cc2Christian MaedernegDec :: Bool -> DecLit -> DecLit
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian MaedernegDec b (DecLit t f) = DecLit (if b then negInt t else t) f
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maederdata FloatLit = FloatLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder { floatBase :: DecLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder , floatExp :: IntLit }
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maeder deriving (Eq, Ord)
4aa35aadcb28f8a962096efc70d3bdb58ab7d9faChristian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maederinstance Show FloatLit where
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder show (FloatLit b e) = show b
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder ++ if isZeroInt e then "" else
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder 'E' : show e ++ "F"
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederisFloatDec :: FloatLit -> Bool
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederisFloatDec = isZeroInt . floatExp
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederisFloatInt :: FloatLit -> Bool
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederisFloatInt f = isFloatDec f && isDecInt (floatBase f)
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederfloatToInt :: FloatLit -> IntLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederfloatToInt = truncDec . floatBase
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederintToDec :: IntLit -> DecLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederintToDec i = DecLit i zeroNNInt
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederdecToFloat :: DecLit -> FloatLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederdecToFloat d = FloatLit d zeroInt
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederintToFloat :: IntLit -> FloatLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederintToFloat = decToFloat . intToDec
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederabInt :: IntLit -> IntLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederabInt int = int {isNegInt = False}
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederabDec :: DecLit -> DecLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederabDec dec = dec {truncDec = abInt $ truncDec dec}
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederabFloat :: FloatLit -> FloatLit
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederabFloat f = f {floatBase = abDec $ floatBase f}
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederisNegDec :: DecLit -> Bool
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaederisNegDec d = isNegInt $ truncDec d
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaedernumberName :: FloatLit -> String
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaedernumberName f
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder | isFloatInt f = integerS
32562a567baac248a00782d2727716c13117dc4aChristian Maeder | isFloatDec f = decimalS
32562a567baac248a00782d2727716c13117dc4aChristian Maeder | otherwise = floatS
32562a567baac248a00782d2727716c13117dc4aChristian Maeder
32562a567baac248a00782d2727716c13117dc4aChristian MaedercTypeS :: String
32562a567baac248a00782d2727716c13117dc4aChristian MaedercTypeS = "^^"
32562a567baac248a00782d2727716c13117dc4aChristian Maeder
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder-- * PROPERTY EXPRESSIONS
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder
32562a567baac248a00782d2727716c13117dc4aChristian Maedertype InverseObjectProperty = ObjectPropertyExpression
32562a567baac248a00782d2727716c13117dc4aChristian Maeder
32562a567baac248a00782d2727716c13117dc4aChristian Maederdata ObjectPropertyExpression = ObjectProp ObjectProperty
32562a567baac248a00782d2727716c13117dc4aChristian Maeder | ObjectInverseOf InverseObjectProperty
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski deriving (Show, Eq, Ord)
3b70d8ee5c2927f843d5d907e6ef724f867f1b40Till Mossakowski
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maedertype DataPropertyExpression = DataProperty
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder-- * DATA RANGES
3b70d8ee5c2927f843d5d907e6ef724f867f1b40Till Mossakowski
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maederdata DataRange =
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder DataType Datatype [(ConstrainingFacet, RestrictionValue)]
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder | DataJunction JunctionType [DataRange]
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder | DataComplementOf DataRange
ca732bc259f74cb4f3f725daab7fe80fc7e1d9a0Till Mossakowski | DataOneOf [Literal]
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder deriving (Show, Eq, Ord)
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder-- * CLASS EXPERSSIONS
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maederdata ClassExpression =
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder Expression Class
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder | ObjectJunction JunctionType [ClassExpression]
ca732bc259f74cb4f3f725daab7fe80fc7e1d9a0Till Mossakowski | ObjectComplementOf ClassExpression
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang | ObjectOneOf [Individual]
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang | ObjectValuesFrom QuantifierType ObjectPropertyExpression ClassExpression
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang | ObjectHasValue ObjectPropertyExpression Individual
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder | ObjectHasSelf ObjectPropertyExpression
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski | ObjectCardinality (Cardinality ObjectPropertyExpression ClassExpression)
2561b4bfc45d280ee2be8a7870314670e4e682e4Christian Maeder | DataValuesFrom QuantifierType DataPropertyExpression DataRange
2561b4bfc45d280ee2be8a7870314670e4e682e4Christian Maeder | DataHasValue DataPropertyExpression Literal
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang | DataCardinality (Cardinality DataPropertyExpression DataRange)
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maeder deriving (Show, Eq, Ord)
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maeder
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder-- * ANNOTATIONS
d79e02625778d20a5458078f979ff74aac67db61Christian Maeder
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maederdata Annotation = Annotation [Annotation] AnnotationProperty AnnotationValue
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder deriving (Show, Eq, Ord)
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maederdata AnnotationValue = AnnValue IRI | AnnValLit Literal
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder deriving (Show, Eq, Ord)
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maeder