Revision 2886c58d src/Ganeti/PyValueInstances.hs

b/src/Ganeti/PyValueInstances.hs
27 27
02110-1301, USA.
28 28

  
29 29
-}
30
{-# LANGUAGE ExistentialQuantification #-}
30 31
{-# LANGUAGE FlexibleInstances, OverlappingInstances,
31 32
             TypeSynonymInstances, IncoherentInstances #-}
32
{-# OPTIONS_GHC -fno-warn-orphans #-}
33 33
module Ganeti.PyValueInstances where
34 34

  
35 35
import Data.List (intercalate)
......
38 38
import qualified Data.Set as Set (toList)
39 39

  
40 40
import Ganeti.BasicTypes
41
import Ganeti.THH
41

  
42
-- * PyValue represents data types convertible to Python
43

  
44
-- | Converts Haskell values into Python values
45
--
46
-- This is necessary for the default values of opcode parameters and
47
-- return values.  For example, if a default value or return type is a
48
-- Data.Map, then it must be shown as a Python dictioanry.
49
class PyValue a where
50
  showValue :: a -> String
42 51

  
43 52
instance PyValue Bool where
44 53
  showValue = show
......
79 88

  
80 89
instance PyValue a => PyValue (ListSet a) where
81 90
  showValue = showValue . Set.toList . unListSet
91

  
92
-- * PyValue represents an unspecified value convertible to Python
93

  
94
-- | Encapsulates Python default values
95
data PyValueEx = forall a. PyValue a => PyValueEx a
96

  
97
instance PyValue PyValueEx where
98
  showValue (PyValueEx x) = showValue x

Also available in: Unified diff