Lose the "Value_" prefix

This commit is contained in:
Nikita Volkov 2014-08-06 04:03:29 +04:00
parent 30b3593b40
commit e4fee82adf
2 changed files with 27 additions and 27 deletions

View File

@ -86,23 +86,23 @@ type ResultSet =
data Value =
Value_Text !Text |
Value_ByteString !ByteString |
Value_Word32 !Word32 |
Value_Word64 !Word64 |
Value_Int32 !Int32 |
Value_Int64 !Int64 |
Value_Integer !Integer |
Value_Char !Char |
Value_Bool !Bool |
Value_Double !Double |
Value_Rational !Rational |
Value_Day !Day |
Value_LocalTime !LocalTime |
Value_TimeOfDay !TimeOfDay |
Value_ZonedTime !ZonedTime |
Value_UTCTime !UTCTime |
Value_NominalDiffTime !NominalDiffTime |
Text !Text |
ByteString !ByteString |
Word32 !Word32 |
Word64 !Word64 |
Int32 !Int32 |
Int64 !Int64 |
Integer !Integer |
Char !Char |
Bool !Bool |
Double !Double |
Rational !Rational |
Day !Day |
LocalTime !LocalTime |
TimeOfDay !TimeOfDay |
ZonedTime !ZonedTime |
UTCTime !UTCTime |
NominalDiffTime !NominalDiffTime |
-- | Yes, this encodes @NULL@s.
Value_Maybe !(Maybe Value)
Maybe !(Maybe Value)
deriving (Show, Data, Typeable, Generic)

View File

@ -22,7 +22,7 @@ let
InstanceD [] (AppT (ConT ''Value) (ConT t)) [d1, d2]
where
c =
mkName $ "Backend.Value_" ++ nameBase t
mkName $ "Backend." ++ nameBase t
d1 =
FunD 'toValue [Clause [] (NormalB (ConE c)) []]
d2 =
@ -43,20 +43,20 @@ let
''Word64, ''Word32, ''ByteString, ''Text]
instance Value String where
toValue = Backend.Value_Text . Text.pack
fromValue = \case Backend.Value_Text a -> Just (Text.unpack a); _ -> Nothing
toValue = Backend.Text . Text.pack
fromValue = \case Backend.Text a -> Just (Text.unpack a); _ -> Nothing
instance Value Word where
toValue = Backend.Value_Word64 . fromIntegral
fromValue = \case Backend.Value_Word64 a -> Just (fromIntegral a); _ -> Nothing
toValue = Backend.Word64 . fromIntegral
fromValue = \case Backend.Word64 a -> Just (fromIntegral a); _ -> Nothing
instance Value Int where
toValue = Backend.Value_Int64 . fromIntegral
fromValue = \case Backend.Value_Int64 a -> Just (fromIntegral a); _ -> Nothing
toValue = Backend.Int64 . fromIntegral
fromValue = \case Backend.Int64 a -> Just (fromIntegral a); _ -> Nothing
instance Value a => Value (Maybe a) where
toValue = Backend.Value_Maybe . fmap toValue
fromValue = \case Backend.Value_Maybe a -> traverse fromValue a; _ -> Nothing
toValue = Backend.Maybe . fmap toValue
fromValue = \case Backend.Maybe a -> traverse fromValue a; _ -> Nothing
-- * Row