Revision c4d68e39 src/Ganeti/OpCodes.hs
b/src/Ganeti/OpCodes.hs | ||
---|---|---|
52 | 52 |
|
53 | 53 |
import qualified Ganeti.Hs2Py.OpDoc as OpDoc |
54 | 54 |
import Ganeti.OpParams |
55 |
import Ganeti.PyValueInstances () |
|
55 | 56 |
import Ganeti.Types |
56 | 57 |
import Ganeti.Query.Language (queryTypeOpToRaw) |
57 | 58 |
|
58 | 59 |
import Data.List (intercalate) |
59 | 60 |
import Data.Map (Map) |
60 |
import qualified Data.Map as Map |
|
61 |
import Data.Set (Set) |
|
62 |
import qualified Data.Set as Set |
|
63 | 61 |
|
64 | 62 |
import qualified Ganeti.Constants as C |
65 | 63 |
|
66 |
instance PyValue Bool |
|
67 |
instance PyValue Int |
|
68 |
instance PyValue Double |
|
69 |
instance PyValue Char |
|
70 |
|
|
71 |
instance (PyValue a, PyValue b) => PyValue (a, b) where |
|
72 |
showValue (x, y) = show (showValue x, showValue y) |
|
73 |
|
|
74 |
instance PyValue a => PyValue [a] where |
|
75 |
showValue xs = show (map showValue xs) |
|
76 |
|
|
77 |
instance PyValue a => PyValue (Set a) where |
|
78 |
showValue s = showValue (Set.toList s) |
|
79 |
|
|
80 |
instance (PyValue k, PyValue a) => PyValue (Map k a) where |
|
81 |
showValue mp = |
|
82 |
"{" ++ intercalate ", " (map showPair (Map.assocs mp)) ++ "}" |
|
83 |
where showPair (k, x) = show k ++ ":" ++ show x |
|
84 |
|
|
85 | 64 |
instance PyValue DiskIndex where |
86 | 65 |
showValue = showValue . unDiskIndex |
87 | 66 |
|
Also available in: Unified diff