AS.hs revision e9458b1a7a19a63aa4c179f9ab20f4d50681c168
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder{-# LANGUAGE DeriveDataTypeable #-}
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian MaederCopyright : (c) C. Maeder, Felix Gabriel Mance
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederLicense : GPLv2 or higher, see LICENSE.txt
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : Christian.Maeder@dfki.de
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian MaederStability : provisional
413db961f13e112716509b6d61d7a7bbf50c98b2Christian MaederPortability : portable
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaederOWL 2 Functional Syntax constructs
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder <http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/#Functional-Style_Syntax>
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder <http://www.w3.org/TR/owl2-manchester-syntax/>
3c5cc698b0c061209ff83eb8de027daef5ae922aChristian Maederimport Data.Char (intToDigit)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maederimport qualified Data.Map as Map
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maederimport qualified Data.Set as Set
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederdata IRIType = Full | Abbreviated | NodeID
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder{- | full or abbreviated IRIs with a possible uri for the prefix
c18e9c3c6d5039618f1f2c05526ece84c7794ea3Christian Maeder or a local part following a hash sign -}
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederdata QName = QN
ce3928e71520030ad0275b72050a8f4377f9313cChristian Maeder { namePrefix :: String
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder -- ^ the name prefix part of a qualified name \"namePrefix:localPart\"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder , localPart :: String
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder -- ^ the local part of a qualified name \"namePrefix:localPart\"
e997f1724fcc2c5bb49f44e9f45e8354e0f3a2d6Christian Maeder , iriType :: IRIType
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder , expandedIRI :: String
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder -- ^ the associated namespace uri (not printed)
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder , iriPos :: Range
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder } deriving (Show, Typeable, Data)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederinstance Eq QName where
120efeede54a5f7650cda8e91363bd6832eac9a9Christian Maeder p == q = compare p q == EQ
120efeede54a5f7650cda8e91363bd6832eac9a9Christian Maederinstance Ord QName where
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder compare (QN p1 l1 b1 n1 _) (QN p2 l2 b2 n2 _) =
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder if null n1 || null n2 then compare (b1, p1, l1) (b2, p2, l2) else
df33a9af92444f63ad545da6bb326aac9284318eChristian Maeder compare n1 n2 -- compare fully expanded names only
df33a9af92444f63ad545da6bb326aac9284318eChristian MaederqNameRange :: QName -> [Pos]
df33a9af92444f63ad545da6bb326aac9284318eChristian MaederqNameRange q = let Range rs = iriPos q in case rs of
df33a9af92444f63ad545da6bb326aac9284318eChristian Maeder p0 = if iriType q == Full then incSourceColumn p (-1) else p
df33a9af92444f63ad545da6bb326aac9284318eChristian Maeder in tokenRange $ Token (showQN q) $ Range [p0]
df33a9af92444f63ad545da6bb326aac9284318eChristian Maederinstance GetRange QName where
df33a9af92444f63ad545da6bb326aac9284318eChristian Maeder getRange = iriPos
df33a9af92444f63ad545da6bb326aac9284318eChristian Maeder rangeSpan = qNameRange
120efeede54a5f7650cda8e91363bd6832eac9a9Christian MaedershowQN :: QName -> String
ce3928e71520030ad0275b72050a8f4377f9313cChristian MaedershowQN q = (if iriType q == Full then showQI else showQU) q
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder-- | show QName as abbreviated iri
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian MaedershowQU :: QName -> String
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian MaedershowQU (QN pre local _ _ _) =
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder if null pre then local else pre ++ ":" ++ local
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder-- | show QName in angle brackets as full iris
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedershowQI :: QName -> String
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedershowQI n = '<' : showQU n ++ ">"
92aa1b88f02d2a413da60dba78acd34312e6f29aChristian MaedernullQName :: QName
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedernullQName = QN "" "" Abbreviated "" nullRange
36c6cc568751e4235502cfee00ba7b597dae78dcChristian MaederisNullQName :: QName -> Bool
81946e2b3f6dde6167f48769bd02c7a634736856Christian MaederisNullQName qn = case qn of
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder QN "" "" _ "" _ -> True
6cb518d88084543c13aa7e56db767c14ee97ab77Christian MaederunamedS :: String
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaederunamedS = "//www." ++ dnamedS
99f16a0f9ca757410960ff51a79b034503384fe2Christian MaederdnamedS :: String
68485f7bfab1b4c6f963ce6837cba5fb148ed625Christian MaederdummyQName :: QName
68485f7bfab1b4c6f963ce6837cba5fb148ed625Christian MaederdummyQName = QN "http" unamedS Full ("http:" ++ unamedS) nullRange
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaedermkQName :: String -> QName
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaedermkQName s = nullQName { localPart = s }
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaedersetQRange :: Range -> QName -> QName
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaedersetQRange r q = q { iriPos = r }
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaedersetPrefix :: String -> QName -> QName
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaedersetPrefix s q = q { namePrefix = s }
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaedersetFull :: QName -> QName
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaedersetFull q = q {iriType = Full}
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maedertype IRI = QName
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maederinstance SymbolName QName where
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder addString (q, s) = q { localPart = localPart q ++ s,
df33a9af92444f63ad545da6bb326aac9284318eChristian Maeder expandedIRI = expandedIRI q ++ s
04a1ed0b360858b85de6f449b84df4eab81b3fc9Christian Maeder-- | checks if an IRI is an anonymous individual
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaederisAnonymous :: IRI -> Bool
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaederisAnonymous iri = iriType iri == NodeID || namePrefix iri == "_"
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder-- | checks if a string (bound to be localPart of an IRI) contains \":\/\/\"
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedercssIRI :: String -> IRIType
72909c6c1cfe9702f5910d0a135c8b55729c7917Christian MaedercssIRI iri = if isInfixOf "://" iri then Full else Abbreviated
72909c6c1cfe9702f5910d0a135c8b55729c7917Christian Maeder-- | prefix -> localname
68485f7bfab1b4c6f963ce6837cba5fb148ed625Christian Maedertype PrefixMap = Map.Map String String
e997f1724fcc2c5bb49f44e9f45e8354e0f3a2d6Christian MaederpredefPrefixes :: PrefixMap
e997f1724fcc2c5bb49f44e9f45e8354e0f3a2d6Christian MaederpredefPrefixes = Map.fromList
e997f1724fcc2c5bb49f44e9f45e8354e0f3a2d6Christian Maeder [ ("owl", "http://www.w3.org/2002/07/owl#")
932f71e6f6f404ac139399c3d6a2b906ba055cbdChristian Maeder , ("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
932f71e6f6f404ac139399c3d6a2b906ba055cbdChristian Maeder , ("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
e997f1724fcc2c5bb49f44e9f45e8354e0f3a2d6Christian Maeder , ("xsd", "http://www.w3.org/2001/XMLSchema#")
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder , ("", showQU dummyQName ++ "#") ]
99f16a0f9ca757410960ff51a79b034503384fe2Christian Maedertype LexicalForm = String
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maedertype LanguageTag = String
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maedertype ImportIRI = IRI
68485f7bfab1b4c6f963ce6837cba5fb148ed625Christian Maedertype OntologyIRI = IRI
932f71e6f6f404ac139399c3d6a2b906ba055cbdChristian Maedertype Class = IRI
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maedertype Datatype = IRI
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maedertype ObjectProperty = IRI
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maedertype DataProperty = IRI
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maedertype AnnotationProperty = IRI
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maedertype Individual = IRI
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maederdata EquivOrDisjoint = Equivalent | Disjoint
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedershowEquivOrDisjoint :: EquivOrDisjoint -> String
932f71e6f6f404ac139399c3d6a2b906ba055cbdChristian MaedershowEquivOrDisjoint ed = case ed of
35cd0c10843c2cdbbe29f00a2a5d7e5e4f2d0064Christian Maeder Equivalent -> equivalentToC
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder Disjoint -> disjointWithC
e997f1724fcc2c5bb49f44e9f45e8354e0f3a2d6Christian Maederdata DomainOrRange = ADomain | ARange
e997f1724fcc2c5bb49f44e9f45e8354e0f3a2d6Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
68485f7bfab1b4c6f963ce6837cba5fb148ed625Christian MaedershowDomainOrRange :: DomainOrRange -> String
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian MaedershowDomainOrRange dr = case dr of
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder ADomain -> domainC
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder ARange -> rangeC
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maederdata SameOrDifferent = Same | Different
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian MaedershowSameOrDifferent :: SameOrDifferent -> String
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedershowSameOrDifferent sd = case sd of
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder Same -> sameAsC
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder Different -> differentFromC
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederdata Relation =
37354e3ed68875fb527338105a610df481f98cb0Christian Maeder EDRelation EquivOrDisjoint
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder | SubPropertyOf
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder | DRRelation DomainOrRange
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder | SDRelation SameOrDifferent
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedershowRelation :: Relation -> String
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedershowRelation r = case r of
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder EDRelation ed -> showEquivOrDisjoint ed
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder SubPropertyOf -> subPropertyOfC
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder InverseOf -> inverseOfC
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder SubClass -> subClassOfC
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder Types -> typesC
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder DRRelation dr -> showDomainOrRange dr
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder SDRelation sd -> showSameOrDifferent sd
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedergetED :: Relation -> EquivOrDisjoint
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedergetED r = case r of
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder EDRelation ed -> ed
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian Maeder _ -> error "not domain or range"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedergetDR :: Relation -> DomainOrRange
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedergetDR r = case r of
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder DRRelation dr -> dr
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder _ -> error "not domain or range"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedergetSD :: Relation -> SameOrDifferent
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian MaedergetSD s = case s of
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian Maeder SDRelation sd -> sd
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian Maeder _ -> error "not same or different"
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian Maederdata Character =
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian Maeder | InverseFunctional
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian Maeder | Irreflexive
d50ea352472823a62196db3cf11fae2af6866ab6Christian Maeder | Antisymmetric
d50ea352472823a62196db3cf11fae2af6866ab6Christian Maeder deriving (Enum, Bounded, Show, Eq, Ord, Typeable, Data)
79bf169bcae16ce390683c698bae248c1ed6ab13Christian Maederdata PositiveOrNegative = Positive | Negative
09249711700a6acbc40a2e337688b434d7aafa28Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
09249711700a6acbc40a2e337688b434d7aafa28Christian Maederdata QuantifierType = AllValuesFrom | SomeValuesFrom
d50ea352472823a62196db3cf11fae2af6866ab6Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
d50ea352472823a62196db3cf11fae2af6866ab6Christian MaedershowQuantifierType :: QuantifierType -> String
d50ea352472823a62196db3cf11fae2af6866ab6Christian MaedershowQuantifierType ty = case ty of
d50ea352472823a62196db3cf11fae2af6866ab6Christian Maeder AllValuesFrom -> onlyS
d50ea352472823a62196db3cf11fae2af6866ab6Christian Maeder SomeValuesFrom -> someS
d50ea352472823a62196db3cf11fae2af6866ab6Christian Maeder-- * Predefined IRI checkings
d50ea352472823a62196db3cf11fae2af6866ab6Christian MaederthingMap :: PreDefMaps
d50ea352472823a62196db3cf11fae2af6866ab6Christian MaederthingMap = makeOWLPredefMaps predefClass
d50ea352472823a62196db3cf11fae2af6866ab6Christian MaederisThing :: IRI -> Bool
d50ea352472823a62196db3cf11fae2af6866ab6Christian MaederisThing = checkPredef thingMap
d50ea352472823a62196db3cf11fae2af6866ab6Christian MaedermakePredefObjProp :: PreDefMaps
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian MaedermakePredefObjProp = makeOWLPredefMaps predefObjProp
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaederisPredefObjProp :: IRI -> Bool
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian MaederisPredefObjProp = checkPredef makePredefObjProp
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedermakePredefDataProp :: PreDefMaps
f875f7eebac7f69bf9da98c93479a542d0a8056fChristian MaedermakePredefDataProp = makeOWLPredefMaps predefDataProp
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederisPredefDataProp :: IRI -> Bool
ce3928e71520030ad0275b72050a8f4377f9313cChristian MaederisPredefDataProp = checkPredef makePredefDataProp
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaedermakePredefRDFSAnnoProp :: PreDefMaps
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian MaedermakePredefRDFSAnnoProp = preDefMaps predefRDFSAnnoProps "rdfs"
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian MaederisPredefRDFSAnnoProp :: IRI -> Bool
b06572b54fcf9d6976cfff57da22672f996b4748Christian MaederisPredefRDFSAnnoProp = checkPredef makePredefRDFSAnnoProp
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedermakePredefOWLAnnoProp :: PreDefMaps
09249711700a6acbc40a2e337688b434d7aafa28Christian MaedermakePredefOWLAnnoProp = makeOWLPredefMaps predefOWLAnnoProps
b06572b54fcf9d6976cfff57da22672f996b4748Christian MaederisPredefOWLAnnoProp :: IRI -> Bool
09249711700a6acbc40a2e337688b434d7aafa28Christian MaederisPredefOWLAnnoProp = checkPredef makePredefOWLAnnoProp
09249711700a6acbc40a2e337688b434d7aafa28Christian MaederisPredefAnnoProp :: IRI -> Bool
09249711700a6acbc40a2e337688b434d7aafa28Christian MaederisPredefAnnoProp iri = isPredefOWLAnnoProp iri || isPredefRDFSAnnoProp iri
b06572b54fcf9d6976cfff57da22672f996b4748Christian MaederisPredefPropOrClass :: IRI -> Bool
09249711700a6acbc40a2e337688b434d7aafa28Christian MaederisPredefPropOrClass iri = isPredefAnnoProp iri || isPredefDataProp iri
09249711700a6acbc40a2e337688b434d7aafa28Christian Maeder || isPredefObjProp iri || isThing iri
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederpredefIRIs :: Set.Set IRI
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederpredefIRIs = Set.fromList $ map (setPrefix "xsd" . mkQName) xsdKeys
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maeder ++ map (setPrefix "owl" . mkQName) owlNumbers
84e7cfca5b97aef300acdaa8cf63a3572f9151c0Christian Maeder ++ map (setPrefix "rdf" . mkQName) [rdfsLiteral, stringS]
09249711700a6acbc40a2e337688b434d7aafa28Christian Maeder ++ [setPrefix "rdfs" $ mkQName xmlLiteral]
09249711700a6acbc40a2e337688b434d7aafa28Christian MaederisDatatypeKey :: IRI -> Bool
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian MaederisDatatypeKey = not . null . isDatatypeKeyAux
ce3928e71520030ad0275b72050a8f4377f9313cChristian MaederxsdMap :: PreDefMaps
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaederxsdMap = makeXsdMap xsdKeys
30e50372105eacc129a413e390e06036735b69b2Christian MaederowlNumbersMap :: PreDefMaps
30e50372105eacc129a413e390e06036735b69b2Christian MaederowlNumbersMap = makeOWLPredefMaps owlNumbers
95a732a847b41efa43b43608fcfcbac3b18dbb4fChristian MaederrdfMap :: PreDefMaps
30e50372105eacc129a413e390e06036735b69b2Christian MaederrdfMap = preDefMaps [xmlLiteral, stringS] "rdf"
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian MaederrdfsMap :: PreDefMaps
f875f7eebac7f69bf9da98c93479a542d0a8056fChristian MaederrdfsMap = preDefMaps [rdfsLiteral] "rdfs"
f7663514e02f6095198371a64e574c50e6ec857aChristian MaederisDatatypeKeyAux :: IRI -> [(String, String)]
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederisDatatypeKeyAux iri = mapMaybe (`checkPredefAux` iri)
f7663514e02f6095198371a64e574c50e6ec857aChristian Maeder [ xsdMap, owlNumbersMap, rdfMap, rdfsMap ]
f7663514e02f6095198371a64e574c50e6ec857aChristian Maedertype PreDefMaps = ([String], String, String)
f7663514e02f6095198371a64e574c50e6ec857aChristian MaederpreDefMaps :: [String] -> String -> PreDefMaps
f7663514e02f6095198371a64e574c50e6ec857aChristian MaederpreDefMaps sl pref = let
f7663514e02f6095198371a64e574c50e6ec857aChristian Maeder Just puri = Map.lookup pref predefPrefixes
f7663514e02f6095198371a64e574c50e6ec857aChristian Maeder Just sp = stripPrefix "http://www.w3.org/" puri
f7663514e02f6095198371a64e574c50e6ec857aChristian Maeder in (sl, pref, sp)
f7663514e02f6095198371a64e574c50e6ec857aChristian MaedercheckPredefAux :: PreDefMaps -> IRI -> Maybe (String, String)
f7663514e02f6095198371a64e574c50e6ec857aChristian MaedercheckPredefAux (sl, pref, exPref) u =
f7663514e02f6095198371a64e574c50e6ec857aChristian Maeder let lp = localPart u
99edc5256de959957a8c27b05ae4ad4f0572233dChristian Maeder nn = dnamedS ++ "#"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder res = Just (pref, lp)
99edc5256de959957a8c27b05ae4ad4f0572233dChristian Maeder in case namePrefix u of
f875f7eebac7f69bf9da98c93479a542d0a8056fChristian Maeder "http" -> case stripPrefix "//www." lp of
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder Just q -> case stripPrefix "w3.org/" q of
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder Just r -> case stripPrefix exPref r of
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder Just s | elem s sl -> Just (pref, s)
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder Nothing -> case stripPrefix nn q of
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder Just s | elem s sl -> Just (pref, s)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder Nothing -> Nothing
966e627a1c06b302a06d59d08b8ab45905f3509cChristian Maeder pu | elem lp sl -> case pu of
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "" -> let ex = expandedIRI u in
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder case stripPrefix "http://www." ex of
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder Just r | r == "w3.org/" ++ exPref ++ lp || r == nn ++ lp
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder _ | null ex -> res
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder _ | pu == pref -> Just (pref, lp)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedercheckPredef :: PreDefMaps -> IRI -> Bool
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedercheckPredef ms = isJust . checkPredefAux ms
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian MaedermakeOWLPredefMaps :: [String] -> PreDefMaps
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian MaedermakeOWLPredefMaps sl = preDefMaps sl "owl"
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian Maeder-- | sets the correct prefix for the predefined datatypes
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian MaedersetDatatypePrefix :: IRI -> IRI
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian MaedersetDatatypePrefix iri = case isDatatypeKeyAux iri of
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian Maeder (p, l) : _ -> setPrefix p $ mkQName l
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian Maeder _ -> error $ showQU iri ++ " is not a predefined datatype"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder-- | checks if the IRI is part of the built-in ones and puts the correct prefix
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedersetReservedPrefix :: IRI -> IRI
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedersetReservedPrefix iri = case namePrefix iri of
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder | isDatatypeKey iri -> setDatatypePrefix iri
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder | isThing iri || isPredefDataProp iri || isPredefOWLAnnoProp iri
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder || isPredefObjProp iri -> setPrefix "owl" iri
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder | isPredefRDFSAnnoProp iri -> setPrefix "rdfs" iri
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian MaederstripReservedPrefix :: IRI -> IRI
028f19cdb09d52bb2fd207399b6fa874540d1670Christian MaederstripReservedPrefix = mkQName . getPredefName
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder{- | returns the name of the predefined IRI (e.g <xsd:string> returns "string"
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder or <http://www.w3.org/2002/07/owl#real> returns "real") -}
028f19cdb09d52bb2fd207399b6fa874540d1670Christian MaedergetPredefName :: IRI -> String
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaedergetPredefName iri =
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder if namePrefix iri `elem` ["", "xsd", "rdf", "rdfs", "owl"]
09249711700a6acbc40a2e337688b434d7aafa28Christian Maeder then localPart iri
09249711700a6acbc40a2e337688b434d7aafa28Christian Maeder else case mapMaybe (`stripPrefix` showQU iri)
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder $ Map.elems predefPrefixes of
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder _ -> showQN iri
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder-- | Extracts Token from IRI
028f19cdb09d52bb2fd207399b6fa874540d1670Christian MaederuriToTok :: IRI -> Token
028f19cdb09d52bb2fd207399b6fa874540d1670Christian MaederuriToTok urI = mkSimpleId $ getPredefName urI
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder-- | Extracts Id from IRI
aaf68b27b802d3b9bf39202fa781478dcab8fde5Christian MaederuriToId :: IRI -> Id
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederuriToId = simpleIdToId . uriToTok
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder-- | Extracts Id from Entities
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian MaederentityToId :: Entity -> Id
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaederentityToId = uriToId . cutIRI
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian MaederprintDatatype :: IRI -> String
6cb518d88084543c13aa7e56db767c14ee97ab77Christian MaederprintDatatype dt = showQU $
6cb518d88084543c13aa7e56db767c14ee97ab77Christian Maeder if isDatatypeKey dt then stripReservedPrefix dt else dt
6cb518d88084543c13aa7e56db767c14ee97ab77Christian Maederdata DatatypeCat = OWL2Number | OWL2String | OWL2Bool | Other
6cb518d88084543c13aa7e56db767c14ee97ab77Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian MaedergetDatatypeCat :: IRI -> DatatypeCat
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian MaedergetDatatypeCat iri = case isDatatypeKey iri of
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder | checkPredef xsdBooleanMap iri -> OWL2Bool
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian Maeder | checkPredef xsdNumbersMap iri || checkPredef owlNumbersMap iri
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian Maeder -> OWL2Number
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder | checkPredef xsdStringsMap iri -> OWL2String
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian Maeder | otherwise -> Other
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian Maeder False -> Other
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian MaedermakeXsdMap :: [String] -> PreDefMaps
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian MaedermakeXsdMap sl = preDefMaps sl "xsd"
6cb518d88084543c13aa7e56db767c14ee97ab77Christian MaederxsdBooleanMap :: PreDefMaps
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian MaederxsdBooleanMap = makeXsdMap [booleanS]
6cb518d88084543c13aa7e56db767c14ee97ab77Christian MaederxsdNumbersMap :: PreDefMaps
8a6b503b50c0be589f12eb0d4ebeb4b4312fd491Christian MaederxsdNumbersMap = makeXsdMap xsdNumbers
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederxsdStringsMap :: PreDefMaps
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederxsdStringsMap = makeXsdMap xsdStrings
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian MaederfacetToIRI :: DatatypeFacet -> ConstrainingFacet
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederfacetToIRI = setPrefix "xsd" . mkQName . showFacet
6cb518d88084543c13aa7e56db767c14ee97ab77Christian Maeder-- * Cardinalities
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maederdata CardinalityType = MinCardinality | MaxCardinality | ExactCardinality
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
9c5b1136299d9052e4e995614a3a36a051a2682fChristian MaedershowCardinalityType :: CardinalityType -> String
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedershowCardinalityType ty = case ty of
ce3928e71520030ad0275b72050a8f4377f9313cChristian Maeder MinCardinality -> minS
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder MaxCardinality -> maxS
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ExactCardinality -> exactlyS
32a2f5f00ff72c095b39629101043db4407974f9Christian Maederdata Cardinality a b = Cardinality CardinalityType Int a (Maybe b)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
1090553a9231ceb536cb8007219c08be0c8c313dChristian Maederdata JunctionType = UnionOf | IntersectionOf
1090553a9231ceb536cb8007219c08be0c8c313dChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maedertype ConstrainingFacet = IRI
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maedertype RestrictionValue = Literal
011b7807145efa2af0c7470414a96e0133c26dbcChristian Maederdata Entity = Entity
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder { label :: Maybe String
011b7807145efa2af0c7470414a96e0133c26dbcChristian Maeder , entityKind :: EntityType
011b7807145efa2af0c7470414a96e0133c26dbcChristian Maeder , cutIRI :: IRI }
011b7807145efa2af0c7470414a96e0133c26dbcChristian Maeder deriving (Show, Typeable, Data)
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedermkEntity :: EntityType -> IRI -> Entity
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedermkEntity = Entity Nothing
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedermkEntityLbl :: String -> EntityType -> IRI -> Entity
120efeede54a5f7650cda8e91363bd6832eac9a9Christian MaedermkEntityLbl = Entity . Just
120efeede54a5f7650cda8e91363bd6832eac9a9Christian Maederinstance Ord Entity where
120efeede54a5f7650cda8e91363bd6832eac9a9Christian Maeder compare (Entity _ ek1 ir1) (Entity _ ek2 ir2) = compare (ek1, ir1) (ek2, ir2)
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maederinstance Eq Entity where
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder e1 == e2 = compare e1 e2 == EQ
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maederinstance GetRange Entity where
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder getRange = iriPos . cutIRI
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder rangeSpan = qNameRange . cutIRI
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maederdata EntityType =
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder | ObjectProperty
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder | DataProperty
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder | AnnotationProperty
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder | NamedIndividual
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder deriving (Enum, Bounded, Show, Read, Eq, Ord, Typeable, Data)
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedershowEntityType :: EntityType -> String
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaedershowEntityType e = case e of
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder Datatype -> datatypeC
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder Class -> classC
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ObjectProperty -> objectPropertyC
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder DataProperty -> dataPropertyC
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder AnnotationProperty -> annotationPropertyC
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder NamedIndividual -> individualC
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaederentityTypes :: [EntityType]
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaederentityTypes = [minBound .. maxBound]
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaederpairSymbols :: Entity -> Entity -> Result Entity -- TODO: improve!
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederpairSymbols (Entity lb1 k1 i1) (Entity lb2 k2 i2) =
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder if k1 /= k2 then
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder error "can't pair symbols of different kind"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder let rest x = drop 1 $ dropWhile (/= '#') x
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian Maeder pairLables lbl1 lbl2 = case (lbl1, lbl2) of
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maeder (Nothing, _) -> pairLables lbl2 lbl1
62fb92b09f732b770317b46a793b60b960d5f481Christian Maeder (Just l1, Just l2) | l1 /= l2 -> Just $ l1 ++ ", " ++ l2
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maeder pairIRIs (QN p1 l1 t1 _e1 r1)
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maeder (QN _p2 l2 _t2 _e2 _r2) =
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder { namePrefix = p1
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder , localPart = if rest l1 == rest l2 then l1 else l1 ++ "_" ++ rest l2
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian Maeder , iriType = t1
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian Maeder , expandedIRI = ""
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian Maeder , iriPos = r1
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian Maeder return $ Entity (pairLables lb1 lb2) k1 $ pairIRIs i1 i2
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maederdata TypedOrUntyped = Typed Datatype | Untyped (Maybe LanguageTag)
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maederdata Literal = Literal LexicalForm TypedOrUntyped | NumberLit FloatLit
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maeder-- | non-negative integers given by the sequence of digits
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maederdata NNInt = NNInt [Int] deriving (Eq, Ord, Typeable, Data)
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maederinstance Show NNInt where
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder show (NNInt l) = map intToDigit l
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian MaederzeroNNInt :: NNInt
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaederzeroNNInt = NNInt []
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaederisZeroNNInt :: NNInt -> Bool
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaederisZeroNNInt (NNInt l) = null l
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maederdata IntLit = IntLit
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian Maeder { absInt :: NNInt
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian Maeder , isNegInt :: Bool }
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian Maeder deriving (Eq, Ord, Typeable, Data)
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian Maederinstance Show IntLit where
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian Maeder show (IntLit n b) = (if b then ('-' :) else id) $ show n
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian MaederzeroInt :: IntLit
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian MaederzeroInt = IntLit zeroNNInt False
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian MaederisZeroInt :: IntLit -> Bool
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian MaederisZeroInt (IntLit n _) = isZeroNNInt n
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaedernegNNInt :: Bool -> NNInt -> IntLit
48c4688439e0aade4faeebf25ca8b16d661e47afChristian MaedernegNNInt b n = IntLit n b
bf4263f9dab040818efc7a67172aab8f32218061Christian MaedernegInt :: IntLit -> IntLit
32a2f5f00ff72c095b39629101043db4407974f9Christian MaedernegInt (IntLit n b) = IntLit n $ not b
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederdata DecLit = DecLit
df33a9af92444f63ad545da6bb326aac9284318eChristian Maeder { truncDec :: IntLit
749074bf849727439f584139415f6a985a8aa875Christian Maeder , fracDec :: NNInt }
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder deriving (Eq, Ord, Typeable, Data)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederinstance Show DecLit where
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder show (DecLit t f) = show t
ce3928e71520030ad0275b72050a8f4377f9313cChristian Maeder ++ if isZeroNNInt f then "" else
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederisDecInt :: DecLit -> Bool
6cb518d88084543c13aa7e56db767c14ee97ab77Christian MaederisDecInt = isZeroNNInt . fracDec
f8a1ab8012a1f36060d6ce9b63399fa4a8a2981cChristian MaedernegDec :: Bool -> DecLit -> DecLit
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedernegDec b (DecLit t f) = DecLit (if b then negInt t else t) f
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederdata FloatLit = FloatLit
f875f7eebac7f69bf9da98c93479a542d0a8056fChristian Maeder { floatBase :: DecLit
99edc5256de959957a8c27b05ae4ad4f0572233dChristian Maeder , floatExp :: IntLit }
120efeede54a5f7650cda8e91363bd6832eac9a9Christian Maeder deriving (Eq, Ord, Typeable, Data)
120efeede54a5f7650cda8e91363bd6832eac9a9Christian Maederinstance Show FloatLit where
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder show (FloatLit b e) = show b
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder ++ if isZeroInt e then "" else
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder 'E' : show e ++ "F"
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederisFloatDec :: FloatLit -> Bool
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederisFloatDec = isZeroInt . floatExp
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaederisFloatInt :: FloatLit -> Bool
a59f2017dfc311ece7afcea3e8a3ceceac77ba5aChristian MaederisFloatInt f = isFloatDec f && isDecInt (floatBase f)
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian MaederfloatToInt :: FloatLit -> IntLit
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederfloatToInt = truncDec . floatBase
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaederintToDec :: IntLit -> DecLit
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaederintToDec i = DecLit i zeroNNInt
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederdecToFloat :: DecLit -> FloatLit
2f6227e9ec96ca827cc40078916f18d54a075136Christian MaederdecToFloat d = FloatLit d zeroInt
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian MaederintToFloat :: IntLit -> FloatLit
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian MaederintToFloat = decToFloat . intToDec
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian MaederabInt :: IntLit -> IntLit
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian MaederabInt int = int {isNegInt = False}
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederabDec :: DecLit -> DecLit
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederabDec dec = dec {truncDec = abInt $ truncDec dec}
48c4688439e0aade4faeebf25ca8b16d661e47afChristian MaederabFloat :: FloatLit -> FloatLit
48c4688439e0aade4faeebf25ca8b16d661e47afChristian MaederabFloat f = f {floatBase = abDec $ floatBase f}
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederisNegDec :: DecLit -> Bool
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaederisNegDec d = isNegInt $ truncDec d
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian MaedernumberName :: FloatLit -> String
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder | isFloatInt f = integerS
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder | isFloatDec f = decimalS
6cb518d88084543c13aa7e56db767c14ee97ab77Christian Maeder | otherwise = floatS
54b698a84a1686b828c99d839fc671942b817534Christian MaedercTypeS :: String
d92635f998347112e5d5803301c2abfe7832ab65Christian Maeder-- * PROPERTY EXPRESSIONS
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maedertype InverseObjectProperty = ObjectPropertyExpression
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maederdata ObjectPropertyExpression = ObjectProp ObjectProperty
8452387b4c54b8dd36c012b216e0b0c5004ca6f1Christian Maeder | ObjectInverseOf InverseObjectProperty
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
24f79601ad5e42ce74f4152a36aad257d7c4d7b5Christian MaederobjPropToIRI :: ObjectPropertyExpression -> Individual
62fb92b09f732b770317b46a793b60b960d5f481Christian MaederobjPropToIRI opExp = case opExp of
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder ObjectProp u -> u
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ObjectInverseOf objProp -> objPropToIRI objProp
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maedertype DataPropertyExpression = DataProperty
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder-- * DATA RANGES
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederdata DataRange =
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder DataType Datatype [(ConstrainingFacet, RestrictionValue)]
99edc5256de959957a8c27b05ae4ad4f0572233dChristian Maeder | DataJunction JunctionType [DataRange]
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder | DataComplementOf DataRange
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder | DataOneOf [Literal]
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder-- * CLASS EXPERSSIONS
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederdata ClassExpression =
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder Expression Class
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder | ObjectJunction JunctionType [ClassExpression]
99edc5256de959957a8c27b05ae4ad4f0572233dChristian Maeder | ObjectComplementOf ClassExpression
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder | ObjectOneOf [Individual]
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder | ObjectValuesFrom QuantifierType ObjectPropertyExpression ClassExpression
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder | ObjectHasValue ObjectPropertyExpression Individual
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder | ObjectHasSelf ObjectPropertyExpression
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder | ObjectCardinality (Cardinality ObjectPropertyExpression ClassExpression)
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maeder | DataValuesFrom QuantifierType DataPropertyExpression DataRange
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder | DataHasValue DataPropertyExpression Literal
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder | DataCardinality (Cardinality DataPropertyExpression DataRange)
341d00318de2d0ea9b6f0ab43f7e4d10ee4fb454Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder-- * ANNOTATIONS
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maederdata Annotation = Annotation [Annotation] AnnotationProperty AnnotationValue
2f6227e9ec96ca827cc40078916f18d54a075136Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)