Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
This module provides a class ArrayMap
and a concrete implementation with ConstArray
for
McCarthy's basic array theory.
Synopsis
- class ArrayMap f k v where
- asConst :: forall f k v. ArrayMap f k v => v -> f k v
- data ConstArray k v = ConstArray {}
- arrConst :: forall k v. Lens' (ConstArray k v) v
- stored :: forall k v k. Lens (ConstArray k v) (ConstArray k v) (Map k v) (Map k v)
Class
class ArrayMap f k v where Source #
Class that allows access to a map-like array where any value is either the default value or an overwritten values. Every index has a value by default. Values at indices can be overwritten manually.
Based on McCarthy`s basic array theory.
Therefore the following axioms must hold:
- forall A i x: arrSelect (arrStore i x) == x
- forall A i j x: i /= j ==> (arrSelect (arrStore i x) j === arrSelect A j)
asConst' :: Proxy f -> Proxy k -> v -> f k v Source #
Construct an ArrayMap
via it's const value.
viewConst :: f k v -> v Source #
View the const value of the ArrayMap
.
arrSelect :: f k v -> k -> v Source #
Select a value from the ArrayMap
.
Returns the specific value for given key if there is one. Returns the const value otherwise.
arrStore :: f k v -> k -> v -> f k v Source #
Store a specific value at a given key in an ArrayMap
.
Instances
Ord k => ArrayMap ConstArray k v Source # | |
Defined in Language.Hasmtlib.Type.ArrayMap asConst' :: Proxy ConstArray -> Proxy k -> v -> ConstArray k v Source # viewConst :: ConstArray k v -> v Source # arrSelect :: ConstArray k v -> k -> v Source # arrStore :: ConstArray k v -> k -> v -> ConstArray k v Source # |
Type
data ConstArray k v Source #
A map-like array with a default constant value and partially overwritten values.
Instances
Lens
arrConst :: forall k v. Lens' (ConstArray k v) v Source #
stored :: forall k v k. Lens (ConstArray k v) (ConstArray k v) (Map k v) (Map k v) Source #