Revision ffdcc263
b/src/Ganeti/THH.hs | ||
---|---|---|
36 | 36 |
, makeJSONInstance |
37 | 37 |
, deCamelCase |
38 | 38 |
, genOpID |
39 |
, genOpLowerStrip |
|
39 | 40 |
, genAllConstr |
40 | 41 |
, genAllOpIDs |
41 | 42 |
, PyValue(..) |
... | ... | |
578 | 579 |
genOpID :: Name -> String -> Q [Dec] |
579 | 580 |
genOpID = genConstrToStr (return . deCamelCase) |
580 | 581 |
|
582 |
-- | Strips @Op@ from the constructor name, converts to lower-case |
|
583 |
-- and adds a given prefix. |
|
584 |
genOpLowerStrip :: String -> Name -> String -> Q [Dec] |
|
585 |
genOpLowerStrip prefix = |
|
586 |
genConstrToStr (liftM ((prefix ++) . map toLower . deCamelCase) |
|
587 |
. stripPrefixM "Op") |
|
588 |
where |
|
589 |
stripPrefixM :: String -> String -> Q String |
|
590 |
stripPrefixM pfx s = maybe (fail $ s ++ " doesn't start with " ++ pfx) |
|
591 |
return |
|
592 |
$ stripPrefix pfx s |
|
593 |
|
|
581 | 594 |
-- | Builds a list with all defined constructor names for a type. |
582 | 595 |
-- |
583 | 596 |
-- @ |
Also available in: Unified diff