SDL3 Haskell Bindings λ

Work in progress bindings for the SDL3 library written in Haskell.

Please report any bugs or suggestions you have for the bindings!

Setup Instructions

NOTE: These bindings are for SDL version 3.3 as of right now.

Install SDL3 from source: SDL GitHub

Linux

To build SDL3 from source on Linux:

# Navigate to SDL3 source directory
cd path/to/SDL3/source

# Create and enter build directory
mkdir build
cd build

# Configure with cmake.
# CMAKE_BUILD_TYPE can be whatever you need it to be.
cmake -DCMAKE_BUILD_TYPE=Release -GNinja ..

# Build
cmake --build . --config Release --parallel

# Install (requires sudo)
sudo cmake --install . --config Release

This will install SDL3 to your system so that cabal can find and build the sdl3 package.

Find your way back to this project's directory and run cabal build sdl3 to build just the package.

Windows

Recommendation: Use the Developer PowerShell or Developer Command Prompt that comes with Visual Studio for best results.

# Navigate to SDL3 source directory
cd path/to/SDL3/source

# Create and enter build directory
mkdir build
cd build

# Configure with cmake.
# CMAKE_BUILD_TYPE can be whatever you need it to be.
cmake -DCMAKE_BUILD_TYPE=Release -GNinja ..

# Build
cmake --build . --config Release --parallel

# Install (requires sudo)
cmake --install . --config Release

Make sure SDL3 compiles a .DLL file, and pkgconfig knows that SDL3 exists. (You might have to install pkgconfig using your pacman of choice.)

You can do this by setting:

set PKG_CONFIG_PATH="path\to\SDL3\lib\pkgconfig"
# or
$env:PKG_CONFIG_PATH="path\to\SDL3\lib\pkgconfig\"

Ensure the .DLL file is present in your PATH environment variable or within the root directory for this project.

You'll also want to add a cabal.project.local file to the root directory with:

package *
  extra-include-dirs: "path/to/SDL3/include/"
  extra-lib-dirs: "path/to/SDL3/lib/"

Once all of this is done, you can find your way into this directory and run cabal build sdl3 to build just the package.

Building and Running Examples

To build all examples:

cabal build --flag examples

To see a list of all available examples:

cabal run --flag examples

To run a specific example:

cabal run --flag examples EXAMPLE_NAME

For example, to run the init example:

cabal run --flag examples init

You can also build specific executables in a similar manner by specifying the target name.

Build Options

The bindings support two main build configurations:

Dynamic Linking (Default)

cabal build sdl3                    # Build library only
cabal build --flag examples        # Build with examples

This is the default and recommended approach for development. Your executable will depend on SDL3 shared libraries.

Static Linking

cabal build --flag static-linking  # Build with static SDL3 (Linux only)

Creates self-contained executables with SDL3 compiled in. Requires SDL3 to be built with static libraries enabled.

⚠️ macOS Limitation: Static linking is not supported on macOS due to Apple's linking restrictions. The static-linking flag is ignored on macOS. Use dynamic linking with bundled libraries instead (see DISTRIBUTION.md).

Note: Static linking requires SDL3 built with -DBUILD_SHARED_LIBS=OFF. See DISTRIBUTION.md for details.

Cabal Project Configuration

Add to cabal.project.local:

package sdl3
  flags: +static-linking  # Enable static linking

Distribution

For distributing applications to end users, see our comprehensive Distribution Guide which covers:

Quick Summary:

Working Examples

Core Functionality

Initialization & System

Window & Rendering

Rendering

Misc

GPU & Graphics

These examples are based off of the original SDL3 GPU Examples

Input & Interaction

User Input

User Interface

Audio & Media

Audio

Camera

System Integration

File & Data

Internationalization

Time & Process Management

Time

Process

Sensors

Hardware

📊 Binding Status

Last updated: 2025-08-20 18:40 UTC

SDL3 commit: e1a623f129e75ad532315852d656fb26c80382a6

Summary

Status by Module

Module Status
SDL_assert ✅ Complete
SDL_asyncio ✅ Complete
SDL_atomic ✅ Complete
SDL_audio ✅ Complete
SDL_bits ✅ Complete
SDL_blendmode ✅ Complete
SDL_camera ✅ Complete
SDL_clipboard ✅ Complete
SDL_cpuinfo ✅ Complete
SDL_dialog ✅ Complete
SDL_endian ✅ Complete
SDL_error ✅ Complete
SDL_events ✅ Complete
SDL_filesystem ✅ Complete
SDL_gamepad ✅ Complete
SDL_gpu ✅ Complete
SDL_guid ✅ Complete
SDL_haptic ✅ Complete
SDL_hidapi ✅ Complete
SDL_hints ✅ Complete
SDL_init ✅ Complete
SDL_iostream ✅ Complete
SDL_joystick ✅ Complete
SDL_keyboard ✅ Complete
SDL_keycode ✅ Complete
SDL_loadso ✅ Complete
SDL_locale ✅ Complete
SDL_log ✅ Complete
SDL_messagebox ✅ Complete
SDL_metal ✅ Complete
SDL_misc ✅ Complete
SDL_mouse ✅ Complete
SDL_mutex ✅ Complete
SDL_pen ✅ Complete
SDL_pixels ✅ Complete
SDL_platform ✅ Complete
SDL_power ✅ Complete
SDL_process ✅ Complete
SDL_properties ✅ Complete
SDL_rect ✅ Complete
SDL_render ✅ Complete
SDL_scancode ✅ Complete
SDL_sensor ✅ Complete
SDL_stdinc ✅ Complete
SDL_storage ✅ Complete
SDL_surface ✅ Complete
SDL_system ✅ Complete
SDL_thread ✅ Complete
SDL_time ✅ Complete
SDL_timer ✅ Complete
SDL_touch ✅ Complete
SDL_tray ✅ Complete
SDL_version ✅ Complete
SDL_video ✅ Complete
SDL_vulkan ✅ Complete

Legend

Notes