achirkin / easytensor

Many-dimensional type-safe numeric ops
https://hackage.haskell.org/package/easytensor
BSD 3-Clause "New" or "Revised" License
46 stars 2 forks source link

Added PrimBytes instances for FunPtr a and StablePtr a. #23

Closed Rotaerk closed 4 years ago

Rotaerk commented 4 years ago

To resolve #22 (and StablePtr, which I noticed after I created the issue), I just made a modified copy of your Ptr a instance in both cases. For FunPtr a, I just did s/Ptr/FunPtr/ and s/HSPTR/HSFUNPTR/. For StablePtr a, I did s/Ptr/StablePtr/, s/HSPTR/HSSTABLEPTR/, and replaced all the Addr#-based function calls with StablePtr#-analogous function calls. Also had to import GHC.Stable.

I made this change to let me continue working on my project, and I figured it would save you a bit of work, but I'm not sure if it's correct. It does build, but I didn't test it. (Not really sure how to approach that.) Please check over it when you get a chance...

Rotaerk commented 4 years ago

Hmm, looks like it doesn't build on 8.4; it lacks StablePtr functions?

achirkin commented 4 years ago

Wow, thanks!

The code seems ok. As for the build failure, GHC added a bunch of primops in base-4.12. Could you please add the shims for the old GHC in here? For the offset scaling bitshift, I think, you can use OFFSHIFT_P, as StablePtr# seems to be the same size as Addr#.

Rotaerk commented 4 years ago

Builds now \o/

achirkin commented 4 years ago

Great, thanks!