[C2hs] [c2hs] #50: Parenthesize marshallers, to preserve Haskell expressions

c2hs cvs-ghc at haskell.org
Mon Oct 8 04:26:19 CEST 2012


#50: Parenthesize marshallers, to preserve Haskell expressions
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  defect 
   Status:  new     |    Priority:  normal 
Milestone:          |   Component:  general
  Version:  0.16.0  |    Keywords:         
--------------------+-------------------------------------------------------
 Marshallers can contain Haskell expressions; however, c2hs substitutes
 those expressions into Haskell code as function calls and adds arguments
 to the end, which limits these Haskell expressions to simple function
 calls with one or more arguments.  Add parentheses to these expressions,
 allowing them to contain arbitrary Haskell expressions with lower
 precedence than function calls, such as operators.

 {{{
 diff -rN -u old-c2hs/src/C2HS/Gen/Bind.hs new-c2hs/src/C2HS/Gen/Bind.hs
 --- old-c2hs/src/C2HS/Gen/Bind.hs       2012-10-07 19:24:21.493527302
 -0700
 +++ new-c2hs/src/C2HS/Gen/Bind.hs       2012-10-07 19:24:21.521526937
 -0700
 @@ -884,7 +884,7 @@
                        interr "GenBind.funDef: marshRes: no default?"

        marshBody (Left ide) = identToString ide
 -      marshBody (Right str) = str
 +      marshBody (Right str) = "(" ++ str ++ ")"

        retArgs'  = case parm' of
                      CHSParm _ _ _ (Just (_, CHSVoidArg))   _ ->
 retArgs
 @@ -962,7 +962,7 @@
          retArg   = if omArgKind == CHSVoidArg || omArgKind ==
 CHSIOVoidArg then "" else outBndr

          marshBody (Left ide) = identToString ide
 -        marshBody (Right str) = str
 +        marshBody (Right str) = "(" ++ str ++ ")"
        in
        (funArg, marshIn, callArgs, marshOut, retArg)
      marshArg _ _ = interr "GenBind.funDef: Missing default?"
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/50>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell



More information about the C2hs mailing list