Re[2]: [Haskell-cafe] FFI basics

2007-02-27 Thread Bulat Ziganshin
Hello Evan,

Tuesday, February 27, 2007, 12:02:57 AM, you wrote:

 Unfortunately, ghc doesn't seem relink the target if cfile.o changed,
 so as a hack I put 'rm target' before the ghc line to make it link
 every time.

it's a bug. i don't know whether it's already fixed, try it with the
latest 6.6 snapshot

 #2 is structs.  What's a good way to marshal structs?

this depends on your actual task. in particular, you can write
instances of Storable for your structures:

instance (Storable a, Storable b) = Storable (a,b) where
  sizeOf (x,y) = sizeOf x + sizeOf y
  ..

hsc2hs translator allows you to use offsets in C structures, see
http://therning.org/magnus/archives/238 
  
-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] FFI basics

2007-02-16 Thread Bulat Ziganshin
Hello Magnus,

Thursday, February 15, 2007, 3:08:41 PM, you wrote:

I would like to use FFI for the first time. Can someone give me a

 Shameless self-promotion: http://therning.org/magnus/archives/238

great intro, better than my own!




-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] FFI basics

2007-02-12 Thread Yitzchak Gale

Bulat Ziganshin wrote:

examples of lifting C functions into Haskell world:

mysin :: Double - Double
mysin = realToFrac . c_mysin . realToFrac

-- c_mysin :: CDouble - CDouble

rnd :: Int - IO Int
rnd x = do r - c_rnd (fromIntegral x)
   return (fromIntegral r)

-- c_rnd :: CInt - IO CInt


OK, got it. I'll put that in.

Thanks,
Yitz
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] FFI basics

2007-02-11 Thread Bulat Ziganshin
Hello Yitzchak,

Sunday, February 11, 2007, 4:14:39 AM, you wrote:
 when I have time. What Bulat wrote is in my opinion
 _exactly_ what is needed.

i has a pedagogical talent :D  searching for Haskell teacher position :)))


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] FFI basics

2007-02-10 Thread Bulat Ziganshin
Hello Donald,

Saturday, February 10, 2007, 11:21:58 AM, you wrote:

 foreign import ccall mysin.h mysin
   c_mysin :: Double - Double

 Shouldn't that be CDouble? At least for Int/CInt you can hit troubles on
 64 bit machines...

conceptually - yes. practically, it should be the same for all current
platforms. of course, for maintained programs it's better to use safer
approach


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe