logo
首页技术栈工具库讨论
usb
usb
This library enables you to communicate with USB devices from userspace. It is implemented as a high-level wrapper around bindings-libusb (http://hackage.haskell.org/package/bindings-libusb) which is a low-level binding to the C library: libusb-1.* (http://libusb.org/). The USB transfer functions in this library have a simple synchronous interface (they block) but are implemented using the libusb asynchronous interface. They integrate with the GHC event manager making them efficient (no busy-loops) and interruptible (throwing an exception to the thread executing a transfer immediately cancels the transfer). If the GHC event manager is not available (because you're either not using GHC or because you're on Windows) the library degrades gracefully to the libusb synchronous implementation. This documentation assumes knowledge of how to operate USB devices from a software standpoint (descriptors, configurations, interfaces, endpoints, control/bulk/interrupt/isochronous transfers, etc). Full information can be found in the USB 2.0 specification (http://www.usb.org/developers/docs/). For an example how to use this library see the usb-example package (https://github.com/basvandijk/usb-example) or the ls-usb package (http://hackage.haskell.org/package/ls-usb). Besides this API documentation the following sources might be interesting: The libusb 1.0 documentation (http://libusb.sourceforge.net/api-1.0/). The USB 2.0 specification (http://www.usb.org/developers/docs/). The bindings-libusb documentation (http://hackage.haskell.org/package/bindings-libusb). "USB in a NutShell" (http://www.beyondlogic.org/usbnutshell/usb1.htm).
lens-simple
lens-simple
This module, Lens.Simple, just re-exports the main modules from Russell O'Connor's lens-family package, the original van Laarhoven-O'Connor lens library. lens-family is particularly remarkable for its minute number of dependencies: (apart from mtl they are all ghc 'boot' libraries); but more importantly for its extreme conceptual simplicity and theoretical soundness. Much of the material it contains is well-explained, from a tutorial point of view, by lens-tutorial It is independent, self-standing and readily intelligible apart from any darker more general system of combinators that might attempt to extend it. Much of it ought to be in the Prelude. Convenient import of the elementary combinators from lens-family, however, a little complicated. The idea of this trivial module, then, is just to make a sort of low-powered, minimal-dependency, lens-family equivalent of the 800 lb gorilla of lens library imports: namely, the light-weight and elegant: Check it out, it's even one character shorter! The material in lens-tutorial will work fine if you make this substitution in the underlying source and follow along as prompted. As another illustration of the simplicity of the fundamental van Laarhoven-O'Connor lens combinators - and their homogeneity with Control.Lens - note that the gloss pong example from the lens library examples directory - which continues to be among the best introductory lens tutorials precisely by saying nothing - requires only this abbreviating change of imports. If you make that program more complicated, you might of course end up needing the more sophisticated material in Control.Lens and its immense mass of dependencies. On the other hand, you might just need some of the additional material present in the similarly demystifying microlens or microlens-th and the associated modules. This module was originally intended to simplify the use of packages that follow the original promise of the van Laarhoven-O'Connor lenses. Correct practice is to export lenses without depending on a lens-library, where possible. In basic cases these just use familiar Prelude types, after all. Examples of best practices in this respect are e.g. lens-family-th which doesn't depend on lens-family despite its name and pipes-related packages like pipes-bytestring and pipes-group. Lens.Simple also re-exports convenient TH incantations like makeLenses from Dan Burton's associated lens-family-th.