|
| 1 | +-- | This module defines helper functions for working with `Apply` instances. |
| 2 | + |
1 | 3 | module Control.Apply where
|
2 | 4 |
|
3 | 5 | infixl 4 <*
|
4 | 6 | infixl 4 *>
|
5 | 7 |
|
| 8 | + -- | Combine two effectful actions, keeping only the result of the first. |
6 | 9 | (<*) :: forall a b f. (Apply f) => f a -> f b -> f a
|
7 | 10 | (<*) a b = const <$> a <*> b
|
8 | 11 |
|
| 12 | + -- | Combine two effectful actions, keeping only the result of the second. |
9 | 13 | (*>) :: forall a b f. (Apply f) => f a -> f b -> f b
|
10 | 14 | (*>) a b = const id <$> a <*> b
|
11 | 15 |
|
| 16 | + -- | Lift a function of two arguments to a function which accepts and returns |
| 17 | + -- | values wrapped with the type constructor `f`. |
12 | 18 | lift2 :: forall a b c f. (Apply f) => (a -> b -> c) -> f a -> f b -> f c
|
13 | 19 | lift2 f a b = f <$> a <*> b
|
14 | 20 |
|
| 21 | + -- | Lift a function of three arguments to a function which accepts and returns |
| 22 | + -- | values wrapped with the type constructor `f`. |
15 | 23 | lift3 :: forall a b c d f. (Apply f) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
|
16 | 24 | lift3 f a b c = f <$> a <*> b <*> c
|
17 | 25 |
|
| 26 | + -- | Lift a function of four arguments to a function which accepts and returns |
| 27 | + -- | values wrapped with the type constructor `f`. |
18 | 28 | lift4 :: forall a b c d e f. (Apply f) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
|
19 | 29 | lift4 f a b c d = f <$> a <*> b <*> c <*> d
|
20 | 30 |
|
| 31 | + -- | Lift a function of five arguments to a function which accepts and returns |
| 32 | + -- | values wrapped with the type constructor `f`. |
21 | 33 | lift5 :: forall a b c d e f g. (Apply f) => (a -> b -> c -> d -> e -> g) -> f a -> f b -> f c -> f d -> f e -> f g
|
22 | 34 | lift5 f a b c d e = f <$> a <*> b <*> c <*> d <*> e
|
23 |
| - |
24 |
| - forever :: forall a b f. (Apply f) => f a -> f b |
25 |
| - forever a = a *> forever a |
|
0 commit comments