I'm working on an home automation system with the raspberry pi.

Currently I use python or C to control the GPIO and haskell/yesod for controlling everything from pc/ipad/phone... But I would like to control the GPIO without using python or C. So directly from haskell.

Is this possible?

Kind regards Joachim

4 Answers 4


One (very Unixy) approach would be to call a helper program (command) that can do the GPIO operations for you. That should be relatively easy in any language and doesn't need bindings beyond system(). The helper could be written in C, Python or something else and made to accept a few arguments for what you want done.

A more elaborate helper might run as a daemon and accept connections over sockets from programs wanting to manipulate GPIO. This may have more issues from security standpoint, but may also be better since GPIO access is already a bit hairy issue.

  • I was thinking about this approach. A C socket server that accepts something as input so it knows what to do. But i'm not familiar with c so I have to learn it first :)
    – Joachim
    Jan 30, 2013 at 10:15

It's a bit late for an answer, but you can use the HPi library for this. It currently supports manipulation of the GPIO pins and sending/receiving with the I2C protocol, all from the IO monad.


If it is possible in haskell to use the GPIO through memory, I guess so, but I have never used haskell, but there are more ways to use the GPIO pins, for example the same way you can use them in a bash script, through the


device files on raspbian, there you can configure, read and write the individual pins. Not as elegant, and root privileges are required, but it works. Check this link for more info on using these files.

  • Thanks for the response I'll take a look at it after my exam on tuesday
    – Joachim
    Jan 26, 2013 at 8:57

I just published this to hackage.


Feel free to try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.