Haskell SDK reference
Read time: 1 minute
Last edited: Mar 31, 2023
A context is a generalized way of referring to the people, services, machines, or other resources that encounter feature flags in your product.
Code samples on this page are from the two most recent SDK versions where they differ. To learn more about upgrading, read Haskell SDK 3.x to 3.0 migration guide.
This topic documents how to get started with the Haskell SDK, and links to reference information on all of the supported features.
LaunchDarkly's SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:
|SDK API documentation||SDK API docs|
Follow the steps below to get started using the LaunchDarkly SDK in your Haskell application.
The root module of the SDK
LaunchDarkly.Server re-exports the entire project.
Here is an example:
After you import and install the SDK, create a single shared instance of
Client. Specify your SDK key to authorize your application to connect to a particular environment within LaunchDarkly.
client :: IO Clientclient = makeClient $ makeConfig "sdk-key-123abc"
It's important to make
Client a singleton for each LaunchDarkly project. The client instance maintains an internal state that allows LaunchDarkly to serve feature flags without making any remote requests. Do not instantiate a new client with every request.
If you have multiple LaunchDarkly projects, you can create one
LDClient for each. In this situation, the clients operate independently. For example, they do not share a single connection to LaunchDarkly.
You can use
client to check which variation a particular context will receive for a given feature flag. To learn more, read Evaluating flags and Flag evaluation reasons. For more information about how contexts are specified, read User and context configuration.
boolVariation client "flag-key-123abc" (makeContext "context-key-123abc" "context-kind") False
Lastly, shut down the client when your application terminates. To learn more, read Shutting down.
This SDK supports the following features:
- Anonymous contexts and users
- Configuration, including
- Evaluating flags
- Flag evaluation reasons
- Flushing events
- Getting all flags
- Identifying and changing contexts
- Offline mode
- Private attributes
- Reading flags from a file
- Relay Proxy configuration
- Secure mode
- Sending custom events
- Shutting down
- Storing data
- Test data sources
- User and context configuration