mirror of
https://github.com/facebook/Haxl.git
synced 2024-12-25 01:31:31 +03:00
Add (de)serialization functions to most datasources
Summary: Add serialization and deserialization functions to non-risk datasources that don't require special treatment (like CacheClient, etc), for use with D2628780 Reviewed By: simonmar Differential Revision: D2645436 fbshipit-source-id: 2777dbfbb11528bc079e2e82e88ebbdc880a8914
This commit is contained in:
parent
9d2d4bc746
commit
c4ca10b6ea
@ -5,6 +5,7 @@
|
|||||||
-- found in the LICENSE file. An additional grant of patent rights can
|
-- found in the LICENSE file. An additional grant of patent rights can
|
||||||
-- be found in the PATENTS file.
|
-- be found in the PATENTS file.
|
||||||
|
|
||||||
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
{-# LANGUAGE ExistentialQuantification #-}
|
{-# LANGUAGE ExistentialQuantification #-}
|
||||||
{-# LANGUAGE StandaloneDeriving #-}
|
{-# LANGUAGE StandaloneDeriving #-}
|
||||||
{-# LANGUAGE DeriveDataTypeable #-}
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
@ -65,6 +66,7 @@ module Haxl.Core.Exception (
|
|||||||
|
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
|
import Data.Binary (Binary)
|
||||||
import Data.Typeable
|
import Data.Typeable
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
|
|
||||||
@ -189,16 +191,16 @@ logicErrorFromException x = do
|
|||||||
|
|
||||||
-- | Generic \"critical\" exception. Something internal is
|
-- | Generic \"critical\" exception. Something internal is
|
||||||
-- borked. Panic.
|
-- borked. Panic.
|
||||||
data CriticalError = CriticalError Text
|
newtype CriticalError = CriticalError Text
|
||||||
deriving (Typeable, Eq, Show)
|
deriving (Typeable, Binary, Eq, Show)
|
||||||
|
|
||||||
instance Exception CriticalError where
|
instance Exception CriticalError where
|
||||||
toException = internalErrorToException
|
toException = internalErrorToException
|
||||||
fromException = internalErrorFromException
|
fromException = internalErrorFromException
|
||||||
|
|
||||||
-- | Generic \"something was not found\" exception.
|
-- | Generic \"something was not found\" exception.
|
||||||
data NotFound = NotFound Text
|
newtype NotFound = NotFound Text
|
||||||
deriving (Typeable, Eq, Show)
|
deriving (Typeable, Binary, Eq, Show)
|
||||||
|
|
||||||
instance Exception NotFound where
|
instance Exception NotFound where
|
||||||
toException = logicErrorToException
|
toException = logicErrorToException
|
||||||
|
@ -10,6 +10,7 @@ module TestTypes
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
|
import Data.Binary (Binary)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
import qualified Data.HashMap.Strict as HashMap
|
import qualified Data.HashMap.Strict as HashMap
|
||||||
@ -36,7 +37,7 @@ lookupInput field = do
|
|||||||
|
|
||||||
|
|
||||||
newtype Id = Id Int
|
newtype Id = Id Int
|
||||||
deriving (Eq, Ord, Enum, Num, Integral, Real, Hashable, Typeable,
|
deriving (Eq, Ord, Binary, Enum, Num, Integral, Real, Hashable, Typeable,
|
||||||
ToJSON, FromJSON)
|
ToJSON, FromJSON)
|
||||||
|
|
||||||
instance Show Id where
|
instance Show Id where
|
||||||
|
Loading…
Reference in New Issue
Block a user