[Haskell-cafe] [Help] Trying to rewrite the NetBSD kernel usingHaskell language.
Kiwamu Okabe
kiwamu at debian.or.jp
Tue Jan 21 11:04:50 UTC 2014
Hi Donn,
Do you know c2hs and GreenCard?
I don't know the details of them.
http://blog.ezyang.com/2010/06/the-haskell-preprocessor-hierarchy/
On Tue, Jan 21, 2014 at 1:27 AM, Donn Cave <donn at avvanta.com> wrote:
> That suggests to me that you should change the class, so that
> its Storable instance doesn't need to dereference the pointers -
> that is, vtbl for example would be a Ptr type. Though that would
> not save you very much trouble in the present case.
Yes. I will try to write the own Ptr type and Storable class.
Thank's.
> Are you using hsc2hs? Your example has a few things like "plusPtr
> p offsetOf_Ac97CodecIf_vtbl" - where do you get that offsetOf_?
> hsc2hs has a #peek macro that does this:
>
> p_Ac97CodecIf_vtbl p = (#peek struct ac97codecxzy, vtbl) p
> -- creates Haskell code
> p_Ac97CodecIf_vtbl p = ((\ hsc_ptr -> peekByteOff hsc_ptr 96) p
Yes, I know it. I read Read World Haskell book.
But there are two problems.
First, jhc has own Foreign Primitives.
http://ajhc.metasepi.org/manual.html#foreign-primitives
The "const. C_CONSTANT" can embed a C expression in Haskell code.
It understands C's macros (#define). Very powerful.
Second, The hsc2hs is not good for cross compiling.
If I miss to choose "--cc" option, I will watch funny BUG...
Thank's,
--
Kiwamu Okabe
More information about the Haskell-Cafe
mailing list