Lots of people dislike the standard prelude, so there have been several attempts to make better ones. Or just reexport a bunch of extra modules (to reduce the number of imports needed). Or both.
base-prelude is almost unambiguously a net win because it simply reexports things from base and lets you reduce your imports without making you learn anything new.
As for other preludes, it's hard to say. protolude looks nice, and classy-prelude is used more often than all other preludes (judging by Github's code search), which probably means something. Anyway, it all depends on your coding style and what exactly you're writing. Also, if you're starting a huge project from scratch, you might want to look at foundation, which reinvents a lot of things (even
Text), but claims to do it better.
A prelude by Stephen Diehl. Described here by its author.
- base, mtl, deepseq, async, void, safe (safer functions for lists)
- Some utility functions (
- Rewrites functions/classes that aren't present in earlier versions of base (
- Defines a class for string conversion and generalises functions like
identity(because it's convenient to be able to name variables
Exports more utility functions than other preludes.
The renaming of
Doesn't do anything radical, so you can start using it quickly.
Adds warnings to
undefined(so you can use them but you're constantly warned that they're still present in code).
undefinedas deprecated (so you'll know if you've accidentally left it in code).
Goes further than other preludes in removing boilerplate like qualified names, etc.
A “foundation” prelude by the author of classy-prelude. Exports two modules –
CorePrelude (intended for developers who want to make their own prelude), and
BasicPrelude (a simple prelude for users, built on
- commonly used functions from
Preludeand other base modules
- types (the usual bunch –
- a selection of functions from other packages (
<.>, as well as hashing functions from hashable, functions for catching exceptions from lifted-base, and
readArgsfrom ReadArgs, a very simple parser for command line arguments)
It also reimplements functions like
Text, and a small number of utility functions (
Control.Monad, methods of
Traversable, some functions from
readFile, etc with their
Text, so can be annoying if you use many libraries that need
Only reimplements a few functions for compatibility with older versions of base (other preludes reimplement more).
Feels somewhat opinionated (why hashable and ReadArgs but not more commonly used libraries like deepseq or mtl? etc).
A single module reexporting most definitions in base. Doesn't serve any purpose other than reducing the number of imports, but is still pretty useful. (For me it routinely shaves off 5–10 imports.)
You don't have to learn any new functions, or, well, anything. Just plug it in and enjoy not having to import things.
Doesn't incur any dependencies.
rebase – uses base-prelude and exports lots of additional modules
A pretty interesting prelude – it depends on lots of commonly used packages (containers, deepseq, hashable, mtl, text, time, uuid, vector, and more), and makes their modules available to you via the
Rebase.* namespace – so, for instance, instead of adding a dependency on text and importing
Data.Text you can just import
Rebase.Data.Text and get
Data.Text.Encoding simultaneously. This means that you save some imports and don't have to manually add a dependency.
Exports modules in full, not just arbitary subsets.
Shaves off more dependency declarations than other libraries.
A superset of base-prelude.
Foundation is a Haskell project to implement a modern & performant standard library with various centrally maintained functionalities.
Haskell's base has been designed a while ago and shows its age. For better or worse, it's also really hard to change base, leading to many interesting but ultimately fruitless discussions, lots of wasted efforts, and/or duplicated pieces and libraries.
Also many core libraries, which brings lots of welcome modern additions to the language (text, bytestring, vector, & many others), are maintained on the side, without coordination. For example bytestring and vector doesn't share any code.
Foundation is trying to provide a solution to those technical and maintainance limitations.
Yet another prelude by Michael Snoyman. From the README:
A Haskell prelude optimized for safety.
No partial functions, period.
Choose best in class libraries (bytestring, text, etc) and promote them.
Regardless of the versions of underlying libraries, this package will always export a consistent API, so that CPP usage should be constrained to just inside this package.
Use generalization (via type classes) when they are well established. For example:
Encourage qualified imports with a consistent naming scheme.
Export any non-conflicting and not-discouraged names from this module that make sense, e.g.
From the README:
SubHask is a radical rewrite of the Haskell Prelude. The goal is to make numerical computing in Haskell fun and fast. The main idea is to use a type safe interface for programming in arbitrary subcategories of Hask. For example, the category Vect of linear functions is a subcategory of Hask, and SubHask exploits this fact to give a nice interface for linear algebra. To achieve this goal, almost every class hierarchy is redefined to be more general.
Maintained by company which uses Haskell in production
Reexports a lot of things you usually need in your code (
Textual data type is defaulted to
IOfunctions are lifted to
A lot of commonly used idioms and convenient functions are introduced
Foldabletype hierarchy a little bit reimagined. You might find it unexpected when some things work for
Foldablebut doesn't work anymore when you're using
Assumes medium knowledge of Haskell. It's hard to use
universumfor Haskell beginners, unfortunately.
universum as a custom prelude.
Not actually an alternative Prelude, but rather a convenient way to define your own Prelude. It re-exports all of base except for
GHC will implicitly import the module called
Prelude, which is usually found in the
base package. If, however, you depend on base-noprelude rather than base and your package has a module called
Prelude, that will be used instead, allowing you to customise it to your needs.
Assemble your own custom prelude that perfectly fits your needs.
No imports or
NoImplicitPreludepragmas at use sites.
Multi-package alternative prelude.
papa-base exports the safe and useful things in
papa-bifunctors exports the safe and useful things in
papa itself exports everything from all sub-packages.