haskelldb-2.1.1: A library of combinators for generating and executing SQL statements.

Portabilitynon-portable
Stabilityexperimental
Maintainerhaskelldb-users@lists.sourceforge.net

Database.HaskellDB.BoundedList

Description

The main idea of bounded lists is to create lists with predetermined maximum size.

BoundedList is a simple, fast and type safe approach to implementing this idea. The implementation is based on inductive instances, making it very easy to expand with new bounds. A new bound only requires one instance of size and two instances of Less.

BoundedList works as follows. Every bound is build up by declaring a data-type representing the new bound. The instance of size only returns the size as an Int. The first instance of Less is for telling the typechecker that this bound is greater than the largest smaller bound. The second instance of Less is used by the typechecker to construct a chain of instances if there is no hardcoded instance available. This way the type checker can determine if a bound is smaller/greater then any other bound.

This inductive approach gives the complexity O(n) on the number of instances and very short type checking times compared to an O(n^2) implementation.

BoundedList also comes with a few utility function for manipulation an contructing bounded lists.

To be noted: Since each bound is a unique type: Explicit shrink and/or grow is needed before using (==). BoundedList does not have an instance of Ordering. (This might change)

Synopsis

Documentation

shrink :: (Size n, Size m) => BoundedList a n -> Maybe (BoundedList a m)Source

Shrinks the BoundedList supplied if it can do so without truncating the list. Returns Nothing if the list inside was to long.

grow :: LessEq n m => BoundedList a n -> BoundedList a mSource

Takes a BoundedList add grows it size.

trunc :: Size n => [a] -> BoundedList a nSource

Takes a list and transforms it to a BoundedList. If the list doesn'n fit, the list is truncated to make it fit into the bounded list.

listBound :: Size n => BoundedList a n -> IntSource

Returns the length of a BoundedList.

toBounded :: Size n => [a] -> Maybe (BoundedList a n)Source

Takes a list and transforms it to a BoundedList. If the list doesn't fit, Nothing is returned.

fromBounded :: Size n => BoundedList a n -> [a]Source

Takes a BoundedList and return the list inside.

class Size n Source

data N0 Source

data N1 Source

data N2 Source

data N3 Source

data N4 Source

data N5 Source

data N6 Source

data N7 Source

data N8 Source

data N9 Source

data N10 Source

data N11 Source

data N12 Source

data N13 Source

data N14 Source

data N15 Source

data N16 Source

data N17 Source

data N18 Source

data N19 Source

data N20 Source

data N21 Source

data N22 Source

data N23 Source

data N24 Source

data N25 Source

data N26 Source

data N27 Source

data N28 Source

data N29 Source

data N30 Source

data N31 Source

data N32 Source

data N33 Source

data N34 Source

data N35 Source

data N36 Source

data N37 Source

data N38 Source

data N39 Source

data N40 Source

data N41 Source

data N42 Source

data N43 Source

data N44 Source

data N45 Source

data N46 Source

data N47 Source

data N48 Source

data N49 Source

data N50 Source

data N51 Source

data N52 Source

data N53 Source

data N54 Source

data N55 Source

data N56 Source

data N57 Source

data N58 Source

data N59 Source

data N60 Source

data N61 Source

data N62 Source

data N63 Source

data N64 Source

data N65 Source

data N66 Source

data N67 Source

data N68 Source

data N69 Source

data N70 Source

data N71 Source

data N72 Source

data N73 Source

data N74 Source

data N75 Source

data N76 Source

data N77 Source

data N78 Source

data N79 Source

data N80 Source

data N81 Source

data N82 Source

data N83 Source

data N84 Source

data N85 Source

data N86 Source

data N87 Source

data N88 Source

data N89 Source

data N90 Source

data N91 Source

data N92 Source

data N93 Source

data N94 Source

data N95 Source

data N96 Source

data N97 Source

data N98 Source

data N99 Source