My attempt at Haskell USB

A few months ago, I declared here that I intended to get USB working in Haskell. After a lot of thinking on what could be a realistic goal, this is where I've got: http://hackage.haskell.org/packages/archive/bindings-libusb/0.0.3/doc/html/B... I know this is probably a disapointment for most of you, but please try to understand the concept at the base package: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bindings-common-0... What I'm doing is to group under these bindings-* packages a Haskell link to well established libraries. But Bindings.* modules are not supposed to be Haskell code, but C (or other languages, in the future?) code in Haskell. You may ask what good is this. Well, suppose you want to write a nice module, using GADTs, Template Haskell and STM, using functionality from libusb or other libraries bindings-* have links to. Just learn to use Foreign.Ptr, Foreign.Marshable and friends. Forget about the details of FFI, it's already done, and it's really time consuming and boring, believe me, I've been there. Are there other libraries you would like to have low-level bindings for? Just tell. I've organized and standardized things in a way that it is really easy to add other libraries really fast. Here is another example: http://hackage.haskell.org/packages/archive/bindings-sqlite3/0.0.2/doc/html/... Hope you can use it somehow. This is my attempt in doing something that may be usefull to others after all the great and friendly support I've had from this community in the last month and years. Thanks for you all, gtk2hs guys specially. Best, Maurício

2009/6/4 Maurício
A few months ago, I declared here that I intended to get USB working in Haskell. After a lot of thinking on what could be a realistic goal, this is where I've got:
http://hackage.haskell.org/packages/archive/bindings-libusb/0.0.3/doc/html/B...
I know this is probably a disapointment for most of you, but please try to understand the concept at the base package:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bindings-common-0...
What I'm doing is to group under these bindings-* packages a Haskell link to well established libraries. But Bindings.* modules are not supposed to be Haskell code, but C (or other languages, in the future?) code in Haskell.
You may ask what good is this. Well, suppose you want to write a nice module, using GADTs, Template Haskell and STM, using functionality from libusb or other libraries bindings-* have links to. Just learn to use Foreign.Ptr, Foreign.Marshable and friends. Forget about the details of FFI, it's already done, and it's really time consuming and boring, believe me, I've been there.
Are there other libraries you would like to have low-level bindings for? Just tell. I've organized and standardized things in a way that it is really easy to add other libraries really fast. Here is another example:
http://hackage.haskell.org/packages/archive/bindings-sqlite3/0.0.2/doc/html/...
Hope you can use it somehow. This is my attempt in doing something that may be usefull to others after all the great and friendly support I've had from this community in the last month and years. Thanks for you all, gtk2hs guys specially.
Hi, from a cursory glance at the Haddock, in the following code foreign import ccall "libusb_get_device_address" libusb_get_device_address :: Ptr libusb_device -> IO Word8 is it normal libusb_device is written in lower case, not Libusb_device ? Cheers, Thu

(...)
foreign import ccall "libusb_get_device_address" libusb_get_device_address :: Ptr libusb_device -> IO Word8
is it normal libusb_device is written in lower case, not Libusb_device ?
No! Could this make a case for requiring explicit foralls? I think not :) My mistake, just corrected, cabal will generate documentation again after some time. Thanks, Maurício

Maurício wrote:
A few months ago, I declared here that I intended to get USB working in Haskell. After a lot of thinking on what could be a realistic goal, this is where I've got:
http://hackage.haskell.org/packages/archive/bindings-libusb/0.0.3/doc/html/B...
I know this is probably a disapointment for most of you, but please try to understand the concept at the base package:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bindings-common-0...
What I'm doing is to group under these bindings-* packages a Haskell link to well established libraries. But Bindings.* modules are not supposed to be Haskell code, but C (or other languages, in the future?) code in Haskell.
You may ask what good is this. Well, suppose you want to write a nice module, using GADTs, Template Haskell and STM, using functionality from libusb or other libraries bindings-* have links to. Just learn to use Foreign.Ptr, Foreign.Marshable and friends. Forget about the details of FFI, it's already done, and it's really time consuming and boring, believe me, I've been there.
seconded: the Haskell FFI is really nice BUT it's a potential for type mismatches that cause crashes! So, there's an advantage to put them all in one package that's easier to check, and not worry as much in the packages that *use* the bindings. -Isaac
participants (3)
-
Isaac Dupree
-
Maurício
-
minh thu