haskell / haskell/c2hs

Automatically generate Storable instances for enums

Open
#248 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
211
Forks
52
PR merge metrics
No merged PRs in 30d

Description

Enums are CInts in memory so this should work for all types
```
instance Storable SomeType where
sizeOf _ = 4
alignment _ = 4
peek ptr = do
val <- peek (castPtr ptr)
return $ toEnum $ fromEnum (val :: CInt)
poke ptr v = poke (castPtr ptr) (toEnum $ fromEnum v :: CInt)
```
It would be nice if we add syntactic sugar for automatically generating storables instances.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.