Revision 2886c58d src/Ganeti/THH.hs
b/src/Ganeti/THH.hs | ||
---|---|---|
1 |
{-# LANGUAGE ExistentialQuantification, ParallelListComp, TemplateHaskell #-}
|
|
1 |
{-# LANGUAGE ParallelListComp, TemplateHaskell #-} |
|
2 | 2 |
|
3 | 3 |
{-| TemplateHaskell helper for Ganeti Haskell code. |
4 | 4 |
|
... | ... | |
77 | 77 |
import Text.JSON.Pretty (pp_value) |
78 | 78 |
|
79 | 79 |
import Ganeti.JSON |
80 |
import Ganeti.PyValueInstances |
|
80 | 81 |
|
81 | 82 |
import Data.Maybe |
82 | 83 |
import Data.Functor ((<$>)) |
... | ... | |
584 | 585 |
|
585 | 586 |
-- * Python code generation |
586 | 587 |
|
587 |
-- | Converts Haskell values into Python values |
|
588 |
-- |
|
589 |
-- This is necessary for the default values of opcode parameters and |
|
590 |
-- return values. For example, if a default value or return type is a |
|
591 |
-- Data.Map, then it must be shown as a Python dictioanry. |
|
592 |
class PyValue a where |
|
593 |
showValue :: a -> String |
|
594 |
|
|
595 |
-- | Encapsulates Python default values |
|
596 |
data PyValueEx = forall a. PyValue a => PyValueEx a |
|
597 |
|
|
598 |
instance PyValue PyValueEx where |
|
599 |
showValue (PyValueEx x) = showValue x |
|
600 |
|
|
601 | 588 |
-- | Transfers opcode data between the opcode description (through |
602 | 589 |
-- @genOpCode@) and the Python code generation functions. |
603 | 590 |
type OpCodeDescriptor = |
Also available in: Unified diff