arith-encode-1.0.2: A practical arithmetic encoding (aka Godel numbering) library.

Data.ArithEncode.Util

Description

Derived encodings for standard datatypes.

This module contains a number of useful constructions which can be defined using the constructions from Basic.

Synopsis

# Simple Encodings

An encoding that produces ().

An empty encoding, which contains no mappings.

# Non-Empty Containers

Arguments

 :: Encoding ty The encoding for the element type -> Encoding [ty]

Build an encoding that produces non-empty sequences from an encoding for the elements of the sequence.

Arguments

 :: Encoding ty The encoding for the element type -> Encoding [Maybe ty]

Build an encoding for lists of Maybes, where the last element of the list is always guaranteed not to be Nothing. This is useful for building function encodings.

Arguments

 :: Ord ty => Encoding ty The encoding for the element type -> Encoding (Set ty)

Build an encoding that produces non-empty sets from an encoding for the elements of the set.

Arguments

 :: (Hashable ty, Ord ty) => Encoding ty The encoding for the element type -> Encoding (HashSet ty)

Build an encoding that produces non-empty hash sets from an encoding for the elements of the set.

# Functions and Relations

Arguments

 :: 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.

Arguments

 :: (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.

Arguments

 :: (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 Maps from the first type to Sets of the second.

Arguments

 :: (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 HashMaps from the first type to HashSets of the second.

# Trees

Arguments

 :: Encoding ty The encoding for the node data type -> Encoding (Tree ty)

Build an encoding that produces trees from an encoding for the node labels.