quaalude (empty) → 0.0.0.0
raw patch · 5 files changed
+295/−0 lines, 5 filesdep +base
Dependencies added: base
Files
- changelog.md +3/−0
- library/Essentials.hs +41/−0
- license.txt +13/−0
- quaalude.cabal +31/−0
- readme.md +207/−0
+ changelog.md view
@@ -0,0 +1,3 @@+# 0.0.0.0 (2023-01-15)++Initial release
+ library/Essentials.hs view
@@ -0,0 +1,41 @@+module Essentials+ (+ {- * Function -} ($), (&),+ {- * Category -} id, (.), (>>>), (<<<),+ {- * Functor -} fmap, (<$>), (<&>), (<$), ($>), void,+ {- * Applicative -} pure, (<*>), (<**>), (<*), (*>),+ {- * Monad -} (>>=), (=<<), (>=>), (<=<),+ {- * Boole -} Bool (False, True), otherwise,+ {- * Comparison -} (==), (/=), (<), (>), (<=), (>=),+ {- * Monoid -} (<>), mempty,+ {- * Traversal -} traverse, traverse_,+ {- * Maybe -} Maybe (Nothing, Just), maybe,+ {- * Void -} Void, absurd,+ {- * Identity -} Identity (Identity, runIdentity),+ {- * Const -} Const (Const, getConst),+ {- * Type classes -} Semigroup, Monoid, Eq, Ord, Enum, Bounded, Show,+ {- * Constructor classes -} Functor, Applicative, Monad, Foldable, Traversable,+ {- * Type -} Type,+ {- * Undefined -} undefined,+ )+ where++import Control.Applicative (Applicative, pure, (*>), (<*), (<*>), (<**>))+import Control.Category (id, (.), (>>>), (<<<))+import Control.Monad (Monad, (<=<), (=<<), (>=>), (>>=))+import Data.Bool (Bool (False, True), otherwise)+import Data.Eq (Eq, (/=), (==))+import Data.Foldable (Foldable, traverse_)+import Data.Function (($), (&))+import Data.Functor (Functor, fmap, void, ($>), (<$), (<$>), (<&>))+import Data.Functor.Const (Const (Const, getConst))+import Data.Functor.Identity (Identity (Identity, runIdentity))+import Data.Kind (Type)+import Data.Maybe (Maybe (Just, Nothing), maybe)+import Data.Monoid (Monoid, mempty)+import Data.Ord (Ord, (<), (>), (<=), (>=))+import Data.Semigroup (Semigroup, (<>))+import Data.Traversable (Traversable, traverse)+import Data.Void (Void, absurd)+import Prelude (Bounded, Enum, undefined)+import Text.Show (Show)
+ license.txt view
@@ -0,0 +1,13 @@+Copyright 2023 Mission Valley Software LLC++Licensed under the Apache License, Version 2.0 (the "License");+you may not use this file except in compliance with the License.+You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++Unless required by applicable law or agreed to in writing, software+distributed under the License is distributed on an "AS IS" BASIS,+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+See the License for the specific language governing permissions and+limitations under the License.
+ quaalude.cabal view
@@ -0,0 +1,31 @@+cabal-version: 3.0++name: quaalude+version: 0.0.0.0+synopsis: Extremely minimal prelude+category: Prelude++description: "Essentials" is an minimal Prelude alternative containing+ only what is truly needed by the vast majority of modules.++license: Apache-2.0+license-file: license.txt++author: Chris Martin+maintainer: Chris Martin, Julie Moronuki++homepage: https://github.com/typeclasses/quaalude+bug-reports: https://github.com/typeclasses/quaalude/issues++extra-source-files: *.md++source-repository head+ type: git+ location: git://github.com/typeclasses/quaalude.git++library+ default-language: GHC2021+ ghc-options: -Wall+ hs-source-dirs: library+ build-depends: base ^>= 4.16 || ^>= 4.17+ exposed-modules: Essentials
+ readme.md view
@@ -0,0 +1,207 @@+`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++```haskell+($) :: (a -> b) -> a -> b+(&) :: a -> (a -> b) -> b+```++`($)` and `(&)` are the same function, just flipped.+`(&)` has slightly higher operator precedence.++## Category++```haskell+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 ~ (->)`:++```haskell+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++```haskell+pure :: Applicative f => a -> f a+```++```haskell+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.++```haskell+(<*>) :: 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.++```haskell+(>>=) :: 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:++```haskell+(<$) :: 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++```haskell+data Bool = False | True++otherwise = True+```++## Comparison++```haskell+(==), (/=) :: Eq a => a -> a -> Bool++(<), (>), (<=), (>=) :: Ord a => a -> a -> Bool+```++## Monoid++```haskell+(<>) :: Semigroup a => a -> a -> a+mempty :: Monoid a => a+```++## Traversal++```haskell+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++```haskell+data Maybe a =+ Nothing | Just a+```++```haskell+maybe :: b -> (a -> b) -> Maybe a -> b+```++## Void++```haskell+data Void+```++```haskell+absurd :: Void -> a+```++## Identity++```haskell+newtype Identity a =+ Identity {runIdentity :: a}+```++## Const++```haskell+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++```haskell+undefined :: a+```++## Fixities++```haskell+infixr 0 $++infixl 1 & <&> >>=++infixr 1 =<< <=< >=>+ <<< >>>++infixl 4 <$> <$ $>+ <*> *> <* <**>++infix 4 == /=+ < >+ <= >=++infixr 6 <>++infixr 9 .+```