haskelldb-0.10: SQL unwrapper for Haskell.ContentsIndex
Database.HaskellDB.BoundedList
Portabilitynon-portable
Stabilityexperimental
Maintainerhaskelldb-users@lists.sourceforge.net
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
shrink :: (Size n, Size m) => BoundedList a n -> Maybe (BoundedList a m)
grow :: LessEq n m => BoundedList a n -> BoundedList a m
trunc :: Size n => [a] -> BoundedList a n
listBound :: Size n => BoundedList a n -> Int
toBounded :: Size n => [a] -> Maybe (BoundedList a n)
fromBounded :: Size n => BoundedList a n -> [a]
class Size n
data BoundedList a n
data N0
data N1
data N2
data N3
data N4
data N5
data N6
data N7
data N8
data N9
data N10
data N11
data N12
data N13
data N14
data N15
data N16
data N17
data N18
data N19
data N20
data N21
data N22
data N23
data N24
data N25
data N26
data N27
data N28
data N29
data N30
data N31
data N32
data N33
data N34
data N35
data N36
data N37
data N38
data N39
data N40
data N41
data N42
data N43
data N44
data N45
data N46
data N47
data N48
data N49
data N50
data N51
data N52
data N53
data N54
data N55
data N56
data N57
data N58
data N59
data N60
data N61
data N62
data N63
data N64
data N65
data N66
data N67
data N68
data N69
data N70
data N71
data N72
data N73
data N74
data N75
data N76
data N77
data N78
data N79
data N80
data N81
data N82
data N83
data N84
data N85
data N86
data N87
data N88
data N89
data N90
data N91
data N92
data N93
data N94
data N95
data N96
data N97
data N98
data N99
data N100
data N101
data N102
data N103
data N104
data N105
data N106
data N107
data N108
data N109
data N110
data N111
data N112
data N113
data N114
data N115
data N116
data N117
data N118
data N119
data N120
data N121
data N122
data N123
data N124
data N125
data N126
data N127
data N128
data N129
data N130
data N131
data N132
data N133
data N134
data N135
data N136
data N137
data N138
data N139
data N140
data N141
data N142
data N143
data N144
data N145
data N146
data N147
data N148
data N149
data N150
data N151
data N152
data N153
data N154
data N155
data N156
data N157
data N158
data N159
data N160
data N161
data N162
data N163
data N164
data N165
data N166
data N167
data N168
data N169
data N170
data N171
data N172
data N173
data N174
data N175
data N176
data N177
data N178
data N179
data N180
data N181
data N182
data N183
data N184
data N185
data N186
data N187
data N188
data N189
data N190
data N191
data N192
data N193
data N194
data N195
data N196
data N197
data N198
data N199
data N200
data N201
data N202
data N203
data N204
data N205
data N206
data N207
data N208
data N209
data N210
data N211
data N212
data N213
data N214
data N215
data N216
data N217
data N218
data N219
data N220
data N221
data N222
data N223
data N224
data N225
data N226
data N227
data N228
data N229
data N230
data N231
data N232
data N233
data N234
data N235
data N236
data N237
data N238
data N239
data N240
data N241
data N242
data N243
data N244
data N245
data N246
data N247
data N248
data N249
data N250
data N251
data N252
data N253
data N254
data N255
data N65535
Documentation
shrink :: (Size n, Size m) => BoundedList a n -> Maybe (BoundedList a m)
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 m
Takes a BoundedList add grows it size.
trunc :: Size n => [a] -> BoundedList a n
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 -> Int
Returns the length of a BoundedList.
toBounded :: Size n => [a] -> Maybe (BoundedList a n)
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]
Takes a BoundedList and return the list inside.
class Size n
show/hide Instances
Size N0
Size N1
Size N10
Size N100
Size N101
Size N102
Size N103
Size N104
Size N105
Size N106
Size N107
Size N108
Size N109
Size N11
Size N110
Size N111
Size N112
Size N113
Size N114
Size N115
Size N116
Size N117
Size N118
Size N119
Size N12
Size N120
Size N121
Size N122
Size N123
Size N124
Size N125
Size N126
Size N127
Size N128
Size N129
Size N13
Size N130
Size N131
Size N132
Size N133
Size N134
Size N135
Size N136
Size N137
Size N138
Size N139
Size N14
Size N140
Size N141
Size N142
Size N143
Size N144
Size N145
Size N146
Size N147
Size N148
Size N149
Size N15
Size N150
Size N151
Size N152
Size N153
Size N154
Size N155
Size N156
Size N157
Size N158
Size N159
Size N16
Size N160
Size N161
Size N162
Size N163
Size N164
Size N165
Size N166
Size N167
Size N168
Size N169
Size N17
Size N170
Size N171
Size N172
Size N173
Size N174
Size N175
Size N176
Size N177
Size N178
Size N179
Size N18
Size N180
Size N181
Size N182
Size N183
Size N184
Size N185
Size N186
Size N187
Size N188
Size N189
Size N19
Size N190
Size N191
Size N192
Size N193
Size N194
Size N195
Size N196
Size N197
Size N198
Size N199
Size N2
Size N20
Size N200
Size N201
Size N202
Size N203
Size N204
Size N205
Size N206
Size N207
Size N208
Size N209
Size N21
Size N210
Size N211
Size N212
Size N213
Size N214
Size N215
Size N216
Size N217
Size N218
Size N219
Size N22
Size N220
Size N221
Size N222
Size N223
Size N224
Size N225
Size N226
Size N227
Size N228
Size N229
Size N23
Size N230
Size N231
Size N232
Size N233
Size N234
Size N235
Size N236
Size N237
Size N238
Size N239
Size N24
Size N240
Size N241
Size N242
Size N243
Size N244
Size N245
Size N246
Size N247
Size N248
Size N249
Size N25
Size N250
Size N251
Size N252
Size N253
Size N254
Size N255
Size N26
Size N27
Size N28
Size N29
Size N3
Size N30
Size N31
Size N32
Size N33
Size N34
Size N35
Size N36
Size N37
Size N38
Size N39
Size N4
Size N40
Size N41
Size N42
Size N43
Size N44
Size N45
Size N46
Size N47
Size N48
Size N49
Size N5
Size N50
Size N51
Size N52
Size N53
Size N54
Size N55
Size N56
Size N57
Size N58
Size N59
Size N6
Size N60
Size N61
Size N62
Size N63
Size N64
Size N65
Size N65535
Size N66
Size N67
Size N68
Size N69
Size N7
Size N70
Size N71
Size N72
Size N73
Size N74
Size N75
Size N76
Size N77
Size N78
Size N79
Size N8
Size N80
Size N81
Size N82
Size N83
Size N84
Size N85
Size N86
Size N87
Size N88
Size N89
Size N9
Size N90
Size N91
Size N92
Size N93
Size N94
Size N95
Size N96
Size N97
Size N98
Size N99
data BoundedList a n
show/hide Instances
(Size n, Eq a) => Eq (BoundedList a n)
(Show a, Size n) => Show (BoundedList a n)
data N0
show/hide Instances
Size N0
Less N0 N1
data N1
show/hide Instances
Size N1
Less N0 N1
Less N1 N2
data N2
show/hide Instances
Size N2
Less N1 N2
Less N2 N3
Less a N1 => Less a N2
data N3
show/hide Instances
Size N3
Less N2 N3
Less N3 N4
Less a N2 => Less a N3
data N4
show/hide Instances
Size N4
Less N3 N4
Less N4 N5
Less a N3 => Less a N4
data N5
show/hide Instances
Size N5
Less N4 N5
Less N5 N6
Less a N4 => Less a N5
data N6
show/hide Instances
Size N6
Less N5 N6
Less N6 N7
Less a N5 => Less a N6
data N7
show/hide Instances
Size N7
Less N6 N7
Less N7 N8
Less a N6 => Less a N7
data N8
show/hide Instances
Size N8
Less N7 N8
Less N8 N9
Less a N7 => Less a N8
data N9
show/hide Instances
Size N9
Less N8 N9
Less N9 N10
Less a N8 => Less a N9
data N10
show/hide Instances
Size N10
Less N10 N11
Less N9 N10
Less a N9 => Less a N10
data N11
show/hide Instances
Size N11
Less N10 N11
Less N11 N12
Less a N10 => Less a N11
data N12
show/hide Instances
Size N12
Less N11 N12
Less N12 N13
Less a N11 => Less a N12
data N13
show/hide Instances
Size N13
Less N12 N13
Less N13 N14
Less a N12 => Less a N13
data N14
show/hide Instances
Size N14
Less N13 N14
Less N14 N15
Less a N13 => Less a N14
data N15
show/hide Instances
Size N15
Less N14 N15
Less N15 N16
Less a N14 => Less a N15
data N16
show/hide Instances
Size N16
Less N15 N16
Less N16 N17
Less a N15 => Less a N16
data N17
show/hide Instances
Size N17
Less N16 N17
Less N17 N18
Less a N16 => Less a N17
data N18
show/hide Instances
Size N18
Less N17 N18
Less N18 N19
Less a N17 => Less a N18
data N19
show/hide Instances
Size N19
Less N18 N19
Less N19 N20
Less a N18 => Less a N19
data N20
show/hide Instances
Size N20
Less N19 N20
Less N20 N21
Less a N19 => Less a N20
data N21
show/hide Instances
Size N21
Less N20 N21
Less N21 N22
Less a N20 => Less a N21
data N22
show/hide Instances
Size N22
Less N21 N22
Less N22 N23
Less a N21 => Less a N22
data N23
show/hide Instances
Size N23
Less N22 N23
Less N23 N24
Less a N22 => Less a N23
data N24
show/hide Instances
Size N24
Less N23 N24
Less N24 N25
Less a N23 => Less a N24
data N25
show/hide Instances
Size N25
Less N24 N25
Less N25 N26
Less a N24 => Less a N25
data N26
show/hide Instances
Size N26
Less N25 N26
Less N26 N27
Less a N25 => Less a N26
data N27
show/hide Instances
Size N27
Less N26 N27
Less N27 N28
Less a N26 => Less a N27
data N28
show/hide Instances
Size N28
Less N27 N28
Less N28 N29
Less a N27 => Less a N28
data N29
show/hide Instances
Size N29
Less N28 N29
Less N29 N30
Less a N28 => Less a N29
data N30
show/hide Instances
Size N30
Less N29 N30
Less N30 N31
Less a N29 => Less a N30
data N31
show/hide Instances
Size N31
Less N30 N31
Less N31 N32
Less a N30 => Less a N31
data N32
show/hide Instances
Size N32
Less N31 N32
Less N32 N33
Less a N31 => Less a N32
data N33
show/hide Instances
Size N33
Less N32 N33
Less N33 N34
Less a N32 => Less a N33
data N34
show/hide Instances
Size N34
Less N33 N34
Less N34 N35
Less a N33 => Less a N34
data N35
show/hide Instances
Size N35
Less N34 N35
Less N35 N36
Less a N34 => Less a N35
data N36