I am new to Haskell and found myself in a bind concerning the use of
the C types, CDouble in particular. I extract a CDouble via it's pointer
from a StorableArray. Since the array must interface with C the elements of
the array must be CDouble. Now I'd like to use Text.Printf to format print
Am Sonntag, 14. Mai 2006 09:30 schrieb SevenThunders:
I am new to Haskell and found myself in a bind concerning the use of
the C types, CDouble in particular. I extract a CDouble via it's pointer
from a StorableArray. Since the array must interface with C the elements
of the array must be
Thanks that helps a bit. The realToFrac type coercion works, but ultimately
it seems
that printf won't play nice. Consider this simple haskell code
module Test
where
import IO
-- import Data.Array.Storable
import Text.Printf
import Foreign.C.Types (CInt, CDouble )
y :: CDouble
y =
On Sunday 14 May 2006 03:00 pm, SevenThunders wrote:
Thanks that helps a bit. The realToFrac type coercion works, but
ultimately it seems
that printf won't play nice. Consider this simple haskell code
module Test
where
import IO
-- import Data.Array.Storable
import Text.Printf
The rabbit hole goes a bit deeper I'm afraid
y :: CDouble
y = 5.2
u :: Double
u = realToFrac(y)
test = do printf %14.7g u
gives
Compiling Test ( test.hs, interpreted )
test.hs:14:11:
No instance for (PrintfType (t t1))
arising from use of `printf' at test.hs:14:11-16
SevenThunders wrote:
test.hs:14:11:
No instance for (PrintfType (t t1))
arising from use of `printf' at test.hs:14:11-16
Probable fix: add an instance declaration for (PrintfType (t t1))
In the result of a 'do' expression: printf %14.7g u
In the definition of `test':