relude-0.7.0.0: Safe, performant, user-friendly and lightweight Haskell Standard Library
relude
is an alternative prelude library. If you find the default
Prelude
unsatisfying, despite its advantages, consider using relude
instead.
Relude goals and design principles
- Productivity. You can be more productive with a "non-standard" standard
library, and
relude
helps you with writing safer and more efficient code faster. - Total programming. Usage of partial functions
can lead to unexpected bugs and runtime exceptions in pure
code. The types of partial functions lie about their behaviour. And
even if it is not always possible to rely only on total functions,
relude
strives to encourage best-practices and reduce the chances of introducing a bug.
Partial | Total |
---|---|
head :: [a] -> a | head :: NonEmpty a -> a |
tail :: [a] -> [a] | tail :: NonEmpty a -> [a] |
read :: Read a => String -> a | readMaybe :: Read a => String -> Maybe a |
fromJust :: Maybe a -> a | fromMaybe :: a -> Maybe a -> a |
- Type-safety. We use the "make invalid states unrepresentable" motto as one
of our guiding principles. If it is possible, we express this concept through the
types.
Example:
whenNotNull :: Applicative f => [a] -> (NonEmpty a -> f ()) -> f ()
- Performance. We prefer
Text
overString
, use space-leaks-free functions (e.g. our custom performantsum
andproduct
), introduce{-# INLINE #-}
and{-# SPECIALIZE #-}
pragmas where appropriate, and make efficient container types (e.g.Map
,HashMap
,Set
) more accesible. - Minimalism (low number of dependencies). We don not force users of
relude
to stick to any specific lens or text formatting or logging library. Where possible,relude
depends only on boot libraries. The Dependency graph ofrelude
can give you a clearer picture. - Convenience. Despite minimalism, we want to bring commonly used types and functions into scope, and make available functions easier to use. Some examples of conveniences:
- No need to import types like
NonEmpty
,Text
,Set
,Reader[T]
,MVar
,STM
- Functions like
liftIO
,fromMaybe
,sortWith
are avaiable by default as well IO
actions are lifted toMonadIO
- Excellent documentation.
- Tutorial
- Migration guide from
Prelude
- Haddock for every function with examples tested by [doctest](http:/hackage.haskell.orgpackage/doctest).
- Documentation regarding internal module structure
relude
-specific HLint rules:.hlint.yaml
- User-friendliness. Anyone should be able to quickly migrate to
relude
. Only some basic familiarity with the common libraries liketext
andcontainers
should be enough (but not necessary). - Exploration. We have space to experiment with new ideas and proposals
without introducing breaking changes.
relude
uses the approach withExtra.*
modules which are not exported by default. The chosen approach makes it quite easy for us to provide new functionality without breaking anything and let the users decide to use it or not.
Signatures
Modules