logo
首页技术栈工具库讨论
oauthenticated
oauthenticated
Warning: This software is pre 1.0 and thus its API may change very dynamically while updating only minor versions. This package will follow the PVP once it reaches version 1.0. OAuth is a popular protocol allowing servers to offer resources owned by some user to a series of authorized clients securely. For instance, OAuth lets Twitter provide access to a user's private tweets to the Twitter client registered on their phone. oauthenticated is a Haskell library implementing OAuth protocols atop the minimalistic http-client HTTP client library extracted from http-conduit. Network.OAuth offers simple functions for signing Network.HTTP.Client.Requests along with tools for Network.OAuth.Credential management and Network.OAuth.Server configuration. Network.OAuth.Simple provides a slightly more heavy-weight interface which manages the necessary state and configuration using a monad transformer stack. There's also an implementation of OAuth's three-legged credential acquisition protocol built atop the Network.OAuth API. This can be handled in both conformant and old-style modes: conformant will reject server responses which are not conformant with RFC 5849 (which builds atop community version OAuth 1.0a) while old-style better allows for less-than-compliant servers. See Network.OAuth.Types.Params.Version for more details. Currently oauthenticated only supports OAuth 1.0 and is in alpha. OAuth 2.0 support is a potential goal, but it's unclear if it can be transparently supported at a similar level of abstraction.
protobuf-native
protobuf-native
protobuf-native uses the code generated from protobuf for C++ in Haskell. [Index] For package maintainers and hackage trustees protobuf-native uses the code generated from protobuf for C++ in Haskell to go between Haskell and protobuf data structures. It makes use of Template Haskell to assist in generating the interface between protobuf and your data structures. Objects have finalizers so you never need to worry about memory management. protobuf is a Template Haskell splice that takes the file path to a compiled protobuf object file and the name of the data type you want to build bindings to. The data type must: For example, if we have a Person protobuf structure in the file person.proto: First we run protoc --cpp_out=. person.proto then compile the person.pb.cc file. Unfortunately, at this point, you need to mangle the C++ header file as per the Protobuf Mangling Guide below, ideally this would be automated. Do not re-run protoc unless you want to re-mangle the file. Always check these files in to source control. Then we can write two Haskell data structures to represent these types: If you get any of this wrong, you will get a compiler error. Note that NameT is the type of the name field in PersonT. With data kinds you may get confusing error messages here. Now we can: The C++ are ForeignPtrs with finalizers, so you do not need to free anything. Working with Cabal requires extra build steps. See this project's Setup.hs for an example on how to run protoc and clang++ in the build phase. The property above is used by QuickCheck to test the library works. The tests are located in tests/Tests.hs. Namely, for all types in Protobuf the following property holds: By profiling the tests you can verify the library does not leak memory. This is a temporary measure until we make a post-processor for protobuf header files. This is an inline function that must be un-inlined. Go to the header file and search for that function name (in this case clear_firstname). You will find two occurances: Remove the inline from both of these. Go to the header file and find set_lastname and remove the inline. It may also look like an field name, such as: Remove the inline from: When dealing with a string setter, you only need to un-inline the std::string function. I.e. This is currently another work around that is fixable. If your problem has performance constraints you may want to consider using this library. When working with large protobuf files, you may want to write file iterators / network operations in C++ and process the data in Haskell. This library lets you only pay for converting the parts of the data structure you need. You can, for example, iterate over a large file 20 elements at a time and only pull out the components of the protobuf structure you need to pass to Haskell.