Safe Haskell | None |
---|---|
Language | Haskell2010 |
Derived encodings for standard datatypes.
This module contains a number of useful constructions which can be defined using the constructions from Basic.
- unit :: Encoding ()
- void :: Encoding b
- nonEmptySeq :: Encoding ty -> Encoding [ty]
- nonEmptyOptionSeq :: Encoding ty -> Encoding [Maybe ty]
- nonEmptySet :: Ord ty => Encoding ty -> Encoding (Set ty)
- nonEmptyHashSet :: (Hashable ty, Ord ty) => Encoding ty -> Encoding (HashSet ty)
- function :: Ord keyty => Encoding keyty -> Encoding valty -> Encoding (Map keyty valty)
- functionHashable :: (Ord keyty, Hashable keyty) => Encoding keyty -> Encoding valty -> Encoding (HashMap keyty valty)
- relation :: (Ord keyty, Ord valty) => Encoding keyty -> Encoding valty -> Encoding (Map keyty (Set valty))
- relationHashable :: (Hashable keyty, Ord keyty, Hashable valty, Ord valty) => Encoding keyty -> Encoding valty -> Encoding (HashMap keyty (HashSet valty))
- tree :: Encoding ty -> Encoding (Tree ty)
Simple Encodings
Non-Empty Containers
Build an encoding that produces non-empty sequences from an encoding for the elements of the sequence.
Build an encoding for lists of Maybe
s, where the last element
of the list is always guaranteed not to be Nothing
. This is
useful for building function encodings.
Build an encoding that produces non-empty sets from an encoding for the elements of the set.
Build an encoding that produces non-empty hash sets from an encoding for the elements of the set.
Functions and Relations
:: Ord keyty | |
=> Encoding keyty | The encoding for the domain type (ie. key type) |
-> Encoding valty | The encoding for the range type (ie. value type) |
-> Encoding (Map keyty valty) |
Build an encoding that produces a (finite partial) function from
one type to another. This function is represented using a Map
.
:: (Ord keyty, Hashable keyty) | |
=> Encoding keyty | The encoding for the domain type (ie. key type) |
-> Encoding valty | The encoding for the range type (ie. value type) |
-> Encoding (HashMap keyty valty) |
Build an encoding that produces a (finite partial) function from
one type to another. This function is represented using a HashMap
.
:: (Ord keyty, Ord valty) | |
=> Encoding keyty | The encoding for the left-hand type (ie. key type) |
-> Encoding valty | The encoding for the right-hand type (ie. value type) |
-> Encoding (Map keyty (Set valty)) |
Build an encoding that produces relations between two types.
These relations are represented as Map
s from the first type to
Set
s of the second.
:: (Hashable keyty, Ord keyty, Hashable valty, Ord valty) | |
=> Encoding keyty | The encoding for the left-hand type (ie. key type) |
-> Encoding valty | The encoding for the right-hand type (ie. value type) |
-> Encoding (HashMap keyty (HashSet valty)) |
Build an encoding that produces relations between two types.
These relations are represented as HashMap
s from the first type to
HashSet
s of the second.