Skip to content

Instantly share code, notes, and snippets.

@rblaze
Last active August 29, 2015 14:16
Show Gist options
  • Save rblaze/4e15c1f2977a82fd1661 to your computer and use it in GitHub Desktop.
Save rblaze/4e15c1f2977a82fd1661 to your computer and use it in GitHub Desktop.
{-# LANGUAGE ScopedTypeVariables, TypeFamilies, DeriveDataTypeable #-}
module Unittest.Compat.Containers (Containers(..)) where
import qualified Bond.Imports as B'
import qualified Unittest.Compat.Another.Another
import qualified Unittest.Compat.Another.EnumType
import qualified Unittest.Compat.BasicTypes
import qualified Unittest.Compat.EnumType1
data Containers = Containers{l_bool :: [B'.Bool],
l_str :: [B'.Utf8], l_int8 :: [B'.Int8], l_int16 :: [B'.Int16],
l_int32 :: [B'.Int32], l_int64 :: [B'.Int64],
l_uint8 :: [B'.Word8], l_uint16 :: [B'.Word16],
l_uint32 :: [B'.Word32], l_uint64 :: [B'.Word64],
l_double :: [B'.Double], l_float :: [B'.Float],
l_enum1 :: [Unittest.Compat.EnumType1.EnumType1],
l_basic :: [Unittest.Compat.BasicTypes.BasicTypes],
l_another_enum :: [Unittest.Compat.Another.EnumType.EnumType],
l_another_struct :: [Unittest.Compat.Another.Another.Another],
s_bool :: B'.HashSet B'.Bool, s_str :: B'.HashSet B'.Utf8,
s_int8 :: B'.HashSet B'.Int8, s_int16 :: B'.HashSet B'.Int16,
s_int32 :: B'.HashSet B'.Int32,
s_int64 :: B'.Maybe (B'.HashSet B'.Int64),
s_uint8 :: B'.HashSet B'.Word8, s_uint16 :: B'.HashSet B'.Word16,
s_uint32 :: B'.HashSet B'.Word32, s_uint64 :: B'.HashSet B'.Word64,
s_double :: B'.HashSet B'.Double, s_float :: B'.HashSet B'.Float,
s_enum1 :: B'.HashSet Unittest.Compat.EnumType1.EnumType1,
m_bool :: B'.Map B'.Utf8 B'.Bool, m_str :: B'.Map B'.Utf8 B'.Utf8,
m_int8 :: B'.Map B'.Utf8 B'.Int8,
m_int16 :: B'.Map B'.Utf8 B'.Int16,
m_int32 :: B'.Map B'.Utf8 B'.Int32,
m_int64 :: B'.Map B'.Utf8 B'.Int64,
m_uint8 :: B'.Maybe (B'.Map B'.Utf8 B'.Word8),
m_uint16 :: B'.Map B'.Utf8 B'.Word16,
m_uint32 :: B'.Map B'.Utf8 B'.Word32,
m_uint64 :: B'.Map B'.Utf8 B'.Word64,
m_double :: B'.Map B'.Utf8 B'.Double,
m_float :: B'.Map B'.Utf8 B'.Float,
m_enum1 :: B'.Map B'.Utf8 Unittest.Compat.EnumType1.EnumType1,
n_bool :: B'.Map B'.Bool B'.Double,
n_str :: B'.Map B'.Utf8 B'.Double,
n_int8 :: B'.Map B'.Int8 B'.Double,
n_int16 :: B'.Map B'.Int16 B'.Double,
n_int32 :: B'.Map B'.Int32 B'.Double,
n_int64 :: B'.Map B'.Int64 B'.Double,
n_uint8 :: B'.Map B'.Word8 B'.Double,
n_uint16 :: B'.Map B'.Word16 B'.Double,
n_uint32 :: B'.Map B'.Word32 B'.Double,
n_uint64 :: B'.Map B'.Word64 B'.Double,
n_double :: B'.Map B'.Double B'.Double,
n_float :: B'.Map B'.Float B'.Double,
n_enum1 :: B'.Map Unittest.Compat.EnumType1.EnumType1 B'.Double,
n_basic ::
B'.Map Unittest.Compat.EnumType1.EnumType1
Unittest.Compat.BasicTypes.BasicTypes,
lv_uint64 :: [B'.Vector B'.Word64],
vs_uint64 :: B'.Vector (B'.HashSet B'.Word64),
vm_uint64 ::
B'.Maybe (B'.Vector (B'.Map B'.Utf8 (B'.HashSet B'.Word64))),
mml_float :: B'.Map B'.Int8 (B'.Map B'.Word8 [B'.Float]),
m_blob :: B'.Blob, l_blob :: [B'.Blob],
n_blob :: B'.Map B'.Utf8 B'.Blob}
deriving (Show, Eq, B'.Data, B'.Typeable)
instance B'.Default Containers where
defaultValue
= Containers{l_bool = B'.defaultValue, l_str = B'.defaultValue,
l_int8 = B'.defaultValue, l_int16 = B'.defaultValue,
l_int32 = B'.defaultValue, l_int64 = B'.defaultValue,
l_uint8 = B'.defaultValue, l_uint16 = B'.defaultValue,
l_uint32 = B'.defaultValue, l_uint64 = B'.defaultValue,
l_double = B'.defaultValue, l_float = B'.defaultValue,
l_enum1 = B'.defaultValue, l_basic = B'.defaultValue,
l_another_enum = B'.defaultValue,
l_another_struct = B'.defaultValue, s_bool = B'.defaultValue,
s_str = B'.defaultValue, s_int8 = B'.defaultValue,
s_int16 = B'.defaultValue, s_int32 = B'.defaultValue,
s_int64 = Nothing, s_uint8 = B'.defaultValue,
s_uint16 = B'.defaultValue, s_uint32 = B'.defaultValue,
s_uint64 = B'.defaultValue, s_double = B'.defaultValue,
s_float = B'.defaultValue, s_enum1 = B'.defaultValue,
m_bool = B'.defaultValue, m_str = B'.defaultValue,
m_int8 = B'.defaultValue, m_int16 = B'.defaultValue,
m_int32 = B'.defaultValue, m_int64 = B'.defaultValue,
m_uint8 = Nothing, m_uint16 = B'.defaultValue,
m_uint32 = B'.defaultValue, m_uint64 = B'.defaultValue,
m_double = B'.defaultValue, m_float = B'.defaultValue,
m_enum1 = B'.defaultValue, n_bool = B'.defaultValue,
n_str = B'.defaultValue, n_int8 = B'.defaultValue,
n_int16 = B'.defaultValue, n_int32 = B'.defaultValue,
n_int64 = B'.defaultValue, n_uint8 = B'.defaultValue,
n_uint16 = B'.defaultValue, n_uint32 = B'.defaultValue,
n_uint64 = B'.defaultValue, n_double = B'.defaultValue,
n_float = B'.defaultValue, n_enum1 = B'.defaultValue,
n_basic = B'.defaultValue, lv_uint64 = B'.defaultValue,
vs_uint64 = B'.defaultValue, vm_uint64 = Nothing,
mml_float = B'.defaultValue, m_blob = B'.defaultValue,
l_blob = B'.defaultValue, n_blob = B'.defaultValue}
equalToDefault _ _ = False
instance B'.WireType Containers where
getWireType _ = B'.BT_STRUCT
instance B'.BondBinary Containers where
bondPut = B'.bondPutStruct
bondGet = B'.bondGetStruct
instance B'.BondStruct Containers where
type Base Containers = B'.VoidBase
bondGetInfo _
= B'.StructInfo (B'.Proxy :: B'.Proxy Containers) Nothing
bondGetSchema _
= B'.StructSchema
[B'.FieldInfo "l_bool" (B'.Ordinal 0),
B'.FieldInfo "l_str" (B'.Ordinal 1),
B'.FieldInfo "l_int8" (B'.Ordinal 2),
B'.FieldInfo "l_int16" (B'.Ordinal 3),
B'.FieldInfo "l_int32" (B'.Ordinal 4),
B'.FieldInfo "l_int64" (B'.Ordinal 5),
B'.FieldInfo "l_uint8" (B'.Ordinal 6),
B'.FieldInfo "l_uint16" (B'.Ordinal 7),
B'.FieldInfo "l_uint32" (B'.Ordinal 8),
B'.FieldInfo "l_uint64" (B'.Ordinal 9),
B'.FieldInfo "l_double" (B'.Ordinal 10),
B'.FieldInfo "l_float" (B'.Ordinal 11),
B'.FieldInfo "l_enum1" (B'.Ordinal 12),
B'.FieldInfo "l_basic" (B'.Ordinal 13),
B'.FieldInfo "l_another_enum" (B'.Ordinal 14),
B'.FieldInfo "l_another_struct" (B'.Ordinal 15),
B'.FieldInfo "s_bool" (B'.Ordinal 20),
B'.FieldInfo "s_str" (B'.Ordinal 21),
B'.FieldInfo "s_int8" (B'.Ordinal 22),
B'.FieldInfo "s_int16" (B'.Ordinal 23),
B'.FieldInfo "s_int32" (B'.Ordinal 24),
B'.FieldInfo "s_int64" (B'.Ordinal 25),
B'.FieldInfo "s_uint8" (B'.Ordinal 26),
B'.FieldInfo "s_uint16" (B'.Ordinal 27),
B'.FieldInfo "s_uint32" (B'.Ordinal 28),
B'.FieldInfo "s_uint64" (B'.Ordinal 29),
B'.FieldInfo "s_double" (B'.Ordinal 30),
B'.FieldInfo "s_float" (B'.Ordinal 31),
B'.FieldInfo "s_enum1" (B'.Ordinal 32),
B'.FieldInfo "m_bool" (B'.Ordinal 40),
B'.FieldInfo "m_str" (B'.Ordinal 41),
B'.FieldInfo "m_int8" (B'.Ordinal 42),
B'.FieldInfo "m_int16" (B'.Ordinal 43),
B'.FieldInfo "m_int32" (B'.Ordinal 44),
B'.FieldInfo "m_int64" (B'.Ordinal 45),
B'.FieldInfo "m_uint8" (B'.Ordinal 46),
B'.FieldInfo "m_uint16" (B'.Ordinal 47),
B'.FieldInfo "m_uint32" (B'.Ordinal 48),
B'.FieldInfo "m_uint64" (B'.Ordinal 49),
B'.FieldInfo "m_double" (B'.Ordinal 50),
B'.FieldInfo "m_float" (B'.Ordinal 51),
B'.FieldInfo "m_enum1" (B'.Ordinal 52),
B'.FieldInfo "n_bool" (B'.Ordinal 60),
B'.FieldInfo "n_str" (B'.Ordinal 61),
B'.FieldInfo "n_int8" (B'.Ordinal 62),
B'.FieldInfo "n_int16" (B'.Ordinal 63),
B'.FieldInfo "n_int32" (B'.Ordinal 64),
B'.FieldInfo "n_int64" (B'.Ordinal 65),
B'.FieldInfo "n_uint8" (B'.Ordinal 66),
B'.FieldInfo "n_uint16" (B'.Ordinal 67),
B'.FieldInfo "n_uint32" (B'.Ordinal 68),
B'.FieldInfo "n_uint64" (B'.Ordinal 69),
B'.FieldInfo "n_double" (B'.Ordinal 70),
B'.FieldInfo "n_float" (B'.Ordinal 71),
B'.FieldInfo "n_enum1" (B'.Ordinal 72),
B'.FieldInfo "n_basic" (B'.Ordinal 73),
B'.FieldInfo "lv_uint64" (B'.Ordinal 80),
B'.FieldInfo "vs_uint64" (B'.Ordinal 81),
B'.FieldInfo "vm_uint64" (B'.Ordinal 82),
B'.FieldInfo "mml_float" (B'.Ordinal 83),
B'.FieldInfo "m_blob" (B'.Ordinal 90),
B'.FieldInfo "l_blob" (B'.Ordinal 91),
B'.FieldInfo "n_blob" (B'.Ordinal 92)]
bondSetBase _ _ = error "no base struct"
bondSetField (B'.Ordinal 0) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_bool = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 1) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_str = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 2) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_int8 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 3) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_int16 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 4) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_int32 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 5) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_int64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 6) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_uint8 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 7) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_uint16 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 8) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_uint32 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 9) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_uint64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 10) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_double = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 11) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_float = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 12) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_enum1 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 13) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_basic = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 14) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_another_enum = val'}) =<<
B'.bondGet
bondSetField (B'.Ordinal 15) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_another_struct = val'}) =<<
B'.bondGet
bondSetField (B'.Ordinal 20) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_bool = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 21) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_str = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 22) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_int8 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 23) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_int16 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 24) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_int32 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 25) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_int64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 26) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_uint8 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 27) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_uint16 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 28) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_uint32 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 29) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_uint64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 30) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_double = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 31) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_float = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 32) B'.BT_SET
= return . fmap (\ val' v' -> v'{s_enum1 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 40) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_bool = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 41) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_str = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 42) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_int8 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 43) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_int16 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 44) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_int32 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 45) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_int64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 46) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_uint8 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 47) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_uint16 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 48) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_uint32 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 49) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_uint64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 50) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_double = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 51) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_float = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 52) B'.BT_MAP
= return . fmap (\ val' v' -> v'{m_enum1 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 60) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_bool = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 61) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_str = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 62) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_int8 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 63) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_int16 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 64) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_int32 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 65) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_int64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 66) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_uint8 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 67) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_uint16 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 68) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_uint32 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 69) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_uint64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 70) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_double = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 71) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_float = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 72) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_enum1 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 73) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_basic = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 80) B'.BT_LIST
= return . fmap (\ val' v' -> v'{lv_uint64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 81) B'.BT_LIST
= return . fmap (\ val' v' -> v'{vs_uint64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 82) B'.BT_LIST
= return . fmap (\ val' v' -> v'{vm_uint64 = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 83) B'.BT_MAP
= return . fmap (\ val' v' -> v'{mml_float = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 90) B'.BT_LIST
= return . fmap (\ val' v' -> v'{m_blob = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 91) B'.BT_LIST
= return . fmap (\ val' v' -> v'{l_blob = val'}) =<< B'.bondGet
bondSetField (B'.Ordinal 92) B'.BT_MAP
= return . fmap (\ val' v' -> v'{n_blob = val'}) =<< B'.bondGet
bondSetField _ _ = return Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment