type-level-kv-list-2.0.1.2: Type level Key-Value list.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.KVList

Description

This library provide a brief implementation for extensible records. It is sensitive to the ordering of key-value items, but has simple type constraints and provides short compile time.

Synopsis

Constructors

We can create type level KV list as follows.

>>> :set -XOverloadedLabels -XTypeOperators
>>> import Prelude
>>> import Data.KVList (empty, KVList, (:=)((:=)), (&.), (&=))
>>> let sampleList = empty &= #foo := "str" &= #bar := 34
>>> type SampleList = KVList '[ "foo" := String, "bar" := Int ]

data KVList (kvs :: [Type]) Source #

A value with type level key.

Instances

Instances details
ShowFields (KVList kvs) => Show (KVList kvs) Source # 
Instance details

Defined in Data.KVList

Methods

showsPrec :: Int -> KVList kvs -> ShowS #

show :: KVList kvs -> String #

showList :: [KVList kvs] -> ShowS #

(Eq v, Eq (KVList kvs)) => Eq (KVList ((k := v) ': kvs)) Source # 
Instance details

Defined in Data.KVList

Methods

(==) :: KVList ((k := v) ': kvs) -> KVList ((k := v) ': kvs) -> Bool #

(/=) :: KVList ((k := v) ': kvs) -> KVList ((k := v) ': kvs) -> Bool #

Eq (KVList ('[] :: [Type])) Source # 
Instance details

Defined in Data.KVList

Methods

(==) :: KVList '[] -> KVList '[] -> Bool #

(/=) :: KVList '[] -> KVList '[] -> Bool #

data (key :: Symbol) := (value :: Type) where infix 2 Source #

 

Constructors

(:=) :: ListKey a -> b -> a := b infix 2 

Instances

Instances details
(Eq v, Eq (KVList kvs)) => Eq (KVList ((k := v) ': kvs)) Source # 
Instance details

Defined in Data.KVList

Methods

(==) :: KVList ((k := v) ': kvs) -> KVList ((k := v) ': kvs) -> Bool #

(/=) :: KVList ((k := v) ': kvs) -> KVList ((k := v) ': kvs) -> Bool #

Show value => Show (key := value) Source # 
Instance details

Defined in Data.KVList

Methods

showsPrec :: Int -> (key := value) -> ShowS #

show :: (key := value) -> String #

showList :: [key := value] -> ShowS #

(&=) :: (KnownSymbol k, Appended kvs '[k := v] ~ appended) => KVList kvs -> (k := v) -> KVList appended infixl 1 Source #

 

(&=>) :: (Applicative f, KnownSymbol k, Appended kvs '[k := v] ~ appended) => f (KVList kvs) -> (k := f v) -> f (KVList appended) infixl 1 Source #

Applicative version of (&=). - - >>> pure KVList.empty - >>> &=> #foo := (Just 3) - >>> &=> #bar := (Just "bar") - Just $ KVList.empty &= #foo := 3 &= #bar := "bar" - - >>> pure KVList.empty - >>> &=> #foo := (Just 3) - >>> &=> #bar := Nothing - Nothing

kvcons :: KnownSymbol k => (k := v) -> KVList kvs -> KVList ((k := v) ': kvs) Source #

 

empty :: KVList '[] Source #

 

singleton :: KnownSymbol k => (k := v) -> KVList '[k := v] Source #

 

data ListKey (t :: Symbol) Source #

ListKey is just a proxy, but needed to implement a non-orphan IsLabel instance. In most cases, you only need to create a ListKey instance with OverloadedLabels, such as `#foo`.

Constructors

ListKey 

Instances

Instances details
l ~ l' => IsLabel l (ListKey l') Source # 
Instance details

Defined in Data.KVList

Methods

fromLabel :: ListKey l' #

Show (ListKey t) Source # 
Instance details

Defined in Data.KVList

Methods

showsPrec :: Int -> ListKey t -> ShowS #

show :: ListKey t -> String #

showList :: [ListKey t] -> ShowS #

Eq (ListKey t) Source # 
Instance details

Defined in Data.KVList

Methods

(==) :: ListKey t -> ListKey t -> Bool #

(/=) :: ListKey t -> ListKey t -> Bool #

Operators

get :: (KnownSymbol key, HasKey key kvs v) => ListKey key -> KVList kvs -> v Source #

 

type HasKey (key :: Symbol) (kvs :: [Type]) (v :: Type) = HasKey_ key kvs kvs v Source #

 

(&.) :: (KnownSymbol key, HasKey key kvs v) => KVList kvs -> ListKey key -> v infixl 9 Source #