Suppose I want to make an SqlType instance for my own data type that can be represented as a value in an SQL column. E.g. I want to represent integers from 0 to 1000:
newtype SmallInt = SmallInt { unSmallInt :: Int }
I could define mkLit (SmallInt x) = LInt x. However, converting in the other direction, what should be done in fromSql if the input is an out-of-range SqlInt value? Just error? How does the user detect an error in the input when running a query?
Suppose I want to make an SqlType instance for my own data type that can be represented as a value in an SQL column. E.g. I want to represent integers from 0 to 1000:
I could define
mkLit (SmallInt x) = LInt x
. However, converting in the other direction, what should be done infromSql
if the input is an out-of-range SqlInt value? Justerror
? How does the user detect an error in the input when running a query?