Revision 8aab74e9 src/Ganeti/THH.hs

b/src/Ganeti/THH.hs
568 568
--
569 569
-- This builds a custom list of name\/string pairs and then uses
570 570
-- 'genToRaw' to actually generate the function.
571
genConstrToStr :: (String -> String) -> Name -> String -> Q [Dec]
571
genConstrToStr :: (String -> Q String) -> Name -> String -> Q [Dec]
572 572
genConstrToStr trans_fun name fname = do
573 573
  cnames <- reifyConsNames name
574
  let svalues = map (Left . trans_fun) cnames
574
  svalues <- mapM (liftM Left . trans_fun) cnames
575 575
  genToRaw ''String (mkName fname) name $ zip cnames svalues
576 576

  
577 577
-- | Constructor-to-string for OpCode.
578 578
genOpID :: Name -> String -> Q [Dec]
579
genOpID = genConstrToStr deCamelCase
579
genOpID = genConstrToStr (return . deCamelCase)
580 580

  
581 581
-- | Builds a list with all defined constructor names for a type.
582 582
--
......
814 814

  
815 815
-- | Constructor-to-string for LuxiOp.
816 816
genStrOfOp :: Name -> String -> Q [Dec]
817
genStrOfOp = genConstrToStr id
817
genStrOfOp = genConstrToStr return
818 818

  
819 819
-- | Constructor-to-string for MsgKeys.
820 820
genStrOfKey :: Name -> String -> Q [Dec]
821
genStrOfKey = genConstrToStr ensureLower
821
genStrOfKey = genConstrToStr (return . ensureLower)
822 822

  
823 823
-- | Generates the LuxiOp data type.
824 824
--

Also available in: Unified diff