set-algebra-0.1.0.0: Set Algebra
Safe Haskell None
Language Haskell2010

Control.Iterate.SetAlgebra

Description

Supports writing 'Set algebra' expressions, using overloaded set operations, that can be applied to a variety of Basic types (Set, List, Map, BiMap etc). Also supports a mechanism to evaluate them efficiently, choosing datatype specific algorithms. This mechanism uses run-time rewrite rules to get the best algorithm. If there are no rewrite rules for a specific expression, falls back to a less efficient generic algorithm.

Synopsis

Documentation

compile :: Exp (f k v) -> ( Query k v, BaseRep f 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).

run :: Ord k => ( Query k v, BaseRep f k v) -> f k v Source #

runSet :: Ord k => Exp (f k v) -> f k v Source #

sameDomain :: ( Ord k, Iter f, Iter g) => f k b -> g k c -> Bool Source #

cost O(min (size m) (size n) * log(max (size m) (size n))), BUT the constants are high, too slow except for small maps.

addp :: ( Ord k, Basic f) => (v -> v -> v) -> (k, v) -> f k v -> f k v Source #

fromList :: Ord k => BaseRep f k v -> (v -> v -> v) -> [(k, v)] -> f k v Source #

materialize :: Ord k => BaseRep f k v -> Collect (k, v) -> f k v Source #

A witness (BaseRep) can be used to 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 duplicate values.

(⨝) :: ( Ord k, Iter f, Iter g) => f k b -> g k c -> Collect (k, b, c) Source #

domEq :: ( Ord k, Iter f, Iter g) => f k b -> g k c -> Collect (k, b, c) Source #

domEqSlow :: ( Ord k, Iter f, Iter g) => f k b -> g k c -> Collect (k, b, c) Source #