foundation: Alternative prelude with batteries and no dependencies

[ bsd3, foundation, library ] [ Propose Tags ]

A custom prelude with no dependencies apart from base.

This package has the following goals:

[Skip to Readme]
Versions [faq] 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.18, 0.0.19, 0.0.20, 0.0.21, 0.0.22, 0.0.23, 0.0.24, 0.0.25
Dependencies base (>=4 && <4.11), ghc-prim, Win32 [details]
License BSD-3-Clause
Copyright Vincent Hanquez <>
Author Vincent Hanquez <>
Revised Revision 1 made by phadej at 2018-04-03T17:11:08Z
Category foundation
Home page
Bug tracker
Source repo head: git clone
Uploaded by VincentHanquez at 2017-04-05T10:09:48Z
Distributions Arch:0.0.25, Debian:0.0.21, Fedora:0.0.25, LTSHaskell:0.0.23, NixOS:0.0.25, Stackage:0.0.23, openSUSE:0.0.25
Downloads 85717 total (689 in the last 30 days)
Rating 2.25 (votes: 4) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2017-04-05 [all 1 reports]





Add some comparaison benchmarks against other haskell libraries


Add extra friendly boundary check for unsafe array operations


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Readme for foundation-0.0.6

[back to package description]


Build Status Coverage Status BSD Haskell

Documentation: foundation on hackage


  • provide a base like set of modules that provide a consistent set of features and bugfixes across multiple versions of GHC (unlike base).
  • provide a better and more efficient prelude than base's prelude.
  • be self-sufficient: no external dependencies apart from base (or ghc packages).
  • provide better data-types: packed unicode string by default, arrays.
  • Better numerical classes that better represent mathematical things (No more all-in-one Num).


How to use with the normal Prelude

Add the foundation package in your cabal file, and it's recommended to import Foundation qualified if you're planning to use with the normal Prelude:

For example:

import qualified Foundation as F

It's also recommended if you're going to deal with packages using text, bytestring, vector.. to use the foundation-edge package.

How to use fully without Prelude

Disable the built-in prelude at the top of your file:

{-# LANGUAGE NoImplicitPrelude #-}

Or directly in your project cabal file:

Default-Extensions: NoImplicitPrelude

Then in your modules:

import Foundation

Advanced settings

Please check out the chapter Advanced Usage Options in the documentation.

How to contribute

Any contributions is welcome, but a short list includes:

  • Improve the code base
  • Report an issue
  • Fix an issue
  • Improve the documentation
  • Make tutorial on how to use foundation
  • Make your project use foundation instead of base, report the missing coverage (IO, types, etc.), or what functionality is missing to make a succesful transition


If you want to see the core (simpl step) or the assembly (asm step), then you can build with

stack build --ghc-options -ddump-simpl --ghc-options -ddump-asm

Note that it doesn't actually will create the necessary extra files if the modules doesn't need building.

you can then find your build by-products in:


Each modules that get compiled will create an equivalent file in the build directory:

  • ModuleName.dump-simpl
  • ModuleName.dump-asm

For profiling individual programs, the following command is useful:

stack ghc -- -O --make X.hs -prof -auto-all -caf-all -fforce-recomp


To get the list of benchmark:

stack bench --benchmark-arguments -l

To compare against other libraries, you need to set the bench-all flag

stack bench --flag foundation:bench-all --benchmark-arguments -l

To run a specific or set of benchmarks :

stack bench --flag foundation:bench-all --benchmark-arguments 'types/String/SplitAt/mascii-10/Text'
stack bench --flag foundation:bench-all --benchmark-arguments '-m prefix types/String/SplitAt'
stack bench --flag foundation:bench-all --benchmark-arguments '-m glob types/String/SplitAt'

To register a set of benchmarks:

stack bench --flag foundation:bench-all --benchmark-arguments "--csv $(git describe).csv"


Foundation started on the simple idea of trying to put everything I need in one simple and consistent package. The amazing haskell ecosystem is extremely fragmented and maintained by different people with different goals, free time, and style. The overall scare of not trying to change anything relatively central (base, bytestring, text, vector, ...) for a promise of stability has pushed many people to work on their own thing, leading to unnecessary work duplication and further fragmentation.

Foundation uses and abuses type families.