From f7e6cb50e45ee1097188d6711102f54288724ca5 Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Sun, 22 Mar 2015 14:24:05 -0700 Subject: [PATCH] Consistency --- README.md | 43 ++++++++++++++++++++-------------------- src/Control/Alt.purs | 2 +- src/Control/Bind.purs | 6 +++--- src/Control/Comonad.purs | 2 +- src/Control/Extend.purs | 12 +++++------ src/Control/Functor.purs | 6 +++--- src/Control/Lazy.purs | 8 ++++---- src/Control/Monad.purs | 6 +++--- src/Control/Plus.purs | 1 + 9 files changed, 44 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index d7eadb1..87c9089 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Module Control.Alt -This module defines the `Alt` type class +This module defines the `Alt` type class. #### `Alt` @@ -140,7 +140,7 @@ This module defines helper functions for working with `Bind` instances. (=<<) :: forall a b m. (Bind m) => (a -> m b) -> m a -> m b ``` -A version of `(>>=)` with its arguments reversed +A version of `(>>=)` with its arguments flipped. #### `(>=>)` @@ -148,7 +148,7 @@ A version of `(>>=)` with its arguments reversed (>=>) :: forall a b c m. (Bind m) => (a -> m b) -> (b -> m c) -> a -> m c ``` -Forwards Kleisli composition +Forwards Kleisli composition. For example: @@ -164,7 +164,7 @@ third = tail >=> tail >=> head (<=<) :: forall a b c m. (Bind m) => (b -> m c) -> (a -> m b) -> a -> m c ``` -Backwards Kleisli composition +Backwards Kleisli composition. #### `join` @@ -194,7 +194,7 @@ main = ifM ((< 0.5) <$> random) ## Module Control.Comonad -This module defines the `Comonad` type class +This module defines the `Comonad` type class. #### `Comonad` @@ -218,7 +218,7 @@ Laws: ## Module Control.Extend -This module defines the `Extend` type class and associated helper functions +This module defines the `Extend` type class and associated helper functions. #### `Extend` @@ -251,7 +251,7 @@ instance extendArr :: (Semigroup w) => Extend (Prim.Function w) (=>>) :: forall b a w. (Extend w) => w a -> (w a -> b) -> w b ``` -A version of `(<<=)` with its arguments reversed +A version of `(<<=)` with its arguments flipped. #### `(=>=)` @@ -259,7 +259,7 @@ A version of `(<<=)` with its arguments reversed (=>=) :: forall b a w c. (Extend w) => (w a -> b) -> (w b -> c) -> w a -> c ``` -Forwards co-Kleisli composition +Forwards co-Kleisli composition. #### `(=<=)` @@ -267,7 +267,7 @@ Forwards co-Kleisli composition (=<=) :: forall b a w c. (Extend w) => (w b -> c) -> (w a -> b) -> w a -> c ``` -Backwards co-Kleisli composition +Backwards co-Kleisli composition. #### `duplicate` @@ -275,15 +275,15 @@ Backwards co-Kleisli composition duplicate :: forall a w. (Extend w) => w a -> w (w a) ``` -Duplicate a comonadic context +Duplicate a comonadic context. -`duplicate` is dual to `join`. +`duplicate` is dual to `Control.Bind.join`. ## Module Control.Functor -This module defines helper functions for working with `Functor` instances +This module defines helper functions for working with `Functor` instances. #### `(<$)` @@ -291,7 +291,7 @@ This module defines helper functions for working with `Functor` instances (<$) :: forall f a b. (Functor f) => a -> f b -> f a ``` -Ignore the return value of a computation, using the specified return value instead +Ignore the return value of a computation, using the specified return value instead. #### `($>)` @@ -299,7 +299,7 @@ Ignore the return value of a computation, using the specified return value inste ($>) :: forall f a b. (Functor f) => f a -> b -> f b ``` -A version of `(<$)` with its arguments flipped +A version of `(<$)` with its arguments flipped. ## Module Control.Lazy @@ -328,7 +328,7 @@ class Lazy1 l where defer1 :: forall a. (Unit -> l a) -> l a ``` -A version of `Lazy` for type constructors of one type argument +A version of `Lazy` for type constructors of one type argument. #### `Lazy2` @@ -337,7 +337,7 @@ class Lazy2 l where defer2 :: forall a b. (Unit -> l a b) -> l a b ``` -A version of `Lazy` for type constructors of two type arguments +A version of `Lazy` for type constructors of two type arguments. #### `fix` @@ -355,7 +355,7 @@ The `Lazy` instance allows us to generate the result lazily. fix1 :: forall l a. (Lazy1 l) => (l a -> l a) -> l a ``` -A version of `fix` for type constructors of one type argument +A version of `fix` for type constructors of one type argument. #### `fix2` @@ -363,13 +363,13 @@ A version of `fix` for type constructors of one type argument fix2 :: forall l a b. (Lazy2 l) => (l a b -> l a b) -> l a b ``` -A version of `fix` for type constructors of two type arguments +A version of `fix` for type constructors of two type arguments. ## Module Control.Monad -This module defines helper functions for working with `Monad` instances +This module defines helper functions for working with `Monad` instances. #### `replicateM` @@ -377,7 +377,7 @@ This module defines helper functions for working with `Monad` instances replicateM :: forall m a. (Monad m) => Number -> m a -> m [a] ``` -Perform a monadic action `n` times collecting all of the results +Perform a monadic action `n` times collecting all of the results. #### `foldM` @@ -385,7 +385,7 @@ Perform a monadic action `n` times collecting all of the results foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> [b] -> m a ``` -Perform a fold using a monadic step function +Perform a fold using a monadic step function. #### `when` @@ -476,6 +476,7 @@ class (Alt f) <= Plus f where The `Plus` type class extends the `Alt` type class with a value that should be the left and right identity for `(<|>)`. + It is similar to `Monoid`, except that it applies to types of kind `* -> *`, like `Array` or `List`, rather than concrete types like `String` or `Number`. diff --git a/src/Control/Alt.purs b/src/Control/Alt.purs index c53374a..b1877c4 100644 --- a/src/Control/Alt.purs +++ b/src/Control/Alt.purs @@ -1,4 +1,4 @@ --- | This module defines the `Alt` type class +-- | This module defines the `Alt` type class. module Control.Alt where diff --git a/src/Control/Bind.purs b/src/Control/Bind.purs index a33be44..31dcfc9 100644 --- a/src/Control/Bind.purs +++ b/src/Control/Bind.purs @@ -6,11 +6,11 @@ module Control.Bind where infixr 1 >=> infixr 1 <=< - -- | A version of `(>>=)` with its arguments reversed + -- | A version of `(>>=)` with its arguments flipped. (=<<) :: forall a b m. (Bind m) => (a -> m b) -> m a -> m b (=<<) f m = m >>= f - -- | Forwards Kleisli composition + -- | Forwards Kleisli composition. -- | -- | For example: -- | @@ -22,7 +22,7 @@ module Control.Bind where (>=>) :: forall a b c m. (Bind m) => (a -> m b) -> (b -> m c) -> a -> m c (>=>) f g a = f a >>= g - -- | Backwards Kleisli composition + -- | Backwards Kleisli composition. (<=<) :: forall a b c m. (Bind m) => (b -> m c) -> (a -> m b) -> a -> m c (<=<) f g a = f =<< g a diff --git a/src/Control/Comonad.purs b/src/Control/Comonad.purs index d210761..ffd71f0 100644 --- a/src/Control/Comonad.purs +++ b/src/Control/Comonad.purs @@ -1,4 +1,4 @@ --- | This module defines the `Comonad` type class +-- | This module defines the `Comonad` type class. module Control.Comonad where diff --git a/src/Control/Extend.purs b/src/Control/Extend.purs index 57188d7..25cc250 100644 --- a/src/Control/Extend.purs +++ b/src/Control/Extend.purs @@ -1,4 +1,4 @@ --- | This module defines the `Extend` type class and associated helper functions +-- | This module defines the `Extend` type class and associated helper functions. module Control.Extend where @@ -23,20 +23,20 @@ class (Functor w) <= Extend w where instance extendArr :: (Semigroup w) => Extend ((->) w) where (<<=) f g w = f \w' -> g (w <> w') --- | A version of `(<<=)` with its arguments reversed +-- | A version of `(<<=)` with its arguments flipped. (=>>) :: forall b a w. (Extend w) => w a -> (w a -> b) -> w b (=>>) w f = f <<= w --- | Forwards co-Kleisli composition +-- | Forwards co-Kleisli composition. (=>=) :: forall b a w c. (Extend w) => (w a -> b) -> (w b -> c) -> w a -> c (=>=) f g w = g (f <<= w) --- | Backwards co-Kleisli composition +-- | Backwards co-Kleisli composition. (=<=) :: forall b a w c. (Extend w) => (w b -> c) -> (w a -> b) -> w a -> c (=<=) f g w = f (g <<= w) --- | Duplicate a comonadic context +-- | Duplicate a comonadic context. -- | --- | `duplicate` is dual to `join`. +-- | `duplicate` is dual to `Control.Bind.join`. duplicate :: forall a w. (Extend w) => w a -> w (w a) duplicate w = id <<= w diff --git a/src/Control/Functor.purs b/src/Control/Functor.purs index 7ac30fa..2d7684a 100644 --- a/src/Control/Functor.purs +++ b/src/Control/Functor.purs @@ -1,14 +1,14 @@ --- | This module defines helper functions for working with `Functor` instances +-- | This module defines helper functions for working with `Functor` instances. module Control.Functor where infixl 4 <$ infixl 4 $> --- | Ignore the return value of a computation, using the specified return value instead +-- | Ignore the return value of a computation, using the specified return value instead. (<$) :: forall f a b. (Functor f) => a -> f b -> f a (<$) x f = const x <$> f --- | A version of `(<$)` with its arguments flipped +-- | A version of `(<$)` with its arguments flipped. ($>) :: forall f a b. (Functor f) => f a -> b -> f b ($>) f x = const x <$> f diff --git a/src/Control/Lazy.purs b/src/Control/Lazy.purs index 10e21d9..20f4a26 100644 --- a/src/Control/Lazy.purs +++ b/src/Control/Lazy.purs @@ -11,11 +11,11 @@ module Control.Lazy where class Lazy l where defer :: (Unit -> l) -> l --- | A version of `Lazy` for type constructors of one type argument +-- | A version of `Lazy` for type constructors of one type argument. class Lazy1 l where defer1 :: forall a. (Unit -> l a) -> l a --- | A version of `Lazy` for type constructors of two type arguments +-- | A version of `Lazy` for type constructors of two type arguments. class Lazy2 l where defer2 :: forall a b. (Unit -> l a b) -> l a b @@ -25,10 +25,10 @@ class Lazy2 l where fix :: forall l a. (Lazy l) => (l -> l) -> l fix f = defer (\_ -> f (fix f)) --- | A version of `fix` for type constructors of one type argument +-- | A version of `fix` for type constructors of one type argument. fix1 :: forall l a. (Lazy1 l) => (l a -> l a) -> l a fix1 f = defer1 (\_ -> f (fix1 f)) --- | A version of `fix` for type constructors of two type arguments +-- | A version of `fix` for type constructors of two type arguments. fix2 :: forall l a b. (Lazy2 l) => (l a b -> l a b) -> l a b fix2 f = defer2 (\_ -> f (fix2 f)) diff --git a/src/Control/Monad.purs b/src/Control/Monad.purs index 1b1d90c..a9b58e8 100644 --- a/src/Control/Monad.purs +++ b/src/Control/Monad.purs @@ -1,8 +1,8 @@ --- | This module defines helper functions for working with `Monad` instances +-- | This module defines helper functions for working with `Monad` instances. module Control.Monad where --- | Perform a monadic action `n` times collecting all of the results +-- | Perform a monadic action `n` times collecting all of the results. replicateM :: forall m a. (Monad m) => Number -> m a -> m [a] replicateM 0 _ = return [] replicateM n m = do @@ -10,7 +10,7 @@ replicateM n m = do as <- replicateM (n - 1) m return (a : as) --- | Perform a fold using a monadic step function +-- | Perform a fold using a monadic step function. foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> [b] -> m a foldM _ a [] = return a foldM f a (b:bs) = f a b >>= \a' -> foldM f a' bs diff --git a/src/Control/Plus.purs b/src/Control/Plus.purs index 21c6645..ac31857 100644 --- a/src/Control/Plus.purs +++ b/src/Control/Plus.purs @@ -6,6 +6,7 @@ import Control.Alt -- | The `Plus` type class extends the `Alt` type class with a value that -- | should be the left and right identity for `(<|>)`. +-- | -- | It is similar to `Monoid`, except that it applies to types of -- | kind `* -> *`, like `Array` or `List`, rather than concrete types like -- | `String` or `Number`.