[Haskell-cafe] Re: Mixing C and Haskell code in the same file

2009-07-23 Thread Simon Marlow
On 12/07/2009 19:26, Bulat Ziganshin wrote: Hello Maurí­cio, Sunday, July 12, 2009, 9:11:53 PM, you wrote: I did read that. It says I can use #def to insert a C definition, but there are no examples of use, and I could not find one. #def inline int signof(int x) {return x0?-1:x0?1:0;}

[Haskell-cafe] Re: Mixing C and Haskell code in the same file

2009-07-15 Thread Maurí­cio
#def inline int signof(int x) {return x0?-1:x0?1:0;} foreign import ccall safe signof :: CInt - CInt Is it possible to get that #def as a result of a macro? Say, something like this: --- (WARNING: invalid code) #define ret(name,value,type) \ #def inline type name (void) {return value;}

[Haskell-cafe] Re: Mixing C and Haskell code in the same file

2009-07-12 Thread Maurí­cio
Is it possible to insert C code directly to, say, .hsc files? I see this construct in ghc user docs: I think you can find your answer here: http://www.haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html I did read that. It says I can use #def to insert a C definition, but there are no

Re: [Haskell-cafe] Re: Mixing C and Haskell code in the same file

2009-07-12 Thread Bulat Ziganshin
Hello Maurí­cio, Sunday, July 12, 2009, 9:11:53 PM, you wrote: I did read that. It says I can use #def to insert a C definition, but there are no examples of use, and I could not find one. #def inline int signof(int x) {return x0?-1:x0?1:0;} foreign import ccall safe signof :: CInt - CInt