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

Safe HaskellNone
LanguageHaskell2010

Data.ArithEncode.Util

Contents

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

unit :: Encoding () Source

An encoding that produces ().

void :: Encoding b Source

An empty encoding, which contains no mappings.

Non-Empty Containers

nonEmptySeq Source

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.

nonEmptyOptionSeq Source

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.

nonEmptySet Source

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.

nonEmptyHashSet Source

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

function Source

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.

functionHashable Source

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.

relation Source

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.

relationHashable Source

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

tree Source

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.