quaalude: Extremely minimal prelude

[ apache, library, prelude ] [ Propose Tags ] [ Report a vulnerability ]

Essentials is a minimal Prelude alternative containing only what is truly needed by the vast majority of modules.


[Skip to Readme]

Downloads

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

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.0.0, 0.0.0.1
Change log changelog.md
Dependencies base (>=4.16 && <4.20) [details]
License Apache-2.0
Author Chris Martin
Maintainer Chris Martin, Julie Moronuki
Revised Revision 2 made by chris_martin at 2023-11-14T00:03:41Z
Category Prelude
Home page https://github.com/typeclasses/quaalude
Bug tracker https://github.com/typeclasses/quaalude/issues
Source repo head: git clone git://github.com/typeclasses/quaalude.git
Uploaded by chris_martin at 2023-01-26T06:51:20Z
Distributions LTSHaskell:0.0.0.1, NixOS:0.0.0.1
Reverse Dependencies 7 direct, 4 indirect [details]
Downloads 355 total (14 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-01-26 [all 1 reports]

Readme for quaalude-0.0.0.1

[back to package description]

Essentials is a small Prelude alternative. It was born out of the experience of maintaining a number of libraries that don't use a prelude at all, preferring instead to use tightly limited explicit imports. When we do this, we find that although the standard prelude contains many things that most modules can live without, there is a handful of items that most code truly needs.

There are plenty of good reasons to use names that conflict with things in the standard prelude. For example, the standard prelude has a takeWhile function that deals with lists; a streaming library might define a function of the same name that deals with effectful streams. The standard prelude has a log function that is an abbreviation for 'logarithm'; a logging library might define a function of the same name that writes an event to a log file. Some names, however, are more sacrosanct. It would be generally unwise and unappreciated to define anything named pure or (>>=), for example. The guiding principle for the Essentials module is that it includes things in the latter category.

Function

($) :: (a -> b) -> a -> b
(&) :: a -> (a -> b) -> b

($) and (&) are the same function, just flipped. (&) has slightly higher operator precedence.

Category

id :: Category cat => cat a a
(>>>) :: Category cat => cat a b -> cat b c -> cat a c
(<<<), (.) :: Category cat => cat b c -> cat a b -> cat a c

Usually specialized as cat ~ (->):

id :: a -> a
(>>>) :: (a -> b) -> (b -> c) -> a -> c
(<<<), (.) :: (b -> c) -> (a -> b) -> a -> c

(>>>) and (<<<) are the same function, just flipped.

(.) is the same as (<<<), but with higher operator precedence.

Functor, Applicative, Monad

pure :: Applicative f => a -> f a
fmap, (<$>) :: Functor f => (a -> b) -> f a -> f b
(<&>) :: Functor f => f a -> (a -> b) -> f b

(<$>) is the same as fmap. (<$>) and (<&>) are also the same function, just flipped. (<$>) has higher operator precedence.

(<*>) :: Applicative f => f (a -> b) -> f a -> f b
(<**>) :: Applicative f => f a -> f (a -> b) -> f b

(<*>) and (<**>) are the same function, just flipped.

(>>=) :: Monad m => m a -> (a -> m b) -> m b
(=<<) :: Monad m => (a -> m b) -> m a -> m b

(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c

(>>=) is left associative; (=<<) is right associative.

These functions keep all effects but discard some values:

(<$) :: Functor f => a -> f b -> f a
(<*) :: Applicative f => f a -> f b -> f a

($>) :: Functor f => f a -> b -> f b
(*>) :: Applicative f => f a -> f b -> f b

void :: Functor f => f a -> f ()

Boole

data Bool = False | True

otherwise = True

Comparison

(==), (/=) :: Eq a => a -> a -> Bool

(<), (>), (<=), (>=) :: Ord a => a -> a -> Bool

Monoid

(<>) :: Semigroup a => a -> a -> a
mempty :: Monoid a => a

Traversal

traverse :: Traversable t => Applicative f =>
    (a -> f b) -> t a -> f (t b)

traverse_ :: Foldable t => Applicative f =>
    (a -> f b) -> t a -> f ()

Maybe

data Maybe a =
    Nothing | Just a
maybe :: b -> (a -> b) -> Maybe a -> b

Void

data Void
absurd :: Void -> a

Identity

newtype Identity a =
    Identity {runIdentity :: a}

Const

newtype Const a b =
    Const {getConst :: a}

Type classes

  • Semigroup
  • Monoid
  • Eq
  • Ord
  • Enum
  • Bounded
  • Show

Constructor classes

  • Functor
  • Applicative
  • Monad
  • Foldable
  • Traversable

Type

  • Type

Undefined

undefined :: a

Fixities

infixr 0  $

infixl 1  &  <&>  >>=

infixr 1  =<<  <=<  >=>
               <<<  >>>

infixl 4  <$>  <$  $>
          <*>  *>  <*  <**>

infix  4  ==  /=
          <   >
          <=  >=

infixr 6  <>

infixr 9  .