mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-11-30 00:55:22 +03:00
Lose the "Value_" prefix
This commit is contained in:
parent
30b3593b40
commit
e4fee82adf
@ -86,23 +86,23 @@ type ResultSet =
|
|||||||
|
|
||||||
|
|
||||||
data Value =
|
data Value =
|
||||||
Value_Text !Text |
|
Text !Text |
|
||||||
Value_ByteString !ByteString |
|
ByteString !ByteString |
|
||||||
Value_Word32 !Word32 |
|
Word32 !Word32 |
|
||||||
Value_Word64 !Word64 |
|
Word64 !Word64 |
|
||||||
Value_Int32 !Int32 |
|
Int32 !Int32 |
|
||||||
Value_Int64 !Int64 |
|
Int64 !Int64 |
|
||||||
Value_Integer !Integer |
|
Integer !Integer |
|
||||||
Value_Char !Char |
|
Char !Char |
|
||||||
Value_Bool !Bool |
|
Bool !Bool |
|
||||||
Value_Double !Double |
|
Double !Double |
|
||||||
Value_Rational !Rational |
|
Rational !Rational |
|
||||||
Value_Day !Day |
|
Day !Day |
|
||||||
Value_LocalTime !LocalTime |
|
LocalTime !LocalTime |
|
||||||
Value_TimeOfDay !TimeOfDay |
|
TimeOfDay !TimeOfDay |
|
||||||
Value_ZonedTime !ZonedTime |
|
ZonedTime !ZonedTime |
|
||||||
Value_UTCTime !UTCTime |
|
UTCTime !UTCTime |
|
||||||
Value_NominalDiffTime !NominalDiffTime |
|
NominalDiffTime !NominalDiffTime |
|
||||||
-- | Yes, this encodes @NULL@s.
|
-- | Yes, this encodes @NULL@s.
|
||||||
Value_Maybe !(Maybe Value)
|
Maybe !(Maybe Value)
|
||||||
deriving (Show, Data, Typeable, Generic)
|
deriving (Show, Data, Typeable, Generic)
|
||||||
|
@ -22,7 +22,7 @@ let
|
|||||||
InstanceD [] (AppT (ConT ''Value) (ConT t)) [d1, d2]
|
InstanceD [] (AppT (ConT ''Value) (ConT t)) [d1, d2]
|
||||||
where
|
where
|
||||||
c =
|
c =
|
||||||
mkName $ "Backend.Value_" ++ nameBase t
|
mkName $ "Backend." ++ nameBase t
|
||||||
d1 =
|
d1 =
|
||||||
FunD 'toValue [Clause [] (NormalB (ConE c)) []]
|
FunD 'toValue [Clause [] (NormalB (ConE c)) []]
|
||||||
d2 =
|
d2 =
|
||||||
@ -43,20 +43,20 @@ let
|
|||||||
''Word64, ''Word32, ''ByteString, ''Text]
|
''Word64, ''Word32, ''ByteString, ''Text]
|
||||||
|
|
||||||
instance Value String where
|
instance Value String where
|
||||||
toValue = Backend.Value_Text . Text.pack
|
toValue = Backend.Text . Text.pack
|
||||||
fromValue = \case Backend.Value_Text a -> Just (Text.unpack a); _ -> Nothing
|
fromValue = \case Backend.Text a -> Just (Text.unpack a); _ -> Nothing
|
||||||
|
|
||||||
instance Value Word where
|
instance Value Word where
|
||||||
toValue = Backend.Value_Word64 . fromIntegral
|
toValue = Backend.Word64 . fromIntegral
|
||||||
fromValue = \case Backend.Value_Word64 a -> Just (fromIntegral a); _ -> Nothing
|
fromValue = \case Backend.Word64 a -> Just (fromIntegral a); _ -> Nothing
|
||||||
|
|
||||||
instance Value Int where
|
instance Value Int where
|
||||||
toValue = Backend.Value_Int64 . fromIntegral
|
toValue = Backend.Int64 . fromIntegral
|
||||||
fromValue = \case Backend.Value_Int64 a -> Just (fromIntegral a); _ -> Nothing
|
fromValue = \case Backend.Int64 a -> Just (fromIntegral a); _ -> Nothing
|
||||||
|
|
||||||
instance Value a => Value (Maybe a) where
|
instance Value a => Value (Maybe a) where
|
||||||
toValue = Backend.Value_Maybe . fmap toValue
|
toValue = Backend.Maybe . fmap toValue
|
||||||
fromValue = \case Backend.Value_Maybe a -> traverse fromValue a; _ -> Nothing
|
fromValue = \case Backend.Maybe a -> traverse fromValue a; _ -> Nothing
|
||||||
|
|
||||||
|
|
||||||
-- * Row
|
-- * Row
|
||||||
|
Loading…
Reference in New Issue
Block a user