... | ... | @@ -69,4 +69,20 @@ pow::CDouble->Int->CDoublepow x y |
|
|
| otherwise = pow (x `mul` x)((y -1)`quot`2)`mul` x
|
|
|
|
|
|
mul::CDouble->CDouble->CDoublemul(C a b)(C d e)=C(a*d-b*e)(a*e+b*d)
|
|
|
```
|
|
|
|
|
|
### peek.hs
|
|
|
|
|
|
|
|
|
This example involves reading a tuple of Ints from memory.
|
|
|
|
|
|
|
|
|
Status: needs -fcpr-depth=4 or higher.
|
|
|
|
|
|
```
|
|
|
{-# LANGUAGE BangPatterns #-}moduleFoo(peek4)whereimportForeign.StorableimportForeign.Ptrpeek4::PtrInt->PtrInt->(PtrInt->IO(PtrInt,PtrInt))->IO(PtrInt,PtrInt,(Int,Int,Int,Int))peek4 ptr end req
|
|
|
| end `minusPtr` ptr >=32=do
|
|
|
val <-(,,,)<$> peekByteOff ptr 0<*> peekByteOff ptr 8<*> peekByteOff ptr 16<*> peekByteOff ptr 24let!ptr' = ptr `plusPtr`32
|
|
|
return (ptr', end, val)| otherwise =do(ptr', end')<- req ptr
|
|
|
peek4 ptr' end' req
|
|
|
``` |
|
|
\ No newline at end of file |