mirror of
https://github.com/facebook/Haxl.git
synced 2024-12-24 01:04:21 +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
|
||||
-- be found in the PATENTS file.
|
||||
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE ExistentialQuantification #-}
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
@ -65,6 +66,7 @@ module Haxl.Core.Exception (
|
||||
|
||||
import Control.Exception
|
||||
import Data.Aeson
|
||||
import Data.Binary (Binary)
|
||||
import Data.Typeable
|
||||
import Data.Text (Text)
|
||||
|
||||
@ -189,16 +191,16 @@ logicErrorFromException x = do
|
||||
|
||||
-- | Generic \"critical\" exception. Something internal is
|
||||
-- borked. Panic.
|
||||
data CriticalError = CriticalError Text
|
||||
deriving (Typeable, Eq, Show)
|
||||
newtype CriticalError = CriticalError Text
|
||||
deriving (Typeable, Binary, Eq, Show)
|
||||
|
||||
instance Exception CriticalError where
|
||||
toException = internalErrorToException
|
||||
fromException = internalErrorFromException
|
||||
|
||||
-- | Generic \"something was not found\" exception.
|
||||
data NotFound = NotFound Text
|
||||
deriving (Typeable, Eq, Show)
|
||||
newtype NotFound = NotFound Text
|
||||
deriving (Typeable, Binary, Eq, Show)
|
||||
|
||||
instance Exception NotFound where
|
||||
toException = logicErrorToException
|
||||
|
@ -10,6 +10,7 @@ module TestTypes
|
||||
) where
|
||||
|
||||
import Data.Aeson
|
||||
import Data.Binary (Binary)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.HashMap.Strict as HashMap
|
||||
@ -36,7 +37,7 @@ lookupInput field = do
|
||||
|
||||
|
||||
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)
|
||||
|
||||
instance Show Id where
|
||||
|
Loading…
Reference in New Issue
Block a user