Revision 26e32dee

b/src/Ganeti/JSON.hs
49 49
  , optionalJSField
50 50
  , optFieldsToObj
51 51
  , readContainer
52
  , DictObject(..)
53
  , ArrayObject(..)
52 54
  , HasStringRepr(..)
53 55
  , GenericContainer(..)
54 56
  , Container
......
326 328
  readJSON v = fail $ "Failed to load container, expected object but got "
327 329
               ++ show (pp_value v)
328 330

  
331
-- * Types that (de)serialize in a special form of JSON
332

  
333
-- | Class of objects that can be converted from and to 'JSObject'
334
-- lists-format.
335
class DictObject a where
336
  toDict :: a -> [(String, J.JSValue)]
337
  fromDict :: [(String, J.JSValue)] -> J.Result a
338

  
339
-- | Class of objects that can be converted from and to @[JSValue]@ with
340
-- a fixed length and order.
341
class ArrayObject a where
342
  toJSArray :: a -> [J.JSValue]
343
  fromJSArray :: [J.JSValue] -> J.Result a
344

  
345
-- * General purpose data types for working with JSON
346

  
329 347
-- | A Maybe newtype that allows for serialization more appropriate to the
330 348
-- semantics of Maybe and JSON in our calls. Does not produce needless
331 349
-- and confusing dictionaries.
b/src/Ganeti/OpCodes.hs
54 54

  
55 55
import qualified Ganeti.Constants as C
56 56
import qualified Ganeti.Hs2Py.OpDoc as OpDoc
57
import Ganeti.JSON (DictObject(..))
57 58
import Ganeti.OpParams
58 59
import Ganeti.PyValue ()
59 60
import Ganeti.Query.Language (queryTypeOpToRaw)
b/src/Ganeti/THH.hs
66 66
                  , buildObject
67 67
                  , buildObjectSerialisation
68 68
                  , buildParam
69
                  , DictObject(..)
70
                  , ArrayObject(..)
71 69
                  , genException
72 70
                  , excErrMsg
73 71
                  ) where
......
97 95

  
98 96
-- * Exported types
99 97

  
100
-- | Class of objects that can be converted from and to 'JSObject'
101
-- lists-format.
102
class DictObject a where
103
  toDict :: a -> [(String, JSON.JSValue)]
104
  fromDict :: [(String, JSON.JSValue)] -> JSON.Result a
105

  
106
-- | Class of objects that can be converted from and to @[JSValue]@ with
107
-- a fixed length and order.
108
class ArrayObject a where
109
  toJSArray :: a -> [JSON.JSValue]
110
  fromJSArray :: [JSON.JSValue] -> JSON.Result a
111

  
112 98
-- | Optional field information.
113 99
data OptionalType
114 100
  = NotOptional           -- ^ Field is not optional

Also available in: Unified diff