Skip to content

Commit

Permalink
Consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
paf31 committed Mar 22, 2015
1 parent 78c1d02 commit f7e6cb5
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 42 deletions.
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Module Control.Alt


This module defines the `Alt` type class
This module defines the `Alt` type class.

#### `Alt`

Expand Down Expand Up @@ -140,15 +140,15 @@ 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.

#### `(>=>)`

``` purescript
(>=>) :: forall a b c m. (Bind m) => (a -> m b) -> (b -> m c) -> a -> m c
```

Forwards Kleisli composition
Forwards Kleisli composition.

For example:

Expand All @@ -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`

Expand Down Expand Up @@ -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`

Expand All @@ -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`

Expand Down Expand Up @@ -251,55 +251,55 @@ 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.

#### `(=>=)`

``` purescript
(=>=) :: forall b a w c. (Extend w) => (w a -> b) -> (w b -> c) -> w a -> c
```

Forwards co-Kleisli composition
Forwards co-Kleisli composition.

#### `(=<=)`

``` purescript
(=<=) :: 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`

``` purescript
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.

#### `(<$)`

``` purescript
(<$) :: 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.

#### `($>)`

``` purescript
($>) :: 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
Expand Down Expand Up @@ -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`

Expand All @@ -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`

Expand All @@ -355,37 +355,37 @@ 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`

``` purescript
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`

``` purescript
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`

``` purescript
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`

Expand Down Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion src/Control/Alt.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- | This module defines the `Alt` type class
-- | This module defines the `Alt` type class.

module Control.Alt where

Expand Down
6 changes: 3 additions & 3 deletions src/Control/Bind.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
-- |
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/Control/Comonad.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- | This module defines the `Comonad` type class
-- | This module defines the `Comonad` type class.

module Control.Comonad where

Expand Down
12 changes: 6 additions & 6 deletions src/Control/Extend.purs
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
6 changes: 3 additions & 3 deletions src/Control/Functor.purs
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions src/Control/Lazy.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
6 changes: 3 additions & 3 deletions src/Control/Monad.purs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
-- | 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
a <- m
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
Expand Down
1 change: 1 addition & 0 deletions src/Control/Plus.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit f7e6cb5

Please sign in to comment.