Download   Getting started


The full power of R's extensive standard library at your fingertips, plus virtually all CRAN packages, which work from Haskell just as they would from R.


Optional type annotations let you leverage the full power of Haskell's type system to program R safely. Region-based memory allocation means precise and predictable memory usage without the dangers: Haskell's type system has your back to statically guarantee the absence of use-after-free bugs.

View details »


Zero marshalling language interop, for crossing language boundaries extremely efficiently at runtime. Mapping an R function over a million element container from Haskell is just as fast as from R.

View details »

The power of R ...
with the safety of Haskell

Haskell is a statically typed, purely functional programming language with a state-of-the-art native code compiler.

R is an old but effective programming language sporting one of the most comprehensive sets of libraries for statistical analysis.

HaskellR is an umbrella project bringing together a number of packages for statistical analysis and machine learning in Haskell using R's comprehensive library support. Including:

  • inline-r: efficiently mix Haskell and R code in the same source file using quasiquotation. R code is designed to be evaluated using an instance of the R interpreter embedded in the binary, with no marshalling costs and hence little to no overhead when communicating values back to Haskell.
  • H: an interactive prompt for exploring and graphing data sets. This is a thin wrapper around GHCi, with the full power of an R prompt, and the full power of Haskell prompt: you can enter expressions of either language, providing you with plotting and distributed computing facilities out-of-the-box.
  • ihaskell-inline-r: an alternative and featureful interactive environment leveraging the Jupyter framework for authoring shareable and collaborative notebooks replete with inline descriptions, equations and graphs.
Interactively author notebooks using IHaskell/Jupyter:
R's powerful graphing facilities at your fingertips: © 2015 FP Complete Corp.

Code examples

Clustering example

{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE ScopedTypeVariables #-}
import H.Prelude as H
import Language.R.QQ

import System.Random

main = H.withEmbeddedR defaultConfig $ do
  H.runRegion $ do
    -- Put any complex model here
    std <- io $ newStdGen
    let (xs::[Double]) = take 100 $ randoms std
    d  <- [r| matrix(xs_hs,ncol = 2) |]
    rv <- [r| clusters <- kmeans(d_hs, 2) |]
    [r| par(mar = c(5.1, 4.1, 0, 1));
        plot(d_hs, col = rv_hs$cluster, pch = 20
            , cex = 3, xlab = "x", ylab = "y");
        points(rv_hs$centers, pch = 4, cex = 4, lwd = 4);
    return ()