Revision 6c1a9fae
b/src/Ganeti/PyValue.hs | ||
---|---|---|
28 | 28 |
|
29 | 29 |
-} |
30 | 30 |
{-# LANGUAGE ExistentialQuantification #-} |
31 |
{-# LANGUAGE FlexibleInstances, OverlappingInstances, |
|
32 |
TypeSynonymInstances, IncoherentInstances #-} |
|
33 |
module Ganeti.PyValue where |
|
31 |
module Ganeti.PyValue |
|
32 |
( PyValue(..) |
|
33 |
, PyValueEx(..) |
|
34 |
) where |
|
34 | 35 |
|
35 | 36 |
import Data.List (intercalate) |
36 | 37 |
import Data.Map (Map) |
... | ... | |
49 | 50 |
class PyValue a where |
50 | 51 |
showValue :: a -> String |
51 | 52 |
|
53 |
showValueList :: [a] -> String |
|
54 |
showValueList xs = "[" ++ intercalate "," (map showValue xs) ++ "]" |
|
55 |
|
|
52 | 56 |
instance PyValue Bool where |
53 | 57 |
showValue = show |
54 | 58 |
|
... | ... | |
63 | 67 |
|
64 | 68 |
instance PyValue Char where |
65 | 69 |
showValue = show |
70 |
showValueList = show |
|
66 | 71 |
|
67 | 72 |
instance (PyValue a, PyValue b) => PyValue (a, b) where |
68 | 73 |
showValue (x, y) = "(" ++ showValue x ++ "," ++ showValue y ++ ")" |
... | ... | |
75 | 80 |
showValue z ++ |
76 | 81 |
")" |
77 | 82 |
|
78 |
instance PyValue String where |
|
79 |
showValue = show |
|
80 |
|
|
81 | 83 |
instance PyValue a => PyValue [a] where |
82 |
showValue xs = "[" ++ intercalate "," (map showValue xs) ++ "]"
|
|
84 |
showValue = showValueList
|
|
83 | 85 |
|
84 | 86 |
instance (PyValue k, PyValue a) => PyValue (Map k a) where |
85 | 87 |
showValue mp = |
Also available in: Unified diff