module Swish.RDF.BuiltIn.Rules
( findRDFOpenVarBindingModifier
, rdfRulesetMap
, allRulesets, allDatatypeRulesets
)
where
import Swish.Datatype (typeRules, typeMkModifiers)
import Swish.Namespace (ScopedName)
import Swish.Ruleset (getRulesetNamespace)
import Swish.VarBinding (openVbmName, nullVarBindingModify, makeVarFilterModify, varFilterEQ, varFilterNE)
import Swish.RDF.BuiltIn.Datatypes (allDatatypes)
import Swish.RDF.Ruleset (RDFRuleset, RDFRulesetMap)
import Swish.RDF.ProofContext (rulesetRDF, rulesetRDFS, rulesetRDFD)
import Swish.RDF.VarBinding
( RDFOpenVarBindingModify
, rdfVarBindingUriRef, rdfVarBindingBlank
, rdfVarBindingLiteral
, rdfVarBindingUntypedLiteral, rdfVarBindingTypedLiteral
, rdfVarBindingXMLLiteral, rdfVarBindingDatatyped
, rdfVarBindingMemberProp
)
import qualified Data.Map as M
rdfVarBindingFilters :: [RDFOpenVarBindingModify]
rdfVarBindingFilters :: [RDFOpenVarBindingModify]
rdfVarBindingFilters =
[ forall {t} {a} {b}.
(t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter1 RDFLabel -> RDFVarBindingFilter
rdfVarBindingUriRef
, forall {t} {a} {b}.
(t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter1 RDFLabel -> RDFVarBindingFilter
rdfVarBindingBlank
, forall {t} {a} {b}.
(t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter1 RDFLabel -> RDFVarBindingFilter
rdfVarBindingLiteral
, forall {t} {a} {b}.
(t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter1 RDFLabel -> RDFVarBindingFilter
rdfVarBindingUntypedLiteral
, forall {t} {a} {b}.
(t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter1 RDFLabel -> RDFVarBindingFilter
rdfVarBindingTypedLiteral
, forall {t} {a} {b}.
(t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter1 RDFLabel -> RDFVarBindingFilter
rdfVarBindingXMLLiteral
, forall {t} {a} {b}.
(t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter1 RDFLabel -> RDFVarBindingFilter
rdfVarBindingMemberProp
, forall {t} {a} {b}.
(t -> t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter2 RDFLabel -> RDFLabel -> RDFVarBindingFilter
rdfVarBindingDatatyped
, forall {t} {a} {b}.
(t -> t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter2 forall b a. Eq b => a -> a -> VarBindingFilter a b
varFilterEQ
, forall {t} {a} {b}.
(t -> t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter2 forall b a. Eq b => a -> a -> VarBindingFilter a b
varFilterNE
]
where
filter1 :: (t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter1 t -> VarBindingFilter a b
f [t]
lbs = forall a b. VarBindingFilter a b -> VarBindingModify a b
makeVarFilterModify forall a b. (a -> b) -> a -> b
$ t -> VarBindingFilter a b
f (forall a. [a] -> a
head [t]
lbs)
filter2 :: (t -> t -> VarBindingFilter a b) -> [t] -> VarBindingModify a b
filter2 t -> t -> VarBindingFilter a b
f [t]
lbs = forall a b. VarBindingFilter a b -> VarBindingModify a b
makeVarFilterModify forall a b. (a -> b) -> a -> b
$ t -> t -> VarBindingFilter a b
f (forall a. [a] -> a
head [t]
lbs) ([t]
lbs forall a. [a] -> Int -> a
!! Int
1)
rdfVarBindingModifiers :: [RDFOpenVarBindingModify]
rdfVarBindingModifiers :: [RDFOpenVarBindingModify]
rdfVarBindingModifiers =
[ forall a b. OpenVarBindingModify a b
nullVarBindingModify
]
allOpenVarBindingModify :: [RDFOpenVarBindingModify]
allOpenVarBindingModify :: [RDFOpenVarBindingModify]
allOpenVarBindingModify =
[RDFOpenVarBindingModify]
rdfVarBindingFilters forall a. [a] -> [a] -> [a]
++
[RDFOpenVarBindingModify]
rdfVarBindingModifiers forall a. [a] -> [a] -> [a]
++
[RDFOpenVarBindingModify]
dtsVarBindingModifiers
dtsVarBindingModifiers :: [RDFOpenVarBindingModify]
dtsVarBindingModifiers :: [RDFOpenVarBindingModify]
dtsVarBindingModifiers = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall ex lb vn. Datatype ex lb vn -> [OpenVarBindingModify lb vn]
typeMkModifiers [RDFDatatype]
allDatatypes
findRDFOpenVarBindingModifier :: ScopedName -> Maybe RDFOpenVarBindingModify
findRDFOpenVarBindingModifier :: ScopedName -> Maybe RDFOpenVarBindingModify
findRDFOpenVarBindingModifier ScopedName
nam =
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup ScopedName
nam forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => [(k, a)] -> Map k a
M.fromList forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (\RDFOpenVarBindingModify
ovbm -> (forall lb vn. OpenVarBindingModify lb vn -> ScopedName
openVbmName RDFOpenVarBindingModify
ovbm, RDFOpenVarBindingModify
ovbm))
[RDFOpenVarBindingModify]
allOpenVarBindingModify
rdfRulesetMap :: RDFRulesetMap
rdfRulesetMap :: RDFRulesetMap
rdfRulesetMap = forall k a. Ord k => [(k, a)] -> Map k a
M.fromList forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (\Ruleset RDFGraph
r -> (forall ex. Ruleset ex -> Namespace
getRulesetNamespace Ruleset RDFGraph
r, Ruleset RDFGraph
r)) [Ruleset RDFGraph]
allRulesets
allRulesets :: [RDFRuleset]
allRulesets :: [Ruleset RDFGraph]
allRulesets =
[ Ruleset RDFGraph
rulesetRDF
, Ruleset RDFGraph
rulesetRDFS
, Ruleset RDFGraph
rulesetRDFD
]
forall a. [a] -> [a] -> [a]
++ [Ruleset RDFGraph]
allDatatypeRulesets
allDatatypeRulesets :: [RDFRuleset]
allDatatypeRulesets :: [Ruleset RDFGraph]
allDatatypeRulesets = forall a b. (a -> b) -> [a] -> [b]
map forall ex lb vn. Datatype ex lb vn -> Ruleset ex
typeRules [RDFDatatype]
allDatatypes