[Haskell-cafe] Begginer question about alignment in Storable

2008-11-15 Thread Maurí­cio
Hi, I need to make the following structure into an instance of Storable: struct { double w[2]; } Can I assume that its function 'alignment' should return the same as alignment (1::CDouble)? Or should it be 2 * alignment (1::CDouble)? (I've read the wikipedia article about memory alignment,

Re: [Haskell-cafe] Begginer question about alignment in Storable

2008-11-15 Thread Bulat Ziganshin
Hello Maurí­cio, Saturday, November 15, 2008, 11:29:23 PM, you wrote: struct { double w[2]; } Can I assume that its function 'alignment' should return the same as alignment (1::CDouble)? Or should it be 2 * alignment (1::CDouble)? secind - definitely not. first - probably yes --

Re: [Haskell-cafe] Begginer question about alignment in Storable

2008-11-15 Thread Michael D. Adams
If you are using hsc2hs (if you are using Cabal this is easy; just rename the file to *.hsc and Cabal will take care of the rest), then there is a macro for making this easier and so you don't have to think about it. First, place the following at the top of your source file: #let alignment t =

Re: [Haskell-cafe] Begginer question

2005-01-06 Thread Jules Bean
On 6 Jan 2005, at 01:37, Maurício wrote: import Complex; complex_root :: (Float, Float, Float) - (Complex Float, Complex Float) complex_root (a,b,c) = (x1,x2) where { delta = b * b - 4 * a * c :: Float; sqr_delta = if delta = 0 then (sqrt delta) :+ 0 else 0 :+ (sqrt delta) :: (Complex Float);

Re: [Haskell-cafe] Begginer question

2005-01-06 Thread Ketil Malde
Maurício [EMAIL PROTECTED] writes: complex_root :: (Float, Float, Float) - (Complex Float, Complex Float) complex_root (a,b,c) = (x1,x2) where { delta = b * b - 4 * a * c :: Float; sqr_delta = if delta = 0 then (sqrt delta) :+ 0 else 0 :+ (sqrt delta) :: (Complex

[Haskell-cafe] Begginer question

2005-01-05 Thread Maurício
Hi, When compiling this: import Complex; complex_root :: (Float, Float, Float) - (Complex Float, Complex Float) complex_root (a,b,c) = (x1,x2) where { delta = b * b - 4 * a * c :: Float; sqr_delta = if delta = 0 then (sqrt delta) :+ 0 else 0 :+ (sqrt delta) :: (Complex Float);