keyed-0.3.0.0: Generic indexing for many data structures

Copyright(c) William Yager 2015
LicenseBSD
Maintainerwill (dot) yager (at) gmail (dot) com
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Keyed

Description

This module provides functions for generic indexing of data structures.

Synopsis

Documentation

class Keyed d where Source

Data structures that allow lookup of values.

Associated Types

type Key d Source

The key to look up by.

type Value d Source

The value that is returned.

Methods

index :: d -> Key d -> Value d Source

Raises an exception on invalid key.

lookup :: d -> Key d -> Maybe (Value d) Source

Returns Nothing on invalid key.

Instances

Keyed [a] 
Keyed (Seq a) 
Keyed (Vector a) 
Unbox a => Keyed (Vector a) 
Storable a => Keyed (Vector a) 
Prim a => Keyed (Vector a) 
Ord k => Keyed (Map k v) 

(!) :: Keyed d => d -> Key d -> Value d Source

An inline version of index.

(!?) :: Keyed d => d -> Key d -> Maybe (Value d) Source

An inline version of lookup.