IreneKnapp / direct-sqlite

MIT License
35 stars 54 forks source link

Narrow Param/ColumnIndex bounds down to native C 'int' size #36

Closed nurpax closed 11 years ago

nurpax commented 11 years ago

SQLite3 accepts column and parameter indices as native 'int's, which on 64-bit systems is usually only 32-bits whereas Haskell's Int is 64-bits on 64-bit systems. Add Bounded instances for ParamIndex and ColumnIndex to mark the allowable integer range for these values.

No explicit overflow checking is done for these values as this is somewhat of a corner case and we don't want to pay any extra for such often used values.

Fixes a test failure reported in #32


FYI, tested

          print (minBound :: ColumnIndex)
          print (maxBound :: ColumnIndex)
          print (minBound :: ParamIndex)
          print (maxBound :: ParamIndex)

and these correctly print -2147483648 & 2147483647 as expected.