{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
module Swish.VarBinding
( VarBinding(..), nullVarBinding
, boundVars, subBinding, makeVarBinding
, applyVarBinding, joinVarBindings, addVarBinding
, VarBindingModify(..), OpenVarBindingModify
, openVbmName
, vbmCompatibility, vbmCompose
, composeSequence, findCompositions, findComposition
, VarBindingFilter(..)
, makeVarFilterModify
, makeVarTestFilter, makeVarCompareFilter
, varBindingId, nullVarBindingModify
, varFilterDisjunction, varFilterConjunction
, varFilterEQ, varFilterNE
)
where
import Swish.Namespace (ScopedName, getScopeLocal)
import Swish.QName (newLName, getLName)
import Swish.RDF.Vocabulary (swishName)
import Swish.Utils.ListHelpers (flist)
#if (!defined(__GLASGOW_HASKELL__)) || (__GLASGOW_HASKELL__ < 710)
import Control.Applicative ((<$>), (<*>))
import Data.Monoid (Monoid(..), mconcat)
#endif
#if !(MIN_VERSION_base(4, 11, 0))
import Data.Semigroup
#endif
import Control.Monad (mplus)
import Data.Function (on)
import Data.List (find, intersect, union, (\\), foldl', permutations)
import Data.Maybe (mapMaybe, fromMaybe, isJust, fromJust, listToMaybe)
import Data.Ord (comparing)
import qualified Data.Map as M
import qualified Data.Set as S
data VarBinding a b = VarBinding
{ forall a b. VarBinding a b -> a -> Maybe b
vbMap :: a -> Maybe b
, forall a b. VarBinding a b -> Set (a, b)
vbEnum :: S.Set (a,b)
, forall a b. VarBinding a b -> Bool
vbNull :: Bool
}
instance (Ord a, Ord b) => Eq (VarBinding a b) where
== :: VarBinding a b -> VarBinding a b -> Bool
(==) = forall a. Eq a => a -> a -> Bool
(==) forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall a b. VarBinding a b -> Set (a, b)
vbEnum
instance (Ord a, Ord b) => Ord (VarBinding a b) where
compare :: VarBinding a b -> VarBinding a b -> Ordering
compare = forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing forall a b. VarBinding a b -> Set (a, b)
vbEnum
instance (Ord a, Ord b) => Semigroup (VarBinding a b) where
<> :: VarBinding a b -> VarBinding a b -> VarBinding a b
(<>) = forall a b.
(Ord a, Ord b) =>
VarBinding a b -> VarBinding a b -> VarBinding a b
joinVarBindings
instance (Ord a, Ord b) => Monoid (VarBinding a b) where
mempty :: VarBinding a b
mempty = forall a b. VarBinding a b
nullVarBinding
#if !(MIN_VERSION_base(4, 11, 0))
mappend = (<>)
#endif
instance (Show a, Show b) => Show (VarBinding a b) where
show :: VarBinding a b -> String
show = forall a. Show a => a -> String
show forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Set a -> [a]
S.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. VarBinding a b -> Set (a, b)
vbEnum
nullVarBinding :: VarBinding a b
nullVarBinding :: forall a b. VarBinding a b
nullVarBinding = VarBinding
{ vbMap :: a -> Maybe b
vbMap = forall a b. a -> b -> a
const forall a. Maybe a
Nothing
, vbEnum :: Set (a, b)
vbEnum = forall a. Set a
S.empty
, vbNull :: Bool
vbNull = Bool
True
}
boundVars :: (Ord a, Ord b) => VarBinding a b -> S.Set a
boundVars :: forall a b. (Ord a, Ord b) => VarBinding a b -> Set a
boundVars = forall b a. Ord b => (a -> b) -> Set a -> Set b
S.map forall a b. (a, b) -> a
fst forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. VarBinding a b -> Set (a, b)
vbEnum
subBinding :: (Ord a, Ord b) => VarBinding a b -> VarBinding a b -> Bool
subBinding :: forall a b.
(Ord a, Ord b) =>
VarBinding a b -> VarBinding a b -> Bool
subBinding = forall a. Ord a => Set a -> Set a -> Bool
S.isSubsetOf forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall a b. VarBinding a b -> Set (a, b)
vbEnum
makeVarBinding :: (Ord a, Ord b) => [(a,b)] -> VarBinding a b
makeVarBinding :: forall a b. (Ord a, Ord b) => [(a, b)] -> VarBinding a b
makeVarBinding [] = forall a b. VarBinding a b
nullVarBinding
makeVarBinding [(a, b)]
vrbs =
VarBinding
{ vbMap :: a -> Maybe b
vbMap = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup (forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [(a, b)]
vrbs)
, vbEnum :: Set (a, b)
vbEnum = forall a. Ord a => [a] -> Set a
S.fromList [(a, b)]
vrbs
, vbNull :: Bool
vbNull = Bool
False
}
applyVarBinding :: VarBinding a a -> a -> a
applyVarBinding :: forall a. VarBinding a a -> a -> a
applyVarBinding VarBinding a a
vbind a
v = forall a. a -> Maybe a -> a
fromMaybe a
v (forall a b. VarBinding a b -> a -> Maybe b
vbMap VarBinding a a
vbind a
v)
joinVarBindings :: (Ord a, Ord b) => VarBinding a b -> VarBinding a b -> VarBinding a b
joinVarBindings :: forall a b.
(Ord a, Ord b) =>
VarBinding a b -> VarBinding a b -> VarBinding a b
joinVarBindings VarBinding a b
vb1 VarBinding a b
vb2
| forall a b. VarBinding a b -> Bool
vbNull VarBinding a b
vb1 = VarBinding a b
vb2
| forall a b. VarBinding a b -> Bool
vbNull VarBinding a b
vb2 = VarBinding a b
vb1
| Bool
otherwise = VarBinding
{ vbMap :: a -> Maybe b
vbMap = a -> Maybe b
mv12
, vbEnum :: Set (a, b)
vbEnum = forall b a. Ord b => (a -> b) -> Set a -> Set b
S.map (\a
v -> (a
v,forall a. HasCallStack => Maybe a -> a
fromJust (a -> Maybe b
mv12 a
v))) Set a
bv12
, vbNull :: Bool
vbNull = Bool
False
}
where
mv12 :: a -> Maybe b
mv12 a
n = forall a b. VarBinding a b -> a -> Maybe b
vbMap VarBinding a b
vb1 a
n forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` forall a b. VarBinding a b -> a -> Maybe b
vbMap VarBinding a b
vb2 a
n
bv12 :: Set a
bv12 = forall a b. (Ord a, Ord b) => VarBinding a b -> Set a
boundVars VarBinding a b
vb1 forall a. Ord a => Set a -> Set a -> Set a
`S.union` forall a b. (Ord a, Ord b) => VarBinding a b -> Set a
boundVars VarBinding a b
vb2
addVarBinding ::
(Ord a, Ord b)
=> a
-> b
-> VarBinding a b
-> VarBinding a b
addVarBinding :: forall a b.
(Ord a, Ord b) =>
a -> b -> VarBinding a b -> VarBinding a b
addVarBinding a
lb b
val VarBinding a b
vbind = forall a b.
(Ord a, Ord b) =>
VarBinding a b -> VarBinding a b -> VarBinding a b
joinVarBindings VarBinding a b
vbind forall a b. (a -> b) -> a -> b
$ forall a b. (Ord a, Ord b) => [(a, b)] -> VarBinding a b
makeVarBinding [(a
lb,b
val)]
data VarBindingModify a b = VarBindingModify
{ forall a b. VarBindingModify a b -> ScopedName
vbmName :: ScopedName
, forall a b.
VarBindingModify a b -> [VarBinding a b] -> [VarBinding a b]
vbmApply :: [VarBinding a b] -> [VarBinding a b]
, forall a b. VarBindingModify a b -> [a]
vbmVocab :: [a]
, forall a b. VarBindingModify a b -> [[a]]
vbmUsage :: [[a]]
}
type OpenVarBindingModify lb vn = [lb] -> VarBindingModify lb vn
openVbmName :: OpenVarBindingModify lb vn -> ScopedName
openVbmName :: forall lb vn. OpenVarBindingModify lb vn -> ScopedName
openVbmName OpenVarBindingModify lb vn
ovbm = forall a b. VarBindingModify a b -> ScopedName
vbmName (OpenVarBindingModify lb vn
ovbm (forall a. HasCallStack => String -> a
error String
"Undefined labels in variable binding"))
instance Show (OpenVarBindingModify a b)
where
show :: OpenVarBindingModify a b -> String
show = forall a. Show a => a -> String
show forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall lb vn. OpenVarBindingModify lb vn -> ScopedName
openVbmName
vbmCompatibility :: (Eq a) => VarBindingModify a b -> [a] -> Maybe [a]
vbmCompatibility :: forall a b. Eq a => VarBindingModify a b -> [a] -> Maybe [a]
vbmCompatibility VarBindingModify a b
vbm [a]
vars = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find [a] -> Bool
compat (forall a b. VarBindingModify a b -> [[a]]
vbmUsage VarBindingModify a b
vbm)
where
compat :: [a] -> Bool
compat = forall a. Eq a => [a] -> [a] -> [a] -> Bool
vbmCompatibleVars [a]
vars (forall a b. VarBindingModify a b -> [a]
vbmVocab VarBindingModify a b
vbm)
vbmCompatibleVars ::
(Eq a)
=> [a]
-> [a]
-> [a]
-> Bool
vbmCompatibleVars :: forall a. Eq a => [a] -> [a] -> [a] -> Bool
vbmCompatibleVars [a]
bvars [a]
vocab [a]
ovars =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([a]
ivars forall a. Eq a => [a] -> [a] -> [a]
`intersect` [a]
ovars) Bool -> Bool -> Bool
&&
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (([a]
vocab forall a. Eq a => [a] -> [a] -> [a]
\\ [a]
ovars) forall a. Eq a => [a] -> [a] -> [a]
\\ [a]
ivars)
where
ivars :: [a]
ivars = [a]
bvars forall a. Eq a => [a] -> [a] -> [a]
`intersect` [a]
vocab
vbmCompose :: (Eq a) => VarBindingModify a b -> VarBindingModify a b
-> Maybe (VarBindingModify a b)
vbmCompose :: forall a b.
Eq a =>
VarBindingModify a b
-> VarBindingModify a b -> Maybe (VarBindingModify a b)
vbmCompose
(VarBindingModify ScopedName
nam1 [VarBinding a b] -> [VarBinding a b]
app1 [a]
voc1 [[a]]
use1)
(VarBindingModify ScopedName
nam2 [VarBinding a b] -> [VarBinding a b]
app2 [a]
voc2 [[a]]
use2)
| Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[a]]
use12) = forall a. a -> Maybe a
Just VarBindingModify
{ vbmName :: ScopedName
vbmName = ScopedName
name
, vbmApply :: [VarBinding a b] -> [VarBinding a b]
vbmApply = [VarBinding a b] -> [VarBinding a b]
app2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. [VarBinding a b] -> [VarBinding a b]
app1
, vbmVocab :: [a]
vbmVocab = [a]
voc1 forall a. Eq a => [a] -> [a] -> [a]
`union` [a]
voc2
, vbmUsage :: [[a]]
vbmUsage = [[a]]
use12
}
| Bool
otherwise = forall a. Maybe a
Nothing
where
use12 :: [[a]]
use12 = forall a. Eq a => [a] -> [[a]] -> [[a]] -> [[a]]
compatibleUsage [a]
voc1 [[a]]
use1 [[a]]
use2
getName :: ScopedName -> Text
getName = LName -> Text
getLName forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScopedName -> LName
getScopeLocal
name :: ScopedName
name = LName -> ScopedName
swishName forall a b. (a -> b) -> a -> b
$ forall a. HasCallStack => Maybe a -> a
fromJust forall a b. (a -> b) -> a -> b
$ Text -> Maybe LName
newLName forall a b. (a -> b) -> a -> b
$ forall a. Monoid a => [a] -> a
mconcat [Text
"_", ScopedName -> Text
getName ScopedName
nam1, Text
"_", ScopedName -> Text
getName ScopedName
nam2, Text
"_"]
compatibleUsage ::
(Eq a)
=> [a]
-> [[a]]
-> [[a]]
-> [[a]]
compatibleUsage :: forall a. Eq a => [a] -> [[a]] -> [[a]] -> [[a]]
compatibleUsage [a]
voc1 [[a]]
use1 [[a]]
use2 =
[ [a]
u1 forall a. [a] -> [a] -> [a]
++ [a]
u2 | [a]
u2 <- [[a]]
use2, forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([a]
voc1 forall a. Eq a => [a] -> [a] -> [a]
`intersect` [a]
u2), [a]
u1 <- [[a]]
use1 ]
findCompositions ::
(Eq a) => [VarBindingModify a b]
-> [a]
-> [VarBindingModify a b]
findCompositions :: forall a b.
Eq a =>
[VarBindingModify a b] -> [a] -> [VarBindingModify a b]
findCompositions [VarBindingModify a b]
vbms [a]
vars =
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (forall a b.
Eq a =>
[a] -> [VarBindingModify a b] -> Maybe (VarBindingModify a b)
composeCheckSequence [a]
vars) (forall a. [a] -> [[a]]
permutations [VarBindingModify a b]
vbms)
composeCheckSequence :: (Eq a) => [a] -> [VarBindingModify a b]
-> Maybe (VarBindingModify a b)
composeCheckSequence :: forall a b.
Eq a =>
[a] -> [VarBindingModify a b] -> Maybe (VarBindingModify a b)
composeCheckSequence [a]
vars [VarBindingModify a b]
vbms = forall {a} {b}.
Eq a =>
[a] -> Maybe (VarBindingModify a b) -> Maybe (VarBindingModify a b)
useWith [a]
vars forall a b. (a -> b) -> a -> b
$ forall a b.
Eq a =>
[VarBindingModify a b] -> Maybe (VarBindingModify a b)
composeSequence [VarBindingModify a b]
vbms
where
useWith :: [a] -> Maybe (VarBindingModify a b) -> Maybe (VarBindingModify a b)
useWith [a]
_ Maybe (VarBindingModify a b)
Nothing = forall a. Maybe a
Nothing
useWith [a]
vs v :: Maybe (VarBindingModify a b)
v@(Just VarBindingModify a b
vbm)
| forall a. Maybe a -> Bool
isJust forall a b. (a -> b) -> a -> b
$ forall a b. Eq a => VarBindingModify a b -> [a] -> Maybe [a]
vbmCompatibility VarBindingModify a b
vbm [a]
vs = Maybe (VarBindingModify a b)
v
| Bool
otherwise = forall a. Maybe a
Nothing
composeSequence :: (Eq a) => [VarBindingModify a b]
-> Maybe (VarBindingModify a b)
composeSequence :: forall a b.
Eq a =>
[VarBindingModify a b] -> Maybe (VarBindingModify a b)
composeSequence [] = forall a. a -> Maybe a
Just forall a b. VarBindingModify a b
varBindingId
composeSequence (VarBindingModify a b
vbm:[VarBindingModify a b]
vbms) = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall a b.
Eq a =>
Maybe (VarBindingModify a b)
-> VarBindingModify a b -> Maybe (VarBindingModify a b)
composePair (forall a. a -> Maybe a
Just VarBindingModify a b
vbm) [VarBindingModify a b]
vbms
composePair :: (Eq a) => Maybe (VarBindingModify a b) -> VarBindingModify a b
-> Maybe (VarBindingModify a b)
composePair :: forall a b.
Eq a =>
Maybe (VarBindingModify a b)
-> VarBindingModify a b -> Maybe (VarBindingModify a b)
composePair Maybe (VarBindingModify a b)
Nothing VarBindingModify a b
_ = forall a. Maybe a
Nothing
composePair (Just VarBindingModify a b
vbm1) VarBindingModify a b
vbm2 = forall a b.
Eq a =>
VarBindingModify a b
-> VarBindingModify a b -> Maybe (VarBindingModify a b)
vbmCompose VarBindingModify a b
vbm1 VarBindingModify a b
vbm2
findComposition :: (Eq a) => [VarBindingModify a b] -> [a]
-> Maybe (VarBindingModify a b)
findComposition :: forall a b.
Eq a =>
[VarBindingModify a b] -> [a] -> Maybe (VarBindingModify a b)
findComposition = forall a. [a] -> Maybe a
listToMaybe forall {b} {c} {a} {a}. (b -> c) -> (a -> a -> b) -> a -> a -> c
`c2` forall a b.
Eq a =>
[VarBindingModify a b] -> [a] -> [VarBindingModify a b]
findCompositions
where
c2 :: (b -> c) -> (a -> a -> b) -> a -> a -> c
c2 = forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall b c a. (b -> c) -> (a -> b) -> a -> c
(.)
varBindingId :: VarBindingModify a b
varBindingId :: forall a b. VarBindingModify a b
varBindingId = VarBindingModify
{ vbmName :: ScopedName
vbmName = LName -> ScopedName
swishName LName
"varBindingId"
, vbmApply :: [VarBinding a b] -> [VarBinding a b]
vbmApply = forall a. a -> a
id
, vbmVocab :: [a]
vbmVocab = []
, vbmUsage :: [[a]]
vbmUsage = [[]]
}
nullVarBindingModify :: OpenVarBindingModify a b
nullVarBindingModify :: forall a b. OpenVarBindingModify a b
nullVarBindingModify [a]
lbs = VarBindingModify
{ vbmName :: ScopedName
vbmName = LName -> ScopedName
swishName LName
"nullVarBindingModify"
, vbmApply :: [VarBinding a b] -> [VarBinding a b]
vbmApply = forall a. a -> a
id
, vbmVocab :: [a]
vbmVocab = [a]
lbs
, vbmUsage :: [[a]]
vbmUsage = [[]]
}
data VarBindingFilter a b = VarBindingFilter
{ forall a b. VarBindingFilter a b -> ScopedName
vbfName :: ScopedName
, forall a b. VarBindingFilter a b -> [a]
vbfVocab :: [a]
, forall a b. VarBindingFilter a b -> VarBinding a b -> Bool
vbfTest :: VarBinding a b -> Bool
}
makeVarFilterModify :: VarBindingFilter a b -> VarBindingModify a b
makeVarFilterModify :: forall a b. VarBindingFilter a b -> VarBindingModify a b
makeVarFilterModify VarBindingFilter a b
vbf = VarBindingModify
{ vbmName :: ScopedName
vbmName = forall a b. VarBindingFilter a b -> ScopedName
vbfName VarBindingFilter a b
vbf
, vbmApply :: [VarBinding a b] -> [VarBinding a b]
vbmApply = forall a. (a -> Bool) -> [a] -> [a]
filter (forall a b. VarBindingFilter a b -> VarBinding a b -> Bool
vbfTest VarBindingFilter a b
vbf)
, vbmVocab :: [a]
vbmVocab = forall a b. VarBindingFilter a b -> [a]
vbfVocab VarBindingFilter a b
vbf
, vbmUsage :: [[a]]
vbmUsage = [[]]
}
makeVarTestFilter ::
ScopedName -> (b -> Bool) -> a -> VarBindingFilter a b
makeVarTestFilter :: forall b a. ScopedName -> (b -> Bool) -> a -> VarBindingFilter a b
makeVarTestFilter ScopedName
nam b -> Bool
vtest a
var = VarBindingFilter
{ vbfName :: ScopedName
vbfName = ScopedName
nam
, vbfVocab :: [a]
vbfVocab = [a
var]
, vbfTest :: VarBinding a b -> Bool
vbfTest = \VarBinding a b
vb -> forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False b -> Bool
vtest (forall a b. VarBinding a b -> a -> Maybe b
vbMap VarBinding a b
vb a
var)
}
makeVarCompareFilter ::
ScopedName -> (b -> b -> Bool) -> a -> a -> VarBindingFilter a b
makeVarCompareFilter :: forall b a.
ScopedName -> (b -> b -> Bool) -> a -> a -> VarBindingFilter a b
makeVarCompareFilter ScopedName
nam b -> b -> Bool
vcomp a
v1 a
v2 = VarBindingFilter
{ vbfName :: ScopedName
vbfName = ScopedName
nam
, vbfVocab :: [a]
vbfVocab = [a
v1,a
v2]
, vbfTest :: VarBinding a b -> Bool
vbfTest = \VarBinding a b
vb -> forall a. a -> Maybe a
Just Bool
True forall a. Eq a => a -> a -> Bool
== (b -> b -> Bool
vcomp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a b. VarBinding a b -> a -> Maybe b
vbMap VarBinding a b
vb a
v1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a b. VarBinding a b -> a -> Maybe b
vbMap VarBinding a b
vb a
v2)
}
varFilterEQ :: (Eq b) => a -> a -> VarBindingFilter a b
varFilterEQ :: forall b a. Eq b => a -> a -> VarBindingFilter a b
varFilterEQ =
forall b a.
ScopedName -> (b -> b -> Bool) -> a -> a -> VarBindingFilter a b
makeVarCompareFilter (LName -> ScopedName
swishName LName
"varFilterEQ") forall a. Eq a => a -> a -> Bool
(==)
varFilterNE :: (Eq b) => a -> a -> VarBindingFilter a b
varFilterNE :: forall b a. Eq b => a -> a -> VarBindingFilter a b
varFilterNE =
forall b a.
ScopedName -> (b -> b -> Bool) -> a -> a -> VarBindingFilter a b
makeVarCompareFilter (LName -> ScopedName
swishName LName
"varFilterNE") forall a. Eq a => a -> a -> Bool
(/=)
varFilterDisjunction :: (Eq a) => [VarBindingFilter a b]
-> VarBindingFilter a b
varFilterDisjunction :: forall a b. Eq a => [VarBindingFilter a b] -> VarBindingFilter a b
varFilterDisjunction [VarBindingFilter a b]
vbfs = VarBindingFilter
{ vbfName :: ScopedName
vbfName = LName -> ScopedName
swishName LName
"varFilterDisjunction"
, vbfVocab :: [a]
vbfVocab = forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 forall a. Eq a => [a] -> [a] -> [a]
union (forall a b. (a -> b) -> [a] -> [b]
map forall a b. VarBindingFilter a b -> [a]
vbfVocab [VarBindingFilter a b]
vbfs)
, vbfTest :: VarBinding a b -> Bool
vbfTest = forall (t :: * -> *). Foldable t => t Bool -> Bool
or forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. [a -> b] -> a -> [b]
flist (forall a b. (a -> b) -> [a] -> [b]
map forall a b. VarBindingFilter a b -> VarBinding a b -> Bool
vbfTest [VarBindingFilter a b]
vbfs)
}
varFilterConjunction :: (Eq a) => [VarBindingFilter a b]
-> VarBindingFilter a b
varFilterConjunction :: forall a b. Eq a => [VarBindingFilter a b] -> VarBindingFilter a b
varFilterConjunction [VarBindingFilter a b]
vbfs = VarBindingFilter
{ vbfName :: ScopedName
vbfName = LName -> ScopedName
swishName LName
"varFilterConjunction"
, vbfVocab :: [a]
vbfVocab = forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 forall a. Eq a => [a] -> [a] -> [a]
union (forall a b. (a -> b) -> [a] -> [b]
map forall a b. VarBindingFilter a b -> [a]
vbfVocab [VarBindingFilter a b]
vbfs)
, vbfTest :: VarBinding a b -> Bool
vbfTest = forall (t :: * -> *). Foldable t => t Bool -> Bool
and forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. [a -> b] -> a -> [b]
flist (forall a b. (a -> b) -> [a] -> [b]
map forall a b. VarBindingFilter a b -> VarBinding a b -> Bool
vbfTest [VarBindingFilter a b]
vbfs)
}