@@ -1,5 +1,6 @@
11{-# language FlexibleInstances #-}
22{-# language MonoLocalBinds #-}
3+{-# language MultiWayIf #-}
34{-# language StandaloneKindSignatures #-}
45{-# language UndecidableInstances #-}
56
@@ -125,7 +126,11 @@ instance DBType Int64 where
125126-- | Corresponds to @float4@
126127instance DBType Float where
127128 typeInformation = TypeInformation
128− { encode = Opaleye.ConstExpr . Opaleye.NumericLit . realToFrac
129+ { encode = \x -> Opaleye.ConstExpr
130+ if | x == (1 /0) -> Opaleye.OtherLit "'Infinity'"
131+ | isNaN x -> Opaleye.OtherLit "'NaN'"
132+ | x == (-1/0) -> Opaleye.OtherLit "'-Infinity'"
133+ | otherwise -> Opaleye.NumericLit $ realToFrac x
129134 , decode = Hasql.float4
130135 , typeName = "float4"
131136 }
@@ -134,7 +139,11 @@ instance DBType Float where
134139-- | Corresponds to @float8@
135140instance DBType Double where
136141 typeInformation = TypeInformation
137− { encode = Opaleye.ConstExpr . Opaleye.NumericLit . realToFrac
142+ { encode = \x -> Opaleye.ConstExpr
143+ if | x == (1 /0) -> Opaleye.OtherLit "'Infinity'"
144+ | isNaN x -> Opaleye.OtherLit "'NaN'"
145+ | x == (-1/0) -> Opaleye.OtherLit "'-Infinity'"
146+ | otherwise -> Opaleye.NumericLit $ realToFrac x
138147 , decode = Hasql.float8
139148 , typeName = "float8"
140149 }