[C2hs] Passing extra arguments to marshalling functions

Björn Bringert bringert at cs.chalmers.se
Fri Jun 1 12:43:00 EDT 2007


I have a function for checking return values of functions:

checkResult :: String -> CInt -> IO ()
checkResult _ 0 = return ()
checkResult f n = fail $ f ++ " failed (" ++ show n ++ ")"

Now, I want to call that on the exit value of lots of functions, like this:

{#fun foo
  {}
  -> `()' `checkResult "foo"'*- #}

{#fun bar
  {}
  -> `()' `checkResult "bar"'*- #}

...

However, the marshallers can only be function names, not arbitrary 
expressions. Wouldn't it be a useful generalization to allow arbitrary 
expressions as marshallers? That way you could even have one-off 
marshallers as lambda expressions.

/Björn


More information about the C2hs mailing list