-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Polydirectional maps -- -- Polydirectional maps for Haskell with flexible storage. @package polymap @version 0.1.0.1 -- | Natural numbers defined at the type level with a proxy defined for the -- promoted kind. module Data.PolyMap.Nat data Nat Z :: Nat S :: Nat -> Nat data Proxy (a :: Nat) Proxy :: Proxy first :: Proxy Z second :: Proxy (S Z) third :: Proxy (S (S Z)) fourth :: Proxy (S (S (S Z))) fifth :: Proxy (S (S (S (S Z)))) sixth :: Proxy (S (S (S (S (S Z))))) seventh :: Proxy (S (S (S (S (S (S Z)))))) eigthth :: Proxy (S (S (S (S (S (S (S Z))))))) ninth :: Proxy (S (S (S (S (S (S (S (S Z)))))))) tenth :: Proxy (S (S (S (S (S (S (S (S (S Z))))))))) -- | Storage typeclass for polymaps. module Data.PolyMap.Storage class (Monoid (s a), Foldable s) => Storage s a singleton :: Storage s a => a -> s a lookupIndex :: (Storage s a, Eq a) => a -> s a -> Maybe Int lookupElem :: Storage s a => Int -> s a -> Maybe a -- | Storage instance for Data.Set. module Data.PolyMap.Storage.Set -- | A set of values a. data Set a :: * -> * instance GHC.Classes.Ord a => Data.PolyMap.Storage.Storage Data.Set.Base.Set a -- | Storage instance for []. module Data.PolyMap.Storage.List instance Data.PolyMap.Storage.Storage [] a -- | Relation type family and helper function to create relations from -- tuples. module Data.PolyMap.Relation class ToRelation a (as :: [*]) toRelation :: ToRelation a as => a -> Relation as instance GHC.Show.Show (Data.PolyMap.Relation.Relation '[]) instance (GHC.Show.Show a, GHC.Show.Show (Data.PolyMap.Relation.Relation as)) => GHC.Show.Show (Data.PolyMap.Relation.Relation (a : as)) instance Data.PolyMap.Relation.ToRelation (Data.PolyMap.Relation.Relation as) as instance Data.PolyMap.Relation.ToRelation () '[] instance Data.PolyMap.Relation.ToRelation a0 '[a0] instance Data.PolyMap.Relation.ToRelation (a0, a1) '[a0, a1] instance Data.PolyMap.Relation.ToRelation (a0, a1, a2) '[a0, a1, a2] instance Data.PolyMap.Relation.ToRelation (a0, a1, a2, a3) '[a0, a1, a2, a3] instance Data.PolyMap.Relation.ToRelation (a0, a1, a2, a3, a4) '[a0, a1, a2, a3, a4] instance Data.PolyMap.Relation.ToRelation (a0, a1, a2, a3, a4, a5) '[a0, a1, a2, a3, a4, a5] instance Data.PolyMap.Relation.ToRelation (a0, a1, a2, a3, a4, a5, a6) '[a0, a1, a2, a3, a4, a5, a6] instance Data.PolyMap.Relation.ToRelation (a0, a1, a2, a3, a4, a5, a6, a7) '[a0, a1, a2, a3, a4, a5, a6, a7] instance Data.PolyMap.Relation.ToRelation (a0, a1, a2, a3, a4, a5, a6, a7, a8) '[a0, a1, a2, a3, a4, a5, a6, a7, a8] instance Data.PolyMap.Relation.ToRelation (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) '[a0, a1, a2, a3, a4, a5, a6, a7, a8, a9] -- | Polydirectional maps for Haskell with flexible storage. module Data.PolyMap -- | A polymap whose sides are defined by a list of types zipped with -- storage types. -- | A simple polymap whose sides are defined by a list of types and a -- single storage type. type SimplePolyMap (as :: [*]) (s :: * -> *) = PolyMap (MapStorage s as) -- | Is the polymap empty? null :: PolyMapClass as => PolyMap as -> Bool -- | The number of relations in the polymap. size :: PolyMapClass as => PolyMap as -> Int -- | Is the key a member at the specified side of the polymap. member :: PolyMapLookup n as => Proxy n -> TypeAt n (MapFst as) -> PolyMap as -> Bool -- | Is the key not a member at the specified side of the polymap? See also -- member. notMember :: PolyMapLookup n as => Proxy n -> TypeAt n (MapFst as) -> PolyMap as -> Bool -- | Lookup the value at a key at the specified side of the polymap. -- -- The function will return the corresponding value as (Just -- value), or Nothing if the key isn't at the specified side -- of the polymap. lookup :: (PolyMapClass as, PolyMapLookup n as) => Proxy n -> TypeAt n (MapFst as) -> PolyMap as -> Maybe (Relation (MapFst as)) -- | The empty polymap. empty :: PolyMapClass as => PolyMap as -- | A polymap with a single relation. singleton :: (PolyMapClass as, ToRelation a (MapFst as)) => a -> PolyMap as -- | Insert a new relation into the polymap. insert :: (PolyMapClass as, ToRelation a (MapFst as)) => a -> PolyMap as -> PolyMap as -- | Lookup the index of a key, which is its zero-based index in the -- storage at the specified side of the polymap. The index is a number -- from 0 up to, but not including, the size of the -- polymap. lookupIndex :: PolyMapLookup n as => Proxy n -> TypeAt n (MapFst as) -> PolyMap as -> Maybe Int -- | Retrieve a relation by its index, i.e. by the zero-based index -- of the storage of each of its sides. The index is a number from -- 0 up to, but not including, the size of the polymap. lookupRelation :: PolyMapClass as => Int -> PolyMap as -> Maybe (Relation (MapFst as)) instance GHC.Show.Show (Data.PolyMap.PolyMap '[]) instance (GHC.Show.Show a, GHC.Show.Show (s a), GHC.Show.Show (Data.PolyMap.PolyMap as)) => GHC.Show.Show (Data.PolyMap.PolyMap ('(a, s) : as)) instance Data.PolyMap.PolyMapClass '[] instance (Data.PolyMap.Storage.Storage s a, Data.PolyMap.PolyMapClass as) => Data.PolyMap.PolyMapClass ('(a, s) : as) instance Data.PolyMap.PolyMapLookup n '[] instance (GHC.Classes.Eq a, Data.PolyMap.Storage.Storage s a) => Data.PolyMap.PolyMapLookup 'Data.PolyMap.Nat.Z ('(a, s) : as) instance (Data.PolyMap.Storage.Storage s a, Data.PolyMap.PolyMapLookup n as) => Data.PolyMap.PolyMapLookup ('Data.PolyMap.Nat.S n) ('(a, s) : as)