talira

Safe, fast alternative Prelude for Haskell

open sourceMITfree

relude is an alternative standard library (Prelude) for Haskell. It replaces partial functions such as head and fromJust with total ones (taking NonEmpty lists or returning Maybe), prefers Text over String, avoids space-leaking functions, and changes behaviour only for a small set of functions, so most names mean what they mean in base. It depends almost only on GHC's boot libraries, follows the Package Versioning Policy, and ships its own HLint rules to help migrate. You switch to it with cabal mixins or NoImplicitPrelude. Kowainik maintains it.

Problems it solves

  • replace Haskell's default Prelude with a safer one
  • avoid partial functions like head in my Haskell code
  • a Haskell standard library that uses Text instead of String

Features

  • total versions of partial functions such as head, tail and read
  • Text-first API and space-leak-free functions such as sum and product
  • depends almost only on GHC boot libraries
  • its own HLint rules for migrating
  • adopt it per project with cabal mixins or NoImplicitPrelude

Limitations

  • Like any alternative prelude, it means learning a different standard library and adding a dependency.1

Alternatives

The same job

These do what relude does.

  1. rio (Haskell) A standard library and Prelude replacement for production Haskell
  2. MissingH A large utility library for Haskell
  3. extra Extra functions for the standard Haskell libraries
  4. base-compat Newer Haskell base functions on older compilers, without CPP

Compare relude with the top 3