polymap-0.1.1.0: Polygonal maps

Copyright(c) 2015 David Farrell
LicensePublicDomain
Stabilityunstable
Portabilitynon-portable (GHC extensions)
Safe HaskellSafe
LanguageHaskell2010

Data.PolyMap

Contents

Description

Polygonal maps for Haskell with flexible storage.

Synopsis

Documentation

PolyMap Type

data family PolyMap as Source

A polymap whose sides are defined by a list of types zipped with storage types.

Instances

(Show a, Show (s a), Show (PolyMap as)) => Show (PolyMap ((:) ((,) * (* -> *)) ((,) * (* -> *) a s) as)) Source 
Show (PolyMap ([] ((,) * (* -> *)))) Source 
data PolyMap ([] ((,) * (* -> *))) = UnitPolyMap Source 
data PolyMap ((:) ((,) * (* -> *)) ((,) * (* -> *) a s) as) = (s a) :<=>: (PolyMap as) Source 

type SimplePolyMap as s = PolyMap (MapStorage s as) Source

A simple polymap whose sides are defined by a list of types and a single storage type.

Query

null :: PolyMapClass as => PolyMap as -> Bool Source

Is the polymap empty?

size :: PolyMapClass as => PolyMap as -> Int Source

The number of relations in the polymap.

member :: PolyMapLookup n as => Proxy n -> TypeAt n (MapFst as) -> PolyMap as -> Bool Source

Is the key a member at the specified side of the polymap.

notMember :: PolyMapLookup n as => Proxy n -> TypeAt n (MapFst as) -> PolyMap as -> Bool Source

Is the key not a member at the specified side of the polymap? See also member.

lookup :: (PolyMapClass as, PolyMapLookup n as) => Proxy n -> TypeAt n (MapFst as) -> PolyMap as -> Maybe (Relation (MapFst as)) Source

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.

Construction

empty :: PolyMapClass as => PolyMap as Source

The empty polymap.

singleton :: (PolyMapClass as, ToRelation a (MapFst as)) => a -> PolyMap as Source

A polymap with a single relation.

Insertion

insert :: (PolyMapClass as, ToRelation a (MapFst as)) => a -> PolyMap as -> PolyMap as Source

Insert a new relation into the polymap.

Indexed

lookupIndex :: PolyMapLookup n as => Proxy n -> TypeAt n (MapFst as) -> PolyMap as -> Maybe Int Source

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.

lookupRelation :: PolyMapClass as => Int -> PolyMap as -> Maybe (Relation (MapFst as)) Source

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.