README.md 4.6 KB

Supported tags and respective Dockerfile links

For more information about this image and its history, please see the relevant manifest file (library/haskell) in the docker-library/official-images GitHub repo.

What is Haskell?

Haskell is a lazy, functional, statically-typed programming language with advanced type system features such as higher-rank, higher-kinded parametric polymorphism, monadic effects, generalized algebraic data types (GADTs), flexible type classes, associated type families, and more.

Haskell's ghc is a portable, optimizing compiler with a foreign-function interface (FFI), an LLVM backend, and sophisticated runtime support for concurrency, explicit/implicit parallelism, runtime profiling, etc. Other Haskell tools like criterion, quickcheck, hpc, and haddock provide advanced benchmarking, property-based testing, code coverage, and documentation generation.

A large number of production-quality Haskell libraries are available from Hackage. The cabal tool fetches packages and builds projects using the Hackage ecosystem.

logo

Contents

This image ships a minimal Haskell toolchain with the following packages:

package version
alex 3.1.3
cabal-install 1.20.0.3
happy 1.19.4
ghc 7.8.3

Usage

  • Start an interactive interpreter session with ghci:

    $ docker run -it --rm haskell:7.8
    GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
    Loading package ghc-prim ... linking ... done.
    Loading package integer-gmp ... linking ... done.
    Loading package base ... linking ... done.
    Prelude>
    
  • Dockerize a Hackage app with a Dockerfile inheriting from the base image:

    FROM haskell:7.8
    RUN cabal update && cabal install MazesOfMonad
    VOLUME /root/.MazesOfMonad
    ENTRYPOINT ["/root/.cabal/bin/mazesofmonad"]
    
  • Iteratively develop then ship a Haskell app with a Dockerfile utilizing the build cache:

    FROM haskell:7.8
    
    RUN cabal update
    
    # Add .cabal file
    ADD ./server/snap-example.cabal /opt/server/snap-example.cabal
    
    # Docker will cache this command as a layer, freeing us up to
    # modify source code without re-installing dependencies
    RUN cd /opt/server && cabal install --only-dependencies -j4
    
    # Add and Install Application Code
    ADD ./server /opt/server
    RUN cd /opt/server && cabal install
    
    # Add installed cabal executables to PATH
    ENV PATH /root/.cabal/bin:$PATH
    
    # Default Command for Container
    WORKDIR /opt/server
    CMD ["snap-example"]
    

Examples

See the application snippet above in more detail in the example snap application.

License

This image is licensed under the MIT License (see LICENSE), and includes software licensed under the Glasgow haskell Compiler License (BSD-style).

User Feedback

Please report issues on the GitHub project