Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Iterate.SetAlgebra
Synopsis
- class Iter f => Basic f where
- fromPairs :: Ord k => (v -> v -> v) -> [(k, v)] -> List k v
- normalize :: Ord k => (v -> v -> v) -> [(k, v)] -> [(k, v)]
- data Single k v where
- mapflip :: (v -> v -> v) -> v -> v -> v
- data BiMap v a b where
- decodeMapAsBimap :: (FromCBOR a, FromCBOR b, Ord a, Ord b) => Decoder s (BiMap b a b)
- addBack :: (Ord v, Ord k) => v -> k -> Map v (Set k) -> Map v (Set k)
- retract :: (Ord v, Ord k) => v -> k -> Map v (Set k) -> Map v (Set k)
- insertBackwards :: (Ord k, Ord v) => v -> v -> k -> Map v (Set k) -> Map v (Set k)
- biMapEmpty :: BiMap v k v
- biMapFromList :: (Ord k, Ord v) => (v -> v -> v) -> [(k, v)] -> BiMap v k v
- biMapFromAscDistinctList :: (Ord k, Ord v) => [(k, v)] -> BiMap v k v
- type Bimap k v = BiMap v k v
- removeval :: (Ord k, Ord v) => v -> BiMap v k v -> BiMap v k v
- data Sett k v where
- class Embed concrete base | concrete -> base where
- class Iter f where
- nxt :: f a b -> Collect (a, b, f a b)
- lub :: Ord k => k -> f k b -> Collect (k, b, f k b)
- hasNxt :: f a b -> Maybe (a, b, f a b)
- hasLub :: Ord k => k -> f k b -> Maybe (k, b, f k b)
- haskey :: Ord key => key -> f key b -> Bool
- isnull :: f k v -> Bool
- lookup :: Ord key => key -> f key rng -> Maybe rng
- element :: Ord k => k -> f k v -> Collect ()
- data List k v where
- UnSafeList :: Ord k => [(k, v)] -> List k v
- unList :: List k v -> [(k, v)]
- noKeys :: Ord k => Map k a -> Map k b -> Map k a
- keysEqual :: Ord k => Map k v1 -> Map k v2 -> Bool
- sameDomain :: (Ord k, Iter f, Iter g) => f k b -> g k c -> Bool
- splitMember :: Ord k => k -> Map k a -> (Map k a, Bool, Map k a)
- data StrictTriple a b c = StrictTriple !a !b !c
- intersectDomP :: Ord k => (k -> v2 -> Bool) -> Map k v1 -> Map k v2 -> Map k v2
- intersectDomPLeft :: Ord k => (k -> v2 -> Bool) -> Map k v1 -> Map k v2 -> Map k v1
- intersectMapSetFold :: Ord k => (k -> v -> ans -> ans) -> Map k v -> Set k -> ans -> ans
- disjointMapSetFold :: Ord k => (k -> v -> ans -> ans) -> Map k v -> Set k -> ans -> ans
- data BaseRep f k v where
- lifo :: Iter f => f k v -> Collect (k, v)
- fifo :: Iter f => f k v -> Collect (k, v)
- data Exp t where
- Base :: (Ord k, Basic f) => BaseRep f k v -> f k v -> Exp (f k v)
- Dom :: Ord k => Exp (f k v) -> Exp (Sett k ())
- Rng :: (Ord k, Ord v) => Exp (f k v) -> Exp (Sett v ())
- DRestrict :: (Ord k, Iter g) => Exp (g k ()) -> Exp (f k v) -> Exp (f k v)
- DExclude :: (Ord k, Iter g) => Exp (g k ()) -> Exp (f k v) -> Exp (f k v)
- RRestrict :: (Ord k, Iter g, Ord v) => Exp (f k v) -> Exp (g v ()) -> Exp (f k v)
- RExclude :: (Ord k, Iter g, Ord v) => Exp (f k v) -> Exp (g v ()) -> Exp (f k v)
- Elem :: (Ord k, Iter g, Show k) => k -> Exp (g k ()) -> Exp Bool
- NotElem :: (Ord k, Iter g, Show k) => k -> Exp (g k ()) -> Exp Bool
- Intersect :: (Ord k, Iter f, Iter g) => Exp (f k v) -> Exp (g k u) -> Exp (Sett k ())
- Subset :: (Ord k, Iter f, Iter g) => Exp (f k v) -> Exp (g k u) -> Exp Bool
- SetDiff :: (Ord k, Iter f, Iter g) => Exp (f k v) -> Exp (g k u) -> Exp (f k v)
- UnionOverrideLeft :: (Show k, Show v, Ord k) => Exp (f k v) -> Exp (g k v) -> Exp (f k v)
- UnionPlus :: (Ord k, Monoid n) => Exp (f k n) -> Exp (f k n) -> Exp (f k n)
- UnionOverrideRight :: Ord k => Exp (f k v) -> Exp (g k v) -> Exp (f k v)
- Singleton :: Ord k => k -> v -> Exp (Single k v)
- SetSingleton :: Ord k => k -> Exp (Single k ())
- KeyEqual :: (Ord k, Iter f, Iter g) => Exp (f k v) -> Exp (g k u) -> Exp Bool
- dRestrict :: (Ord k, Iter g) => Exp (g k ()) -> Exp (f k v) -> Exp (f k v)
- rRestrict :: (Ord k, Iter g, Ord v) => Exp (f k v) -> Exp (g v ()) -> Exp (f k v)
- dExclude :: (Ord k, Iter g) => Exp (g k ()) -> Exp (f k v) -> Exp (f k v)
- rExclude :: (Ord k, Iter g, Ord v) => Exp (f k v) -> Exp (g v ()) -> Exp (f k v)
- class HasExp s t | s -> t where
- dom :: (Ord k, HasExp s (f k v)) => s -> Exp (Sett k ())
- rng :: (Ord k, Ord v) => HasExp s (f k v) => s -> Exp (Sett v ())
- (◁) :: (Ord k, HasExp s1 (Sett k ()), HasExp s2 (f k v)) => s1 -> s2 -> Exp (f k v)
- (<|) :: (Ord k, HasExp s1 (Sett k ()), HasExp s2 (f k v)) => s1 -> s2 -> Exp (f k v)
- drestrict :: (Ord k, HasExp s1 (Sett k ()), HasExp s2 (f k v)) => s1 -> s2 -> Exp (f k v)
- (⋪) :: (Ord k, Iter g, HasExp s1 (g k ()), HasExp s2 (f k v)) => s1 -> s2 -> Exp (f k v)
- dexclude :: (Ord k, Iter g, HasExp s1 (g k ()), HasExp s2 (f k v)) => s1 -> s2 -> Exp (f k v)
- (▷) :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v)
- (|>) :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v)
- rrestrict :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v)
- (⋫) :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v)
- rexclude :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v)
- (∈) :: (Show k, Ord k, Iter g, HasExp s (g k ())) => k -> s -> Exp Bool
- (∉) :: (Show k, Ord k, Iter g, HasExp s (g k ())) => k -> s -> Exp Bool
- notelem :: (Show k, Ord k, Iter g, HasExp s (g k ())) => k -> s -> Exp Bool
- (∪) :: (Show k, Show v, Ord k, HasExp s1 (f k v), HasExp s2 (g k v)) => s1 -> s2 -> Exp (f k v)
- unionleft :: (Show k, Show v, Ord k, HasExp s1 (f k v), HasExp s2 (g k v)) => s1 -> s2 -> Exp (f k v)
- (⨃) :: (Ord k, HasExp s1 (f k v), HasExp s2 (g k v)) => s1 -> s2 -> Exp (f k v)
- unionright :: (Ord k, HasExp s1 (f k v), HasExp s2 (g k v)) => s1 -> s2 -> Exp (f k v)
- (∪+) :: (Ord k, Monoid n, HasExp s1 (f k n), HasExp s2 (f k n)) => s1 -> s2 -> Exp (f k n)
- unionplus :: (Ord k, Monoid n, HasExp s1 (f k n), HasExp s2 (f k n)) => s1 -> s2 -> Exp (f k n)
- singleton :: Ord k => k -> v -> Exp (Single k v)
- setSingleton :: Ord k => k -> Exp (Single k ())
- (∩) :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp (Sett k ())
- intersect :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp (Sett k ())
- (⊆) :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp Bool
- subset :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp Bool
- (➖) :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp (f k v)
- setdiff :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp (f k v)
- (≍) :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp Bool
- keyeq :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp Bool
- data Pat env t where
- data Expr env t where
- X1 :: Expr (d, c, b, a) d
- X2 :: Expr (d, c, b, a) c
- X3 :: Expr (d, c, b, a) b
- X4 :: Expr (d, c, b, a) a
- HasKey :: (Iter f, Ord k) => Expr e k -> f k v -> Expr e Bool
- Neg :: Expr e Bool -> Expr e Bool
- Ap :: Lam (a -> b -> c) -> Expr e a -> Expr e b -> Expr e c
- EPair :: Expr e a -> Expr e b -> Expr e (a, b)
- FST :: Expr e (a, b) -> Expr e a
- SND :: Expr e (a, b) -> Expr e b
- Lit :: Show t => t -> Expr env t
- data Lam t where
- type StringEnv = (String, String, String, String)
- bindE :: Pat (a, b, c, d) t -> Expr (w, x, y, z) t -> StringEnv -> StringEnv
- showE :: StringEnv -> Expr (a, b, c, d) t -> String
- showL :: StringEnv -> Lam t -> String
- showP :: StringEnv -> Pat any t -> String
- data Fun t = Fun (Lam t) t
- apply :: Fun t -> t
- first :: Fun (v -> s -> v)
- second :: Fun (v -> s -> s)
- plus :: Monoid t => Fun (t -> t -> t)
- eql :: Eq t => Fun (t -> t -> Bool)
- constant :: Show c => c -> Fun (a -> b -> c)
- rngElem :: (Ord rng, Iter f) => f rng v -> Fun (dom -> rng -> Bool)
- domElem :: (Ord dom, Iter f) => f dom v -> Fun (dom -> rng -> Bool)
- rngFst :: Fun (x -> (a, b) -> a)
- rngSnd :: Fun (x -> (a, b) -> b)
- compose1 :: Fun (t1 -> t2 -> t3) -> Fun (t1 -> t4 -> t2) -> Fun (t1 -> t4 -> t3)
- compSndL :: Fun (k -> (a, b) -> c) -> Fun (k -> d -> a) -> Fun (k -> (d, b) -> c)
- compSndR :: Fun (k -> (a, b) -> c) -> Fun (k -> d -> b) -> Fun (k -> (a, d) -> c)
- compCurryR :: Fun (k -> (a, b) -> d) -> Fun (a -> c -> b) -> Fun (k -> (a, c) -> d)
- nEgate :: Fun (k -> v -> Bool) -> Fun (k -> v -> Bool)
- always :: Fun (a -> b -> Bool)
- both :: Fun (a -> b -> Bool) -> Fun (a -> b -> Bool) -> Fun (a -> b -> Bool)
- lift :: (a -> b -> c) -> Fun (a -> b -> c)
- materialize :: Ord k => BaseRep f k v -> Collect (k, v) -> f k v
- addp :: (Ord k, Basic f) => (v -> v -> v) -> (k, v) -> f k v -> f k v
- fromList :: Ord k => BaseRep f k v -> (v -> v -> v) -> [(k, v)] -> f k v
- (⨝) :: (Ord k, Iter f, Iter g) => f k b -> g k c -> Collect (k, b, c)
- domEq :: (Ord k, Iter f, Iter g) => f k b -> g k c -> Collect (k, b, c)
- domEqSlow :: (Ord k, Iter f, Iter g) => f k b -> g k c -> Collect (k, b, c)
- data Query k v where
- BaseD :: (Iter f, Ord k) => BaseRep f k v -> f k v -> Query k v
- ProjectD :: Ord k => Query k v -> Fun (k -> v -> u) -> Query k u
- AndD :: Ord k => Query k v -> Query k w -> Query k (v, w)
- ChainD :: (Ord k, Ord v) => Query k v -> Query v w -> Fun (k -> (v, w) -> u) -> Query k u
- AndPD :: Ord k => Query k v -> Query k u -> Fun (k -> (v, u) -> w) -> Query k w
- OrD :: Ord k => Query k v -> Query k v -> Fun (v -> v -> v) -> Query k v
- GuardD :: Ord k => Query k v -> Fun (k -> v -> Bool) -> Query k v
- DiffD :: Ord k => Query k v -> Query k u -> Query k v
- smart :: Bool
- projD :: Ord k => Query k v -> Fun (k -> v -> u) -> Query k u
- andD :: Ord k => Query k v1 -> Query k v2 -> Query k (v1, v2)
- andPD :: Ord k => Query k v1 -> Query k u -> Fun (k -> (v1, u) -> v) -> Query k v
- chainD :: (Ord k, Ord v) => Query k v -> Query v w -> Fun (k -> (v, w) -> u) -> Query k u
- guardD :: Ord k => Query k v -> Fun (k -> v -> Bool) -> Query k v
- compileSubterm :: Exp a -> Exp (f k v) -> Query k v
- compile :: Exp (f k v) -> (Query k v, BaseRep f k v)
- testing :: Bool
- runSetExp :: Ord k => Exp (f k v) -> f k v
- runSet :: Ord k => Exp (f k v) -> f k v
- run :: Ord k => (Query k v, BaseRep f k v) -> f k v
- runBoolExp :: Exp Bool -> Bool
- runBool :: Exp Bool -> Bool
- compute :: Exp t -> t
- eval :: Embed s t => Exp t -> s
- projStep :: Ord k => (t -> Collect (k, v, Query k v)) -> Fun (k -> v -> u) -> t -> Collect (k, u, Query k u)
- andStep :: Ord a => (a, b1, Query a b1) -> (a, b2, Query a b2) -> Collect (a, (b1, b2), Query a (b1, b2))
- chainStep :: (Ord b, Ord a) => (a, b, Query a b) -> Query b w -> Fun (a -> (b, w) -> u) -> Collect (a, u, Query a u)
- andPstep :: Ord a => (a, b1, Query a b1) -> (a, b2, Query a b2) -> Fun (a -> (b1, b2) -> w) -> Collect (a, w, Query a w)
- orStep :: (Ord k, Ord a) => (Query k v -> Collect (a, v, Query k v)) -> Query k v -> Query k v -> Fun (v -> v -> v) -> Collect (a, v, Query k v)
- guardStep :: Ord a => (Query a b -> Collect (a, b, Query a b)) -> Fun (a -> b -> Bool) -> Query a b -> Collect (a, b, Query a b)
- diffStep :: Ord k => (k, v, Query k v) -> Query k u -> Collect (k, v, Query k v)
- rngStep :: Ord v => Query k v -> Sett v ()
- nxtQuery :: Query a b -> Collect (a, b, Query a b)
- lubQuery :: Ord a => a -> Query a b -> Collect (a, b, Query a b)
- projectQ :: (Ord k, HasQuery c k v) => c -> Fun (k -> v -> u) -> Query k u
- andQ :: (Ord k, HasQuery concrete1 k v, HasQuery concrete2 k w) => concrete1 -> concrete2 -> Query k (v, w)
- orQ :: (Ord k, HasQuery concrete1 k v, HasQuery concrete2 k v) => concrete1 -> concrete2 -> Fun (v -> v -> v) -> Query k v
- chainQ :: (Ord k, Ord v, HasQuery concrete1 k v, HasQuery concrete2 v w) => concrete1 -> concrete2 -> Fun (k -> (v, w) -> u) -> Query k u
- andPQ :: (Ord k, HasQuery concrete1 k v, HasQuery concrete2 k u) => concrete1 -> concrete2 -> Fun (k -> (v, u) -> w) -> Query k w
- guardQ :: (Ord k, HasQuery concrete k v) => concrete -> Fun (k -> v -> Bool) -> Query k v
- class HasQuery concrete k v where
- ppQuery :: Query k v -> Doc
Documentation
class Iter f => Basic f where Source #
In order to build typed Exp (which are a typed deep embedding) of Set operations, we need to know what kind of basic types of Maps and Sets can be embedded. Every Basic type has a few operations for creating one from a list, for adding and removing key-value pairs, looking up a value given a key. Instances of this algebra are functional in that every key has exactly one value associated with it. ===================================================================================================
Methods
addpair :: Ord k => k -> v -> f k v -> f k v Source #
in addpair the new value always prevails, to make a choice use addkv
which has a combining function that allows choice.
addkv :: Ord k => (k, v) -> f k v -> (v -> v -> v) -> f k v Source #
use ( old new -> old) if you want the v in (f k v) to prevail, and use ( old new -> new) if you want the v in (k,v) to prevail
removekey :: Ord k => k -> f k v -> f k v Source #
domain :: Ord k => f k v -> Set k Source #
Instances
Basic Map Source # | |
Defined in Control.Iterate.SetAlgebra | |
Basic List Source # | The constructor for List is hidden, since it requires some invariants. Use fromPairs to build an initial List. |
Defined in Control.Iterate.SetAlgebra | |
Basic Sett Source # | |
Defined in Control.Iterate.SetAlgebra | |
Basic Single Source # | |
Defined in Control.Iterate.SetAlgebra Methods addpair :: Ord k => k -> v -> Single k v -> Single k v Source # addkv :: Ord k => (k, v) -> Single k v -> (v -> v -> v) -> Single k v Source # removekey :: Ord k => k -> Single k v -> Single k v Source # domain :: Ord k => Single k v -> Set k Source # | |
Ord v => Basic (BiMap v) Source # | |
Defined in Control.Iterate.SetAlgebra Methods addpair :: Ord k => k -> v0 -> BiMap v k v0 -> BiMap v k v0 Source # addkv :: Ord k => (k, v0) -> BiMap v k v0 -> (v0 -> v0 -> v0) -> BiMap v k v0 Source # removekey :: Ord k => k -> BiMap v k v0 -> BiMap v k v0 Source # domain :: Ord k => BiMap v k v0 -> Set k Source # |
data Single k v where Source #
Instances
data BiMap v a b where Source #
Instances
Ord v => Iter (BiMap v) Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: BiMap v a b -> Collect (a, b, BiMap v a b) Source # lub :: Ord k => k -> BiMap v k b -> Collect (k, b, BiMap v k b) Source # hasNxt :: BiMap v a b -> Maybe (a, b, BiMap v a b) Source # hasLub :: Ord k => k -> BiMap v k b -> Maybe (k, b, BiMap v k b) Source # haskey :: Ord key => key -> BiMap v key b -> Bool Source # isnull :: BiMap v k v0 -> Bool Source # lookup :: Ord key => key -> BiMap v key rng -> Maybe rng Source # element :: Ord k => k -> BiMap v k v0 -> Collect () Source # | |
Ord v => Basic (BiMap v) Source # | |
Defined in Control.Iterate.SetAlgebra Methods addpair :: Ord k => k -> v0 -> BiMap v k v0 -> BiMap v k v0 Source # addkv :: Ord k => (k, v0) -> BiMap v k v0 -> (v0 -> v0 -> v0) -> BiMap v k v0 Source # removekey :: Ord k => k -> BiMap v k v0 -> BiMap v k v0 Source # domain :: Ord k => BiMap v k v0 -> Set k Source # | |
(Ord k, Ord v) => HasExp (Bimap k v) (Bimap k v) Source # | |
(Eq k, Eq v) => Eq (BiMap u k v) Source # | |
(Show k, Show v) => Show (BiMap u k v) Source # | |
(Ord a, Ord b, ToCBOR a, ToCBOR b) => ToCBOR (BiMap b a b) Source # | |
(Ord a, Ord b, FromCBOR a, FromCBOR b) => FromCBOR (BiMap b a b) Source # | |
NFData (BiMap v a b) Source # | |
Defined in Control.Iterate.SetAlgebra | |
(NoThunks a, NoThunks b) => NoThunks (BiMap v a b) Source # | |
(Ord v, Ord k) => HasQuery (BiMap v k v) k v Source # | |
Embed (BiMap v k v) (BiMap v k v) Source # | |
decodeMapAsBimap :: (FromCBOR a, FromCBOR b, Ord a, Ord b) => Decoder s (BiMap b a b) Source #
Decode a serialised CBOR Map as a Bimap
biMapEmpty :: BiMap v k v Source #
Instances
Iter Sett Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: Sett a b -> Collect (a, b, Sett a b) Source # lub :: Ord k => k -> Sett k b -> Collect (k, b, Sett k b) Source # hasNxt :: Sett a b -> Maybe (a, b, Sett a b) Source # hasLub :: Ord k => k -> Sett k b -> Maybe (k, b, Sett k b) Source # haskey :: Ord key => key -> Sett key b -> Bool Source # isnull :: Sett k v -> Bool Source # lookup :: Ord key => key -> Sett key rng -> Maybe rng Source # | |
Basic Sett Source # | |
Defined in Control.Iterate.SetAlgebra | |
Ord k => HasExp (Set k) (Sett k ()) Source # | |
Embed (Set k) (Sett k ()) Source # | |
Eq k => Eq (Sett k ()) Source # | |
Show key => Show (Sett key ()) Source # | |
Methods
nxt :: f a b -> Collect (a, b, f a b) Source #
lub :: Ord k => k -> f k b -> Collect (k, b, f k b) Source #
hasNxt :: f a b -> Maybe (a, b, f a b) Source #
hasLub :: Ord k => k -> f k b -> Maybe (k, b, f k b) Source #
haskey :: Ord key => key -> f key b -> Bool Source #
isnull :: f k v -> Bool Source #
Instances
Iter Map Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: Map a b -> Collect (a, b, Map a b) Source # lub :: Ord k => k -> Map k b -> Collect (k, b, Map k b) Source # hasNxt :: Map a b -> Maybe (a, b, Map a b) Source # hasLub :: Ord k => k -> Map k b -> Maybe (k, b, Map k b) Source # haskey :: Ord key => key -> Map key b -> Bool Source # isnull :: Map k v -> Bool Source # lookup :: Ord key => key -> Map key rng -> Maybe rng Source # | |
Iter Query Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: Query a b -> Collect (a, b, Query a b) Source # lub :: Ord k => k -> Query k b -> Collect (k, b, Query k b) Source # hasNxt :: Query a b -> Maybe (a, b, Query a b) Source # hasLub :: Ord k => k -> Query k b -> Maybe (k, b, Query k b) Source # haskey :: Ord key => key -> Query key b -> Bool Source # isnull :: Query k v -> Bool Source # lookup :: Ord key => key -> Query key rng -> Maybe rng Source # | |
Iter List Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: List a b -> Collect (a, b, List a b) Source # lub :: Ord k => k -> List k b -> Collect (k, b, List k b) Source # hasNxt :: List a b -> Maybe (a, b, List a b) Source # hasLub :: Ord k => k -> List k b -> Maybe (k, b, List k b) Source # haskey :: Ord key => key -> List key b -> Bool Source # isnull :: List k v -> Bool Source # lookup :: Ord key => key -> List key rng -> Maybe rng Source # | |
Iter Sett Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: Sett a b -> Collect (a, b, Sett a b) Source # lub :: Ord k => k -> Sett k b -> Collect (k, b, Sett k b) Source # hasNxt :: Sett a b -> Maybe (a, b, Sett a b) Source # hasLub :: Ord k => k -> Sett k b -> Maybe (k, b, Sett k b) Source # haskey :: Ord key => key -> Sett key b -> Bool Source # isnull :: Sett k v -> Bool Source # lookup :: Ord key => key -> Sett key rng -> Maybe rng Source # | |
Iter Single Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: Single a b -> Collect (a, b, Single a b) Source # lub :: Ord k => k -> Single k b -> Collect (k, b, Single k b) Source # hasNxt :: Single a b -> Maybe (a, b, Single a b) Source # hasLub :: Ord k => k -> Single k b -> Maybe (k, b, Single k b) Source # haskey :: Ord key => key -> Single key b -> Bool Source # isnull :: Single k v -> Bool Source # lookup :: Ord key => key -> Single key rng -> Maybe rng Source # | |
Ord v => Iter (BiMap v) Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: BiMap v a b -> Collect (a, b, BiMap v a b) Source # lub :: Ord k => k -> BiMap v k b -> Collect (k, b, BiMap v k b) Source # hasNxt :: BiMap v a b -> Maybe (a, b, BiMap v a b) Source # hasLub :: Ord k => k -> BiMap v k b -> Maybe (k, b, BiMap v k b) Source # haskey :: Ord key => key -> BiMap v key b -> Bool Source # isnull :: BiMap v k v0 -> Bool Source # lookup :: Ord key => key -> BiMap v key rng -> Maybe rng Source # element :: Ord k => k -> BiMap v k v0 -> Collect () Source # |
Constructors
UnSafeList :: Ord k => [(k, v)] -> List k v |
Instances
Iter List Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: List a b -> Collect (a, b, List a b) Source # lub :: Ord k => k -> List k b -> Collect (k, b, List k b) Source # hasNxt :: List a b -> Maybe (a, b, List a b) Source # hasLub :: Ord k => k -> List k b -> Maybe (k, b, List k b) Source # haskey :: Ord key => key -> List key b -> Bool Source # isnull :: List k v -> Bool Source # lookup :: Ord key => key -> List key rng -> Maybe rng Source # | |
Basic List Source # | The constructor for List is hidden, since it requires some invariants. Use fromPairs to build an initial List. |
Defined in Control.Iterate.SetAlgebra | |
Ord k => HasExp [(k, v)] (List k v) Source # | |
Ord k => Embed [(k, v)] (List k v) Source # | |
(Eq k, Eq v) => Eq (List k v) Source # | |
(Show k, Show v) => Show (List k v) Source # | |
data StrictTriple a b c Source #
Constructors
StrictTriple !a !b !c |
intersectDomP :: Ord k => (k -> v2 -> Bool) -> Map k v1 -> Map k v2 -> Map k v2 Source #
intersetDomP p m1 m2 == Keep the key and value from m2, iff (the key is in the dom of m1) && ((p key value) is true)
intersectDomPLeft :: Ord k => (k -> v2 -> Bool) -> Map k v1 -> Map k v2 -> Map k v1 Source #
- Similar to intersectDomP, except the Map returned has the same key as the first input map, rather than the second input map.
intersectMapSetFold :: Ord k => (k -> v -> ans -> ans) -> Map k v -> Set k -> ans -> ans Source #
- fold over the intersection of a Map and a Set
disjointMapSetFold :: Ord k => (k -> v -> ans -> ans) -> Map k v -> Set k -> ans -> ans Source #
Fold with accum
all those pairs in the map, not appearing in the set.
The self typed GADT: Exp, that encodes the shape of Set expressions. A deep embedding. Exp is a typed Symbolic representation of queries we may ask. It allows us to introspect a query The strategy is to 1) Define Exp so all queries can be represented. 2) Define smart constructors that "parse" the surface syntax, and build a typed Exp 3) Write an evaluate function: eval:: Exp t -> t 4) "eval" can introspect the code and apply efficient domain and type specific translations 5) Use the (Iter f) class to evaluate some Exp that can benefit from its efficient nature. ===============================================================================================
Constructors
Base :: (Ord k, Basic f) => BaseRep f k v -> f k v -> Exp (f k v) | |
Dom :: Ord k => Exp (f k v) -> Exp (Sett k ()) | |
Rng :: (Ord k, Ord v) => Exp (f k v) -> Exp (Sett v ()) | |
DRestrict :: (Ord k, Iter g) => Exp (g k ()) -> Exp (f k v) -> Exp (f k v) | |
DExclude :: (Ord k, Iter g) => Exp (g k ()) -> Exp (f k v) -> Exp (f k v) | |
RRestrict :: (Ord k, Iter g, Ord v) => Exp (f k v) -> Exp (g v ()) -> Exp (f k v) | |
RExclude :: (Ord k, Iter g, Ord v) => Exp (f k v) -> Exp (g v ()) -> Exp (f k v) | |
Elem :: (Ord k, Iter g, Show k) => k -> Exp (g k ()) -> Exp Bool | |
NotElem :: (Ord k, Iter g, Show k) => k -> Exp (g k ()) -> Exp Bool | |
Intersect :: (Ord k, Iter f, Iter g) => Exp (f k v) -> Exp (g k u) -> Exp (Sett k ()) | |
Subset :: (Ord k, Iter f, Iter g) => Exp (f k v) -> Exp (g k u) -> Exp Bool | |
SetDiff :: (Ord k, Iter f, Iter g) => Exp (f k v) -> Exp (g k u) -> Exp (f k v) | |
UnionOverrideLeft :: (Show k, Show v, Ord k) => Exp (f k v) -> Exp (g k v) -> Exp (f k v) | |
UnionPlus :: (Ord k, Monoid n) => Exp (f k n) -> Exp (f k n) -> Exp (f k n) | |
UnionOverrideRight :: Ord k => Exp (f k v) -> Exp (g k v) -> Exp (f k v) | |
Singleton :: Ord k => k -> v -> Exp (Single k v) | |
SetSingleton :: Ord k => k -> Exp (Single k ()) | |
KeyEqual :: (Ord k, Iter f, Iter g) => Exp (f k v) -> Exp (g k u) -> Exp Bool |
class HasExp s t | s -> t where Source #
Basic types are those that can be embedded into Exp.
The HasExp class, encodes how to lift a Basic type into an Exp.
The function toExp
will build a typed Exp for that Basic type.
This will be really usefull in the smart constructors.
==================================================================
Instances
HasExp (Exp t) t Source # | The simplest Base type is one that is already an Exp |
Ord k => HasExp [(k, v)] (List k v) Source # | |
Ord k => HasExp (Set k) (Sett k ()) Source # | |
Ord k => HasExp (Map k v) (Map k v) Source # | |
(Ord k, Ord v) => HasExp (Bimap k v) (Bimap k v) Source # | |
Ord k => HasExp (Single k v) (Single k v) Source # | |
dexclude :: (Ord k, Iter g, HasExp s1 (g k ()), HasExp s2 (f k v)) => s1 -> s2 -> Exp (f k v) Source #
(▷) :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v) Source #
(|>) :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v) Source #
rrestrict :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v) Source #
(⋫) :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v) Source #
rexclude :: (Ord k, Iter g, Ord v, HasExp s1 (f k v), HasExp s2 (g v ())) => s1 -> s2 -> Exp (f k v) Source #
(∪) :: (Show k, Show v, Ord k, HasExp s1 (f k v), HasExp s2 (g k v)) => s1 -> s2 -> Exp (f k v) Source #
unionleft :: (Show k, Show v, Ord k, HasExp s1 (f k v), HasExp s2 (g k v)) => s1 -> s2 -> Exp (f k v) Source #
unionplus :: (Ord k, Monoid n, HasExp s1 (f k n), HasExp s2 (f k n)) => s1 -> s2 -> Exp (f k n) Source #
(∩) :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp (Sett k ()) Source #
intersect :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp (Sett k ()) Source #
(⊆) :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp Bool Source #
subset :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp Bool Source #
(➖) :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp (f k v) Source #
setdiff :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp (f k v) Source #
(≍) :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp Bool Source #
keyeq :: (Ord k, Iter f, Iter g, HasExp s1 (f k v), HasExp s2 (g k u)) => s1 -> s2 -> Exp Bool Source #
Symbolc functions (Fun) are data, that can be pattern matched over. They 1) Represent a wide class of binary functions that are used in translating the SetAlgebra 2) Turned into a String so they can be printed 3) Turned into the function they represent. 4) Composed into bigger functions 5) Symbolically symplified Here we implement Symbolic Binary functions with upto 4 variables, which is enough for this use =================================================================================================
data Expr env t where Source #
Constructors
X1 :: Expr (d, c, b, a) d | |
X2 :: Expr (d, c, b, a) c | |
X3 :: Expr (d, c, b, a) b | |
X4 :: Expr (d, c, b, a) a | |
HasKey :: (Iter f, Ord k) => Expr e k -> f k v -> Expr e Bool | |
Neg :: Expr e Bool -> Expr e Bool | |
Ap :: Lam (a -> b -> c) -> Expr e a -> Expr e b -> Expr e c | |
EPair :: Expr e a -> Expr e b -> Expr e (a, b) | |
FST :: Expr e (a, b) -> Expr e a | |
SND :: Expr e (a, b) -> Expr e b | |
Lit :: Show t => t -> Expr env t |
materialize :: Ord k => BaseRep f k v -> Collect (k, v) -> f k v Source #
Given a BaseRep we can materialize a (Collect k v) into the type witnessed by the BaseRep. Recall a (Collect k v) has no intrinsic type (it is just an ABSTRACT sequence of tuples), so the witness describes how to turn them into the chosen datatype. Note that materialize is meant to be applied to a collection built by iterating over a Query. This produces the keys in ascending order, with no duplicate keys. So we do not need to specify how to merge values. =============================================================================================
Constructors
BaseD :: (Iter f, Ord k) => BaseRep f k v -> f k v -> Query k v | |
ProjectD :: Ord k => Query k v -> Fun (k -> v -> u) -> Query k u | |
AndD :: Ord k => Query k v -> Query k w -> Query k (v, w) | |
ChainD :: (Ord k, Ord v) => Query k v -> Query v w -> Fun (k -> (v, w) -> u) -> Query k u | |
AndPD :: Ord k => Query k v -> Query k u -> Fun (k -> (v, u) -> w) -> Query k w | |
OrD :: Ord k => Query k v -> Query k v -> Fun (v -> v -> v) -> Query k v | |
GuardD :: Ord k => Query k v -> Fun (k -> v -> Bool) -> Query k v | |
DiffD :: Ord k => Query k v -> Query k u -> Query k v |
Instances
Iter Query Source # | |
Defined in Control.Iterate.SetAlgebra Methods nxt :: Query a b -> Collect (a, b, Query a b) Source # lub :: Ord k => k -> Query k b -> Collect (k, b, Query k b) Source # hasNxt :: Query a b -> Maybe (a, b, Query a b) Source # hasLub :: Ord k => k -> Query k b -> Maybe (k, b, Query k b) Source # haskey :: Ord key => key -> Query key b -> Bool Source # isnull :: Query k v -> Bool Source # lookup :: Ord key => key -> Query key rng -> Maybe rng Source # | |
Show (Query k v) Source # | |
HasQuery (Query k v) k v Source # | |
compileSubterm :: Exp a -> Exp (f k v) -> Query k v Source #
Compile the (Exp (f k v)) to a Query iterator, and a BaseRep that indicates how to materialize the iterator to the correct type. Recall the iterator can be used to constuct many things using runCollect, but here we want to materialize it to the same type as the (Exp (f k v)), i.e. (f k v). ================================================================================
projStep :: Ord k => (t -> Collect (k, v, Query k v)) -> Fun (k -> v -> u) -> t -> Collect (k, u, Query k u) Source #
andStep :: Ord a => (a, b1, Query a b1) -> (a, b2, Query a b2) -> Collect (a, (b1, b2), Query a (b1, b2)) Source #
chainStep :: (Ord b, Ord a) => (a, b, Query a b) -> Query b w -> Fun (a -> (b, w) -> u) -> Collect (a, u, Query a u) Source #
andPstep :: Ord a => (a, b1, Query a b1) -> (a, b2, Query a b2) -> Fun (a -> (b1, b2) -> w) -> Collect (a, w, Query a w) Source #
orStep :: (Ord k, Ord a) => (Query k v -> Collect (a, v, Query k v)) -> Query k v -> Query k v -> Fun (v -> v -> v) -> Collect (a, v, Query k v) Source #
guardStep :: Ord a => (Query a b -> Collect (a, b, Query a b)) -> Fun (a -> b -> Bool) -> Query a b -> Collect (a, b, Query a b) Source #
andQ :: (Ord k, HasQuery concrete1 k v, HasQuery concrete2 k w) => concrete1 -> concrete2 -> Query k (v, w) Source #
orQ :: (Ord k, HasQuery concrete1 k v, HasQuery concrete2 k v) => concrete1 -> concrete2 -> Fun (v -> v -> v) -> Query k v Source #
chainQ :: (Ord k, Ord v, HasQuery concrete1 k v, HasQuery concrete2 v w) => concrete1 -> concrete2 -> Fun (k -> (v, w) -> u) -> Query k u Source #
andPQ :: (Ord k, HasQuery concrete1 k v, HasQuery concrete2 k u) => concrete1 -> concrete2 -> Fun (k -> (v, u) -> w) -> Query k w Source #
class HasQuery concrete k v where Source #