[ ⠋ COMPILING... ]alpha

Basel Haskell Compiler

An alternative compiler for Haskell with a modern runtime, multiple targets, and opt-in extensions.

terminal
$curl -fsSL https://arcanist.sh/bhc/install.sh | sh
[ THIS IS HASKELL ] haskell.org

This is Haskell

BHC compiles Haskell — the same language you know. Your code, your packages, your ecosystem. We're not inventing a new language; we're building a new compiler.

Statically typed

Every expression has a type determined at compile time. Types are inferred—write less, catch more.

Purely functional

Functions have no side effects. State and I/O are explicit. Equational reasoning works.

Type inference

The compiler deduces types. You write signatures where they help; the machine handles the rest.

Concurrent

Lightweight threads, software transactional memory, and primitives that compose.

Lazy

Values are computed only when needed. Define infinite data structures; consume what you use.

Packages

Hackage hosts thousands of libraries. Cabal manages dependencies. The ecosystem exists.

What BHC Adds

→
Ecosystem preservedUse existing .cabal files and Hackage packages. No forks, no rewrites.
→
Improved developer experienceClear diagnostics, predictable compilation, modern toolchain integration.
→
Numerical and GPU focusTensor IR, guaranteed fusion, SIMD lowering, CUDA/ROCm codegen for compute workloads.
→
Multiple targetsNative binaries, WASM for edge and browser, runtime profiles per package.
[ CAPABILITIES ]

Capabilities

BHC extends standard Haskell with runtime profiles, a tensor-native numeric pipeline, and compilation targets beyond native binaries. Same language, more options.

Compatibility-first

Targets Haskell 2010 and selected GHC editions. Use existing .cabal files and Hackage packages. Your code works unchanged.

Runtime profiles

Same source language, different runtime contracts. Choose default, server, numeric, or edge profiles per package.

Numeric performance

Tensor-native pipeline, guaranteed fusion patterns, SIMD lowering. Predictable performance for numeric workloads.

Multiple targets

Native compilation for servers, WASI/WASM for sandboxed compute and edge. Haskell doesn't mean one runtime on one OS.

Structured concurrency

Server profile brings cancellation, deadlines, and scoping. Observability hooks for tracing and debugging.

Opt-in extensions

BHC innovations are explicit. Enable BHC2026 bundle or individual BHC.* extensions. Stay portable or specialize.

[ PROFILES ]

Runtime Profiles

Same language, different runtime behavior. Choose a profile per package.

Main.hs
module Main where

-- | Standard Haskell 2010 application compiled with the default profile.
-- This code works identically with GHC and BHC, prioritizing correctness
-- and compatibility over aggressive optimization.

import Data.List (sort, foldl')
import Text.Printf (printf)

-- | Entry point: idiomatic Haskell with lazy evaluation preserved.
-- The default profile maintains GHC's evaluation semantics exactly.
main :: IO ()
main = do
    let numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
    putStrLn "Statistics for input list:"
    printf "  Sorted:  %s\n" (show $ sort numbers)
    printf "  Sum:     %d\n" (sumStrict numbers)
    printf "  Mean:    %.2f\n" (mean numbers)

-- | Strict left fold to avoid space leaks.
-- Even in default profile, explicit strictness is respected.
sumStrict :: [Int] -> Int
sumStrict = foldl' (+) 0

-- | Calculate arithmetic mean of a list.
-- Uses standard Haskell idioms that work with any Haskell compiler.
mean :: [Int] -> Double
mean xs = fromIntegral (sumStrict xs) / fromIntegral (length xs)

Try It Now

Install BHC and compile your first program in 30 seconds.

# 1. Install BHC (or: brew install arcanist-sh/tap/bhc)
curl -fsSL https://arcanist.sh/bhc/install.sh | sh

# 2. Add to your PATH (or restart your terminal)
export PATH="$HOME/.bhc/bin:$PATH"
export LIBRARY_PATH="$HOME/.bhc/lib:$LIBRARY_PATH"

# 3. Create a Haskell file
echo 'main = putStrLn "Hello from BHC!"' > hello.hs

# 4. Compile and run
bhc hello.hs -o hello
./hello

Output: Hello from BHC!

BHC produces native executables via LLVM. No runtime interpreter, just fast native code.

How far along is BHC?

The status page tracks the concrete numbers — what percentage of Pandoc compiles today, which backends and profiles work end-to-end, and where the honest caveats are. Updated when the numbers move.

[ FAQ ]

Frequently Asked Questions

Is BHC a fork of GHC?
No. BHC is a clean-slate compiler written in Rust. It targets the Haskell 2026 Platform specification and prioritizes predictable performance, structured concurrency, and a tensor-native numeric pipeline. It does not share code with GHC.
Why might I choose BHC over GHC?
BHC makes different tradeoffs. Choose BHC if: you want a compiler designed around WebAssembly and GPU targets, explicit runtime profiles, fusion contracts and structured concurrency, and you are comfortable with a young toolchain whose code generator is still catching up with that design; or you want a smaller, more hackable compiler to contribute to. Choose GHC if: you need maximum Hackage compatibility today; you rely heavily on Template Haskell; you need battle-tested production stability; or your codebase uses GHC-specific extensions BHC doesn't yet support. They compile the same language. BHC is younger but opinionated about modern deployment targets and numeric workloads. GHC has decades of ecosystem and stability. Many projects may eventually use both.
Can I use my existing Haskell packages?
BHC is actively working on real-world Haskell compatibility (M11). It supports LANGUAGE pragmas, the Haskell 2010 layout rule, the full module system, type classes, and many common extensions. Check the compatibility page for current status.
What are runtime profiles?
Profiles are compile-time configurations with different performance contracts. Default: lazy evaluation, GC-managed. Server: structured concurrency, observability. Numeric: strict-by-default, guaranteed fusion. Edge: minimal runtime for WASM. Realtime and embedded profiles are planned, not yet selectable.
What makes the Numeric profile special?
The Numeric profile guarantees fusion for standard patterns like map f (map g x) and sum (map f x). No hidden allocations, SIMD auto-vectorization, and a Tensor IR that tracks shapes and strides. Fusion failure is a compiler bug.
Does BHC support GPUs?
Partly. The Metal backend runs tensor kernels on Apple-silicon GPUs today. CUDA (PTX) and ROCm (AMDGCN) code generation exists and passes mock validation, but has not yet been tested on NVIDIA or AMD hardware. The goal is that you write standard Haskell with tensor syntax and the compiler handles GPU code generation and memory transfers.
What about WebAssembly?
BHC can target WASM for browser and edge deployment. Use --target wasm32-wasi with the Edge profile for minimal runtime footprint. SIMD128 is supported for numeric workloads.
Is BHC production-ready?
BHC is in beta. Native code generation and language completeness are done, the WebAssembly backend runs in wasmtime, and BHC compiles all 221 modules of Pandoc to a binary whose Markdown reader and HTML writer run end to end. Numeric fusion and server concurrency exist but are not yet wired into native output, and there is no live garbage collector yet, so long-running programs are not a fit today. See the status page for measured details.
How do I report bugs or contribute?
Open an issue or discussion on GitHub. We follow conventional commits and welcome contributions. See CLAUDE.md for development guidelines.
Does BHC work with Cabal and Stack?
Yes, through hx. hx reads your existing .cabal files, resolves dependencies from Hackage, and builds with BHC when you pass --backend bhc or set it in hx.toml. Existing project files work without modification; how much of a given package compiles depends on the compatibility status of what it uses.
How do I migrate a project from GHC?
Start with bhc check to identify compatibility issues. Most pure Haskell code compiles unchanged. Check the compatibility page for extension support. Migration is incremental—you can compile some modules with BHC while others use GHC.
Which GHC extensions are supported?
BHC supports most common extensions: GADTs, TypeFamilies, DataKinds, RankNTypes, FlexibleContexts, and more. Template Haskell has partial support. See the compatibility charter for the full list and known gaps.
Why is BHC written in Rust?
Rust provides memory safety, predictable performance, and excellent tooling. A clean-slate implementation lets us design a modern compiler architecture without legacy constraints. The choice has no effect on the Haskell code you write.
Does BHC use LLVM?
Yes. BHC uses LLVM for native code generation, just like GHC (optionally), Rust, Swift, and many other modern compilers. LLVM provides battle-tested optimizations, broad target support (x86, ARM, RISC-V), and SIMD auto-vectorization. The GPU backends generate PTX/AMDGCN directly, while the WASM backend emits WebAssembly without LLVM.
What does BHC enable for Haskell?
BHC makes Haskell viable for domains where it previously struggled to compete. Machine learning with tensor-native compilation and GPU acceleration. Bioinformatics — protein folding, genomics, sequence analysis — with predictable numeric performance. Security policy engines where declarative 'what, not how' expressiveness ensures correctness. In a world where AI generates implementation code, languages that cleanly express intent, constraints, and invariants become primary. Haskell's type safety and declarative style are assets, not luxuries. BHC aims to add the runtime to match: WebAssembly for edge enforcement and GPUs for compute. Specify what you want; let the compiler and runtime handle how.
How are BHC's error messages?
BHC prioritizes clear diagnostics. Error messages include source spans, suggested fixes, and explanations. Type errors show the full unification trace when needed. Use --explain E0123 for detailed documentation on any error code.
Can BHC cross-compile?
Yes. BHC supports native (x86_64, aarch64) and WebAssembly (wasm32-wasi) from a single installation; use --target to choose. No separate toolchain installation is required for WASM. Bare-metal embedded targets are planned.