Basel Haskell Compiler
An alternative compiler for Haskell with a modern runtime, multiple targets, and opt-in extensions.
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
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.
Runtime Profiles
Same language, different runtime behavior. Choose a profile per package.
--profile=defaultGeneral-purpose compilation. Focuses on correctness and GHC compatibility. Suitable for most applications.
bhc Main.hsmodule 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
./helloOutput: Hello from BHC!
BHC produces native executables via LLVM. No runtime interpreter, just fast native code.
Frequently Asked Questions
Is BHC a fork of GHC?
Why might I choose BHC over GHC?
Can I use my existing Haskell packages?
What are runtime profiles?
What makes the Numeric profile special?
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?
What about WebAssembly?
--target wasm32-wasi with the Edge profile for minimal runtime footprint. SIMD128 is supported for numeric workloads.Is BHC production-ready?
How do I report bugs or contribute?
Does BHC work with Cabal and Stack?
.cabal files directly and resolves dependencies from Hackage. Use bhc build as a drop-in for cabal build. Stack support is planned. Existing project files work without modification.How do I migrate a project from GHC?
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?
Why is BHC written in Rust?
Does BHC use LLVM?
What does BHC enable for Haskell?
How are BHC's error messages?
--explain E0123 for detailed documentation on any error code.Can BHC cross-compile?
--target to specify. No separate toolchain installation required for WASM.