syntactic-1.11: Generic abstract syntax, and utilities for embedded languages

Safe HaskellNone

Language.Syntactic.Sharing.Utils

Contents

Description

Some utility functions used by the other modules

Synopsis

Difference lists

type DList a = [a] -> [a]Source

Difference list

empty :: DList aSource

Empty list

single :: a -> DList aSource

Singleton list

Misc.

reindex :: (Integral a, Ix a) => [a] -> a -> aSource

Given a list is of unique natural numbers, returns a function that maps each number in is to a unique number in the range [0 .. length is-1]. The complexity is O(maximum is).

countSource

Arguments

:: Ix a 
=> (a, a)

Upper and lower bound on the elements to be counted

-> [a]

Elements to be counted

-> Array a Int 

Count the number of occurrences of each element in the list. The result is an array mapping each element to its number of occurrences.

fullPartition :: (a -> a -> Bool) -> [a] -> [[a]]Source

Partitions the list such that two elements are in the same sub-list if and only if they satisfy the equivalence check. The complexity is O(n^2).