I was following the signal11 tutorial on udev attempting to replicate their example enumerate/monitor C source code in Haskell when what I thought was impossible happened: I got a Segfault in Haskell! That should give an idea of how new I am to Haskell as a language, but I guess the math works out seeing as this package is calling C functions that could return NULL.
Anyway, it seems to me like a better type signature for the getValue function would be:
getValue :: List -> IO (Maybe ByteString)
and my simple hack was to perform a simple nullPtr check inside the getValue function and return the ByteString wrapped in a Mabye which seems to work alright.
This isn't the only place where I've run into a segfault. The getSysattrValue function will also segfault if you give it an attribute name that doesn't exist and it also seems like wrapping the return value in a Mabye would make things more Haskell-like.
I have attached UdevExample.txt which is a bit of Haskell that demonstrates the segfaults I'm running into.
Maybe I'm just a derp for knowing just enough Haskell to get myself into trouble and I'm coding things completely wrong, but I figured it couldn't hurt to try to help out. I would be happy to work on a fix for this and submit a pull request if that's what ends up happening.
I was following the signal11 tutorial on udev attempting to replicate their example enumerate/monitor C source code in Haskell when what I thought was impossible happened: I got a Segfault in Haskell! That should give an idea of how new I am to Haskell as a language, but I guess the math works out seeing as this package is calling C functions that could return NULL.
Anyway, it seems to me like a better type signature for the getValue function would be:
getValue :: List -> IO (Maybe ByteString)
and my simple hack was to perform a simple nullPtr check inside the getValue function and return the ByteString wrapped in a Mabye which seems to work alright.This isn't the only place where I've run into a segfault. The getSysattrValue function will also segfault if you give it an attribute name that doesn't exist and it also seems like wrapping the return value in a Mabye would make things more Haskell-like.
I have attached UdevExample.txt which is a bit of Haskell that demonstrates the segfaults I'm running into.
Maybe I'm just a derp for knowing just enough Haskell to get myself into trouble and I'm coding things completely wrong, but I figured it couldn't hurt to try to help out. I would be happy to work on a fix for this and submit a pull request if that's what ends up happening.
Cheers!