> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Haskell SDK reference

**Developer**

**Federal docs**

**EU docs**

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

> [!NOTE]
>
> **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:
>
> <table>
>   <thead>
>     <tr>
>       <th>Resource</th>
>       <th>Location</th>
>     </tr>
>   </thead>
>
>   <tbody>
>     <tr>
>       <td>SDK API documentation</td>
>       <td>[SDK API docs](https://launchdarkly.github.io/haskell-server-sdk/)</td>
>     </tr>
>
>     <tr>
>       <td>Supported SDK Versions</td>
>       <td>[Haskell server SDK](https://launchdarkly.com/docs/sdk/concepts/supported-versions.md#haskell-server-sdk)</td>
>     </tr>
>
>     <tr>
>       <td>GitHub repository</td>
>       <td>[haskell-server-sdk](https://github.com/launchdarkly/haskell-server-sdk)</td>
>     </tr>
>
>     <tr>
>       <td>Sample application</td>
>       <td>[Haskell](https://github.com/launchdarkly/hello-haskell-server)</td>
>     </tr>
>
>     <tr>
>       <td>Published module</td>
>       <td>[Hackage](https://hackage.haskell.org/package/launchdarkly-server-sdk)</td>
>     </tr>
>   </tbody>
> </table>

## 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 title="Haskell" lines wrap theme={null}
import LaunchDarkly.Server
```

> [!NOTE]
>
> **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](https://launchdarkly.com/docs/sdk/concepts/client-side-server-side.md#keys-and-credentials).

### 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 title="Haskell" lines wrap theme={null}
client :: IO Client
client = makeClient $ makeConfig "YOUR_SDK_KEY"
```

To learn more about the specific configuration properties that are available in this SDK, read [`Config`](https://launchdarkly.github.io/haskell-server-sdk/LaunchDarkly-Server-Config.html).

> [!WARNING]
>
> **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 [Flag variation evaluation](https://launchdarkly.com/docs/sdk/features/evaluating.md) and [Flag variation evaluation details](https://launchdarkly.com/docs/sdk/features/evaluation-reasons.md). For more information about how contexts are specified, read [Context configuration](https://launchdarkly.com/docs/sdk/features/context-config.md).

Here's how:

```haskell title="Haskell SDK v4.0" lines wrap theme={null}
boolVariation 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](https://launchdarkly.com/docs/sdk/features/shutdown.md#haskell).

## Supported features

This SDK supports the following features:

* [SDK configuration](https://launchdarkly.com/docs/sdk/features/config#haskell), including
  * [Application metadata configuration](https://launchdarkly.com/docs/sdk/features/app-config.md#haskell)
  * [Service endpoint configuration](https://launchdarkly.com/docs/sdk/features/service-endpoint-configuration.md#haskell)
* [Anonymous contexts and users](https://launchdarkly.com/docs/sdk/features/anonymous.md#haskell)
* [Context configuration](https://launchdarkly.com/docs/sdk/features/context-config.md#haskell)
* [Flag variation evaluation](https://launchdarkly.com/docs/sdk/features/evaluating.md#haskell)
* [Flag variation evaluation details](https://launchdarkly.com/docs/sdk/features/evaluation-reasons.md#haskell)
* [Flushing events](https://launchdarkly.com/docs/sdk/features/flush.md#haskell)
* [Getting all flags](https://launchdarkly.com/docs/sdk/features/all-flags.md#haskell)
* [Identifying and changing contexts](https://launchdarkly.com/docs/sdk/features/identify.md#haskell)
* [Offline mode](https://launchdarkly.com/docs/sdk/features/offline-mode.md#haskell)
* [Private attributes](https://launchdarkly.com/docs/sdk/features/private-attributes.md#haskell)
* [Reading flags from a file](https://launchdarkly.com/docs/sdk/features/flags-from-files.md#haskell)
* [Relay Proxy configuration](https://launchdarkly.com/docs/sdk/features/relay-proxy-configuration)
  * [Using proxy mode](https://launchdarkly.com/docs/sdk/features/relay-proxy-configuration/proxy-mode.md#haskell)
  * [Using daemon mode](https://launchdarkly.com/docs/sdk/features/relay-proxy-configuration/daemon-mode.md#haskell)
* [Secure mode](https://launchdarkly.com/docs/sdk/features/secure-mode.md#haskell)
* [Tracking custom events](https://launchdarkly.com/docs/sdk/features/events.md#haskell)
* [Shutting down](https://launchdarkly.com/docs/sdk/features/shutdown.md#haskell)
* [Storing data](https://launchdarkly.com/docs/sdk/features/storing-data#haskell)
* [Test data sources](https://launchdarkly.com/docs/sdk/features/test-data-sources.md#haskell)
