For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • SDKs
    • SDK concepts
    • SDK features
    • Client-side SDKs
    • Server-side SDKs
      • .NET SDK reference
      • Apex SDK reference
      • C++ SDK reference
      • Erlang SDK reference
      • Go SDK reference
      • Haskell SDK reference
        • Haskell SDK 3.x to 4.0 migration guide
      • Java SDK reference
      • Lua SDK reference
      • Node.js SDK reference
      • PHP SDK reference
      • Python SDK reference
      • Ruby SDK reference
      • Rust SDK reference
    • AI SDKs
    • Edge SDKs
    • OpenFeature providers
    • Observability SDKs
    • Relay Proxy
Sign inTry it free
LogoLogo
On this page
  • Overview
  • Get started
  • Install the SDK
  • Initialize the client
  • Evaluate a context
  • Shut down the client
  • Supported features
SDKsServer-side SDKs

Haskell SDK reference

Was this page helpful?
Previous

Haskell SDK 3.x to 4.0 migration guide

Next
Built with

Overview

This topic documents how to get started with the Haskell SDK, and links to reference information on all of the supported features.

SDK quick links

LaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:

ResourceLocation
SDK API documentationSDK API docs
Supported SDK VersionsHaskell server SDK
GitHub repositoryhaskell-server-sdk
Sample applicationHaskell
Published moduleHackage

Get started

Follow the steps below to get started using the LaunchDarkly SDK in your Haskell application.

Install the SDK

The root module of the SDK LaunchDarkly.Server re-exports the entire project.

Here is an example:

Haskell
1import LaunchDarkly.Server
The Haskell SDK uses an SDK key

The Haskell SDK uses an SDK key. Keys are specific to each project and environment. They are available on the SDK keys page under Settings. To learn more about key types, read Keys.

Initialize the client

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.

Here’s how:

Haskell
1client :: IO Client
2client = makeClient $ makeConfig "YOUR_SDK_KEY"

To learn more about the specific configuration properties that are available in this SDK, read Config.

Client must be a singleton

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.

Evaluate a context

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 Context configuration.

Here’s how:

1boolVariation client "example-flag-key" (makeContext "example-context-key" "context-kind") False

Shut down the client

Shut down the client when your application terminates. To learn more, read Shutting down.

Supported features

This SDK supports the following features:

  • Anonymous contexts and users
  • Configuration, including
    • Application metadata configuration
    • Service endpoint configuration
  • Context configuration
  • 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
    • Using proxy mode
    • Using daemon mode
  • Secure mode
  • Sending custom events
  • Shutting down
  • Storing data
  • Test data sources