{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Swish.RDF.Datatype.XSD.Integer
( rdfDatatypeXsdInteger
, rdfDatatypeValXsdInteger
, typeNameXsdInteger, namespaceXsdInteger
, axiomsXsdInteger, rulesXsdInteger
)
where
import Swish.Datatype
( Datatype(..)
, DatatypeVal(..)
, DatatypeRel(..), DatatypeRelPr
, altArgs
, UnaryFnTable, unaryFnApp
, BinaryFnTable, binaryFnApp
, BinMaybeFnTable, binMaybeFnApp
, DatatypeMod(..)
, makeVmod11inv, makeVmod11
, makeVmod21inv, makeVmod21
, makeVmod20
, makeVmod22
)
import Swish.Namespace (Namespace, ScopedName)
import Swish.Namespace (namespaceToBuilder, makeNSScopedName)
import Swish.QName (LName)
import Swish.Ruleset (makeRuleset)
import Swish.RDF.Datatype (RDFDatatype, RDFDatatypeVal, RDFDatatypeMod)
import Swish.RDF.Datatype (makeRdfDtOpenVarBindingModifiers)
import Swish.RDF.Datatype.XSD.MapInteger (mapXsdInteger)
import Swish.RDF.Ruleset (RDFFormula, RDFRule, RDFRuleset)
import Swish.RDF.Ruleset (makeRDFGraphFromN3Builder, makeRDFFormula)
import Swish.RDF.ClassRestrictionRule (makeRDFDatatypeRestrictionRules)
import Swish.RDF.Vocabulary
( namespaceRDF
, namespaceRDFS
, namespaceRDFD
, namespaceXSD
, namespaceXsdType
)
import Data.Maybe (maybeToList)
#if (!defined(__GLASGOW_HASKELL__)) || (__GLASGOW_HASKELL__ < 710)
import Data.Monoid (Monoid(..))
#endif
import qualified Data.Text.Lazy.Builder as B
nameXsdInteger :: LName
nameXsdInteger :: LName
nameXsdInteger = LName
"integer"
typeNameXsdInteger :: ScopedName
typeNameXsdInteger :: ScopedName
typeNameXsdInteger = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXSD LName
nameXsdInteger
namespaceXsdInteger :: Namespace
namespaceXsdInteger :: Namespace
namespaceXsdInteger = LName -> Namespace
namespaceXsdType LName
nameXsdInteger
rdfDatatypeXsdInteger :: RDFDatatype
rdfDatatypeXsdInteger :: RDFDatatype
rdfDatatypeXsdInteger = DatatypeVal RDFGraph Integer RDFLabel RDFLabel -> RDFDatatype
forall ex lb vn vt. DatatypeVal ex vt lb vn -> Datatype ex lb vn
Datatype DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger
intPower :: Integer -> Integer -> Maybe Integer
intPower :: Integer -> Integer -> Maybe Integer
intPower Integer
a Integer
b = if Integer
b Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
0 then Maybe Integer
forall a. Maybe a
Nothing else Integer -> Maybe Integer
forall a. a -> Maybe a
Just (Integer -> Integer -> Integer
forall a t. (Integral a, Num t) => t -> a -> t
intPower1 Integer
a Integer
b)
where
intPower1 :: t -> a -> t
intPower1 t
x a
y
| a
q a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
1 = t
atopsqt -> t -> t
forall a. Num a => a -> a -> a
*t
x
| a
p a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
0 = t
1
| Bool
otherwise = t
atopsq
where
(a
p,a
q) = a
y a -> a -> (a, a)
forall a. Integral a => a -> a -> (a, a)
`divMod` a
2
atop :: t
atop = t -> a -> t
intPower1 t
x a
p
atopsq :: t
atopsq = t
atopt -> t -> t
forall a. Num a => a -> a -> a
*t
atop
rdfDatatypeValXsdInteger :: RDFDatatypeVal Integer
rdfDatatypeValXsdInteger :: DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger = DatatypeVal :: forall ex vt lb vn.
ScopedName
-> Ruleset ex
-> (ex -> [Rule ex])
-> [OpenVarBindingModify lb vn]
-> DatatypeMap vt
-> [DatatypeRel vt]
-> [DatatypeMod vt lb vn]
-> DatatypeVal ex vt lb vn
DatatypeVal
{ tvalName :: ScopedName
tvalName = ScopedName
typeNameXsdInteger
, tvalRules :: Ruleset RDFGraph
tvalRules = Ruleset RDFGraph
rdfRulesetXsdInteger
, tvalMkRules :: RDFGraph -> [Rule RDFGraph]
tvalMkRules = DatatypeVal RDFGraph Integer RDFLabel RDFLabel
-> RDFGraph -> [Rule RDFGraph]
forall vt. RDFDatatypeVal vt -> RDFGraph -> [Rule RDFGraph]
makeRDFDatatypeRestrictionRules DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger
, tvalMkMods :: [OpenVarBindingModify RDFLabel RDFLabel]
tvalMkMods = DatatypeVal RDFGraph Integer RDFLabel RDFLabel
-> [OpenVarBindingModify RDFLabel RDFLabel]
forall vt.
RDFDatatypeVal vt -> [OpenVarBindingModify RDFLabel RDFLabel]
makeRdfDtOpenVarBindingModifiers DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger
, tvalMap :: DatatypeMap Integer
tvalMap = DatatypeMap Integer
mapXsdInteger
, tvalRel :: [DatatypeRel Integer]
tvalRel = [DatatypeRel Integer]
relXsdInteger
, tvalMod :: [DatatypeMod Integer RDFLabel RDFLabel]
tvalMod = [DatatypeMod Integer RDFLabel RDFLabel]
modXsdInteger
}
relXsdInteger :: [DatatypeRel Integer]
relXsdInteger :: [DatatypeRel Integer]
relXsdInteger =
[ DatatypeRel Integer
relXsdIntegerAbs
, DatatypeRel Integer
relXsdIntegerNeg
, DatatypeRel Integer
relXsdIntegerSum
, DatatypeRel Integer
relXsdIntegerDiff
, DatatypeRel Integer
relXsdIntegerProd
, DatatypeRel Integer
relXsdIntegerDivMod
, DatatypeRel Integer
relXsdIntegerPower
, DatatypeRel Integer
relXsdIntegerEq
, DatatypeRel Integer
relXsdIntegerNe
, DatatypeRel Integer
relXsdIntegerLt
, DatatypeRel Integer
relXsdIntegerLe
, DatatypeRel Integer
relXsdIntegerGt
, DatatypeRel Integer
relXsdIntegerGe
]
mkIntRel2 ::
LName -> DatatypeRelPr Integer -> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 :: LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
nam DatatypeRelPr Integer
pr UnaryFnTable Integer
fns = DatatypeRel :: forall vt. ScopedName -> DatatypeRelFn vt -> DatatypeRel vt
DatatypeRel
{ dtRelName :: ScopedName
dtRelName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
nam
, dtRelFunc :: DatatypeRelFn Integer
dtRelFunc = DatatypeRelPr Integer
-> UnaryFnTable Integer
-> ((Integer -> Bool)
-> UnaryFnDescr Integer -> [Maybe Integer] -> Maybe [Integer])
-> DatatypeRelFn Integer
forall vt b.
Eq vt =>
DatatypeRelPr vt
-> [(vt -> Bool, [b])]
-> ((vt -> Bool) -> b -> [Maybe vt] -> Maybe [vt])
-> DatatypeRelFn vt
altArgs DatatypeRelPr Integer
pr UnaryFnTable Integer
fns (Integer -> Bool)
-> UnaryFnDescr Integer -> [Maybe Integer] -> Maybe [Integer]
forall a. UnaryFnApply a
unaryFnApp
}
mkIntRel3 ::
LName -> DatatypeRelPr Integer -> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 :: LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
nam DatatypeRelPr Integer
pr BinaryFnTable Integer
fns = DatatypeRel :: forall vt. ScopedName -> DatatypeRelFn vt -> DatatypeRel vt
DatatypeRel
{ dtRelName :: ScopedName
dtRelName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
nam
, dtRelFunc :: DatatypeRelFn Integer
dtRelFunc = DatatypeRelPr Integer
-> BinaryFnTable Integer
-> ((Integer -> Bool)
-> BinaryFnDescr Integer -> [Maybe Integer] -> Maybe [Integer])
-> DatatypeRelFn Integer
forall vt b.
Eq vt =>
DatatypeRelPr vt
-> [(vt -> Bool, [b])]
-> ((vt -> Bool) -> b -> [Maybe vt] -> Maybe [vt])
-> DatatypeRelFn vt
altArgs DatatypeRelPr Integer
pr BinaryFnTable Integer
fns (Integer -> Bool)
-> BinaryFnDescr Integer -> [Maybe Integer] -> Maybe [Integer]
forall a. BinaryFnApply a
binaryFnApp
}
mkIntRel3maybe ::
LName -> DatatypeRelPr Integer -> BinMaybeFnTable Integer
-> DatatypeRel Integer
mkIntRel3maybe :: LName
-> DatatypeRelPr Integer
-> BinMaybeFnTable Integer
-> DatatypeRel Integer
mkIntRel3maybe LName
nam DatatypeRelPr Integer
pr BinMaybeFnTable Integer
fns = DatatypeRel :: forall vt. ScopedName -> DatatypeRelFn vt -> DatatypeRel vt
DatatypeRel
{ dtRelName :: ScopedName
dtRelName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
nam
, dtRelFunc :: DatatypeRelFn Integer
dtRelFunc = DatatypeRelPr Integer
-> BinMaybeFnTable Integer
-> ((Integer -> Bool)
-> BinMaybeFnDescr Integer -> [Maybe Integer] -> Maybe [Integer])
-> DatatypeRelFn Integer
forall vt b.
Eq vt =>
DatatypeRelPr vt
-> [(vt -> Bool, [b])]
-> ((vt -> Bool) -> b -> [Maybe vt] -> Maybe [vt])
-> DatatypeRelFn vt
altArgs DatatypeRelPr Integer
pr BinMaybeFnTable Integer
fns (Integer -> Bool)
-> BinMaybeFnDescr Integer -> [Maybe Integer] -> Maybe [Integer]
forall a. BinMaybeFnApply a
binMaybeFnApp
}
relXsdIntegerAbs :: DatatypeRel Integer
relXsdIntegerAbs :: DatatypeRel Integer
relXsdIntegerAbs = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"abs" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
[ ( (Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>=Integer
0), [ (Integer -> Integer
forall a. Num a => a -> a
abs,Int
1) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer
forall a. a -> a
id,Int
0), (Integer -> Integer
forall a. Num a => a -> a
negate,Int
0) ] )
]
relXsdIntegerNeg :: DatatypeRel Integer
relXsdIntegerNeg :: DatatypeRel Integer
relXsdIntegerNeg = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"neg" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
[ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer
forall a. Num a => a -> a
negate,Int
1) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer
forall a. Num a => a -> a
negate,Int
0) ] )
]
relXsdIntegerSum :: DatatypeRel Integer
relXsdIntegerSum :: DatatypeRel Integer
relXsdIntegerSum = LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
"sum" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
[ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(+),Int
1,Int
2) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((-),Int
0,Int
2) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((-),Int
0,Int
1) ] )
]
relXsdIntegerDiff :: DatatypeRel Integer
relXsdIntegerDiff :: DatatypeRel Integer
relXsdIntegerDiff = LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
"diff" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
[ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((-),Int
1,Int
2) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(+),Int
0,Int
2) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((-),Int
1,Int
0) ] )
]
relXsdIntegerProd :: DatatypeRel Integer
relXsdIntegerProd :: DatatypeRel Integer
relXsdIntegerProd = LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
"prod" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
[ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(*),Int
1,Int
2) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
div,Int
0,Int
2) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
div,Int
0,Int
1) ] )
]
relXsdIntegerDivMod :: DatatypeRel Integer
relXsdIntegerDivMod :: DatatypeRel Integer
relXsdIntegerDivMod = LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
"divmod" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
[ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
div,Int
2,Int
3) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
mod,Int
2,Int
3) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ] )
]
c2 :: (b -> c) -> (a -> d -> b) -> a -> d -> c
c2 :: (b -> c) -> (a -> d -> b) -> a -> d -> c
c2 = ((d -> b) -> d -> c) -> (a -> d -> b) -> a -> d -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) (((d -> b) -> d -> c) -> (a -> d -> b) -> a -> d -> c)
-> ((b -> c) -> (d -> b) -> d -> c)
-> (b -> c)
-> (a -> d -> b)
-> a
-> d
-> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> c) -> (d -> b) -> d -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.)
relXsdIntegerPower :: DatatypeRel Integer
relXsdIntegerPower :: DatatypeRel Integer
relXsdIntegerPower = LName
-> DatatypeRelPr Integer
-> BinMaybeFnTable Integer
-> DatatypeRel Integer
mkIntRel3maybe LName
"power" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
[ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((Integer -> [Integer]) -> Maybe Integer -> Maybe [Integer]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Integer -> [Integer] -> [Integer]
forall a. a -> [a] -> [a]
:[]) (Maybe Integer -> Maybe [Integer])
-> (Integer -> Integer -> Maybe Integer)
-> Integer
-> Integer
-> Maybe [Integer]
forall b c a d. (b -> c) -> (a -> d -> b) -> a -> d -> c
`c2` Integer -> Integer -> Maybe Integer
intPower,Int
1,Int
2) ] )
, ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ] )
, ( (Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>=Integer
0), [ ] )
]
liftL2 :: (a->a->Bool) -> ([a]->a) -> ([a]->a) -> [a] -> Bool
liftL2 :: (a -> a -> Bool) -> ([a] -> a) -> ([a] -> a) -> [a] -> Bool
liftL2 a -> a -> Bool
p [a] -> a
i1 [a] -> a
i2 [a]
as = a -> a -> Bool
p ([a] -> a
i1 [a]
as) ([a] -> a
i2 [a]
as)
lcomp :: (a->a->Bool) -> [a] -> Bool
lcomp :: (a -> a -> Bool) -> [a] -> Bool
lcomp a -> a -> Bool
p = (a -> a -> Bool) -> ([a] -> a) -> ([a] -> a) -> [a] -> Bool
forall a.
(a -> a -> Bool) -> ([a] -> a) -> ([a] -> a) -> [a] -> Bool
liftL2 a -> a -> Bool
p [a] -> a
forall a. [a] -> a
head ([a] -> a
forall a. [a] -> a
head ([a] -> a) -> ([a] -> [a]) -> [a] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a]
forall a. [a] -> [a]
tail)
relXsdIntegerEq :: DatatypeRel Integer
relXsdIntegerEq :: DatatypeRel Integer
relXsdIntegerEq = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"eq" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(==))
( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )
relXsdIntegerNe :: DatatypeRel Integer
relXsdIntegerNe :: DatatypeRel Integer
relXsdIntegerNe = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"ne" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(/=))
( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )
relXsdIntegerLt :: DatatypeRel Integer
relXsdIntegerLt :: DatatypeRel Integer
relXsdIntegerLt = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"lt" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<))
( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )
relXsdIntegerLe :: DatatypeRel Integer
relXsdIntegerLe :: DatatypeRel Integer
relXsdIntegerLe = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"le" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<=))
( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )
relXsdIntegerGt :: DatatypeRel Integer
relXsdIntegerGt :: DatatypeRel Integer
relXsdIntegerGt = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"gt" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>))
( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )
relXsdIntegerGe :: DatatypeRel Integer
relXsdIntegerGe :: DatatypeRel Integer
relXsdIntegerGe = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"ge" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>=))
( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )
modXsdInteger :: [RDFDatatypeMod Integer]
modXsdInteger :: [DatatypeMod Integer RDFLabel RDFLabel]
modXsdInteger =
[ DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerAbs
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerNeg
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerSum
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerDiff
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerProd
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerDivMod
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerPower
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerEq
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerNe
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerLt
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerLe
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerGt
, DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerGe
]
modXsdIntegerAbs :: RDFDatatypeMod Integer
modXsdIntegerAbs :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerAbs = DatatypeMod :: forall vt lb vn.
ScopedName
-> [ModifierFn vt] -> ApplyModifier lb vn -> DatatypeMod vt lb vn
DatatypeMod
{ dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"abs"
, dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall a. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f1 ]
, dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod11
}
where
f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a -> a
forall a. Num a => a -> a
abs a
v2 then [a]
vs else []
f0 [a]
_ = []
f1 :: [a] -> [a]
f1 [a
v2] = [a -> a
forall a. Num a => a -> a
abs a
v2]
f1 [a]
_ = []
modXsdIntegerNeg :: RDFDatatypeMod Integer
modXsdIntegerNeg :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerNeg = DatatypeMod :: forall vt lb vn.
ScopedName
-> [ModifierFn vt] -> ApplyModifier lb vn -> DatatypeMod vt lb vn
DatatypeMod
{ dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"neg"
, dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall a. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f1, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f1 ]
, dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod11inv
}
where
f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a -> a
forall a. Num a => a -> a
negate a
v2 then [a]
vs else []
f0 [a]
_ = []
f1 :: [a] -> [a]
f1 [a
vi] = [-a
vi]
f1 [a]
_ = []
modXsdIntegerSum :: RDFDatatypeMod Integer
modXsdIntegerSum :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerSum = DatatypeMod :: forall vt lb vn.
ScopedName
-> [ModifierFn vt] -> ApplyModifier lb vn -> DatatypeMod vt lb vn
DatatypeMod
{ dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"sum"
, dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall a. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f1, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f2, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f2 ]
, dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod21inv
}
where
f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2,a
v3] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
v2a -> a -> a
forall a. Num a => a -> a -> a
+a
v3 then [a]
vs else []
f0 [a]
_ = []
f1 :: [a] -> [a]
f1 [a
v2,a
v3] = [a
v2a -> a -> a
forall a. Num a => a -> a -> a
+a
v3]
f1 [a]
_ = []
f2 :: [a] -> [a]
f2 [a
v1,a
vi] = [a
v1a -> a -> a
forall a. Num a => a -> a -> a
-a
vi]
f2 [a]
_ = []
modXsdIntegerDiff :: RDFDatatypeMod Integer
modXsdIntegerDiff :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerDiff = DatatypeMod :: forall vt lb vn.
ScopedName
-> [ModifierFn vt] -> ApplyModifier lb vn -> DatatypeMod vt lb vn
DatatypeMod
{ dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"diff"
, dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall a. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f1, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f2, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f3 ]
, dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod21inv
}
where
f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2,a
v3] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
v2a -> a -> a
forall a. Num a => a -> a -> a
-a
v3 then [a]
vs else []
f0 [a]
_ = []
f1 :: [a] -> [a]
f1 [a
v2,a
v3] = [a
v2a -> a -> a
forall a. Num a => a -> a -> a
-a
v3]
f1 [a]
_ = []
f2 :: [a] -> [a]
f2 [a
v1,a
v3] = [a
v1a -> a -> a
forall a. Num a => a -> a -> a
+a
v3]
f2 [a]
_ = []
f3 :: [a] -> [a]
f3 [a
v1,a
v2] = [a
v2a -> a -> a
forall a. Num a => a -> a -> a
-a
v1]
f3 [a]
_ = []
modXsdIntegerProd :: RDFDatatypeMod Integer
modXsdIntegerProd :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerProd = DatatypeMod :: forall vt lb vn.
ScopedName
-> [ModifierFn vt] -> ApplyModifier lb vn -> DatatypeMod vt lb vn
DatatypeMod
{ dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"prod"
, dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall a. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall a. Num a => [a] -> [a]
f1, [Integer] -> [Integer]
forall a. Integral a => [a] -> [a]
f2, [Integer] -> [Integer]
forall a. Integral a => [a] -> [a]
f2 ]
, dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod21inv
}
where
f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2,a
v3] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
v2a -> a -> a
forall a. Num a => a -> a -> a
*a
v3 then [a]
vs else []
f0 [a]
_ = []
f1 :: [a] -> [a]
f1 [a
v2,a
v3] = [a
v2a -> a -> a
forall a. Num a => a -> a -> a
*a
v3]
f1 [a]
_ = []
f2 :: [a] -> [a]
f2 [a
v1,a
vi] = [a
q | a
r a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
0]
where (a
q,a
r) = a -> a -> (a, a)
forall a. Integral a => a -> a -> (a, a)
quotRem a
v1 a
vi
f2 [a]
_ = []
modXsdIntegerDivMod :: RDFDatatypeMod Integer
modXsdIntegerDivMod :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerDivMod = DatatypeMod :: forall vt lb vn.
ScopedName
-> [ModifierFn vt] -> ApplyModifier lb vn -> DatatypeMod vt lb vn
DatatypeMod
{ dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"divmod"
, dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall a. Integral a => [a] -> [a]
f0, [Integer] -> [Integer]
forall a. Integral a => [a] -> [a]
f1 ]
, dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod22
}
where
f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2,a
v3,a
v4] = if (a
v1,a
v2) (a, a) -> (a, a) -> Bool
forall a. Eq a => a -> a -> Bool
== a -> a -> (a, a)
forall a. Integral a => a -> a -> (a, a)
divMod a
v3 a
v4 then [a]
vs else []
f0 [a]
_ = []
f1 :: [a] -> [a]
f1 [a
v3,a
v4] = [a
v1,a
v2] where (a
v1,a
v2) = a -> a -> (a, a)
forall a. Integral a => a -> a -> (a, a)
divMod a
v3 a
v4
f1 [a]
_ = []
modXsdIntegerPower :: RDFDatatypeMod Integer
modXsdIntegerPower :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerPower = DatatypeMod :: forall vt lb vn.
ScopedName
-> [ModifierFn vt] -> ApplyModifier lb vn -> DatatypeMod vt lb vn
DatatypeMod
{ dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"power"
, dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
f0, [Integer] -> [Integer]
f1 ]
, dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod21
}
where
f0 :: [Integer] -> [Integer]
f0 vs :: [Integer]
vs@[Integer
v1,Integer
v2,Integer
v3] = if Integer -> Maybe Integer
forall a. a -> Maybe a
Just Integer
v1 Maybe Integer -> Maybe Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer -> Integer -> Maybe Integer
intPower Integer
v2 Integer
v3 then [Integer]
vs else []
f0 [Integer]
_ = []
f1 :: [Integer] -> [Integer]
f1 [Integer
v2,Integer
v3] = Maybe Integer -> [Integer]
forall a. Maybe a -> [a]
maybeToList (Integer -> Integer -> Maybe Integer
intPower Integer
v2 Integer
v3)
f1 [Integer]
_ = []
modXsdIntegerEq, modXsdIntegerNe, modXsdIntegerLt, modXsdIntegerLe, modXsdIntegerGt, modXsdIntegerGe :: RDFDatatypeMod Integer
modXsdIntegerEq :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerEq = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"eq" Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(==)
modXsdIntegerNe :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerNe = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"ne" Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(/=)
modXsdIntegerLt :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerLt = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"lt" Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<)
modXsdIntegerLe :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerLe = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"le" Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<=)
modXsdIntegerGt :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerGt = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"gt" Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>)
modXsdIntegerGe :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerGe = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"ge" Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>=)
modXsdIntegerCompare ::
LName -> (Integer->Integer->Bool) -> RDFDatatypeMod Integer
modXsdIntegerCompare :: LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
nam Integer -> Integer -> Bool
rel = DatatypeMod :: forall vt lb vn.
ScopedName
-> [ModifierFn vt] -> ApplyModifier lb vn -> DatatypeMod vt lb vn
DatatypeMod
{ dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
nam
, dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
f0 ]
, dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn.
(Eq lb, Show lb, Eq vn, Show vn) =>
ApplyModifier lb vn
makeVmod20
}
where
f0 :: [Integer] -> [Integer]
f0 vs :: [Integer]
vs@[Integer
v1,Integer
v2] = if Integer -> Integer -> Bool
rel Integer
v1 Integer
v2 then [Integer]
vs else []
f0 [Integer]
_ = []
rdfRulesetXsdInteger :: RDFRuleset
rdfRulesetXsdInteger :: Ruleset RDFGraph
rdfRulesetXsdInteger =
Namespace
-> [Formula RDFGraph] -> [Rule RDFGraph] -> Ruleset RDFGraph
forall ex. Namespace -> [Formula ex] -> [Rule ex] -> Ruleset ex
makeRuleset Namespace
namespaceXsdInteger [Formula RDFGraph]
axiomsXsdInteger [Rule RDFGraph]
rulesXsdInteger
prefixXsdInteger :: B.Builder
prefixXsdInteger :: Builder
prefixXsdInteger =
[Builder] -> Builder
forall a. Monoid a => [a] -> a
mconcat ([Builder] -> Builder) -> [Builder] -> Builder
forall a b. (a -> b) -> a -> b
$ (Namespace -> Builder) -> [Namespace] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map Namespace -> Builder
namespaceToBuilder
[ Namespace
namespaceRDF
, Namespace
namespaceRDFS
, Namespace
namespaceRDFD
, Namespace
namespaceXSD
, Namespace
namespaceXsdInteger
]
mkAxiom :: LName -> B.Builder -> RDFFormula
mkAxiom :: LName -> Builder -> Formula RDFGraph
mkAxiom LName
local Builder
gr =
Namespace -> LName -> Builder -> Formula RDFGraph
makeRDFFormula Namespace
namespaceXsdInteger LName
local (Builder
prefixXsdInteger Builder -> Builder -> Builder
forall a. Monoid a => a -> a -> a
`mappend` Builder
gr)
axiomsXsdInteger :: [RDFFormula]
axiomsXsdInteger :: [Formula RDFGraph]
axiomsXsdInteger =
[ LName -> Builder -> Formula RDFGraph
mkAxiom LName
"dt" Builder
"xsd:integer rdf:type rdfs:Datatype ."
]
rulesXsdInteger :: [RDFRule]
rulesXsdInteger :: [Rule RDFGraph]
rulesXsdInteger = DatatypeVal RDFGraph Integer RDFLabel RDFLabel
-> RDFGraph -> [Rule RDFGraph]
forall vt. RDFDatatypeVal vt -> RDFGraph -> [Rule RDFGraph]
makeRDFDatatypeRestrictionRules DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger RDFGraph
gr
where
gr :: RDFGraph
gr = Builder -> RDFGraph
makeRDFGraphFromN3Builder Builder
rulesXsdIntegerBuilder
rulesXsdIntegerBuilder :: B.Builder
rulesXsdIntegerBuilder :: Builder
rulesXsdIntegerBuilder =
[Builder] -> Builder
forall a. Monoid a => [a] -> a
mconcat
[ Builder
prefixXsdInteger
, Builder
"xsd_integer:Abs a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2) ; "
, Builder
" rdfd:constraint xsd_integer:abs ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Neg a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2) ; "
, Builder
" rdfd:constraint xsd_integer:neg ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Sum a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3) ; "
, Builder
" rdfd:constraint xsd_integer:sum ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Diff a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3) ; "
, Builder
" rdfd:constraint xsd_integer:diff ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Prod a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3) ; "
, Builder
" rdfd:constraint xsd_integer:prod ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:DivMod a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3 rdf:_4) ; "
, Builder
" rdfd:constraint xsd_integer:divmod ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Power a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3) ; "
, Builder
" rdfd:constraint xsd_integer:power ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Eq a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2) ; "
, Builder
" rdfd:constraint xsd_integer:eq ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Ne a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2) ; "
, Builder
" rdfd:constraint xsd_integer:ne ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Lt a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2) ; "
, Builder
" rdfd:constraint xsd_integer:lt ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Le a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2) ; "
, Builder
" rdfd:constraint xsd_integer:le ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Gt a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2) ; "
, Builder
" rdfd:constraint xsd_integer:gt ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
, Builder
"xsd_integer:Ge a rdfd:GeneralRestriction ; "
, Builder
" rdfd:onProperties (rdf:_1 rdf:_2) ; "
, Builder
" rdfd:constraint xsd_integer:ge ; "
, Builder
" rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
]