|
1 | 1 | module Control.Apply where |
2 | 2 |
|
3 | | - -- This should currently replace everything in Control.Applicative. |
4 | | - -- Ideally it would be its superclass. |
| 3 | + infixl 4 <* |
| 4 | + infixl 4 *> |
5 | 5 |
|
6 | | - infixl 4 <. |
7 | | - infixl 4 .> |
| 6 | + (<*) :: forall a b f. (Apply f) => f a -> f b -> f a |
| 7 | + (<*) a b = const <$> a <*> b |
8 | 8 |
|
9 | | - -- This should be a subclass of Functor. |
10 | | - class Apply f where |
11 | | - -- Until we get default implementations, use `<.>` as `<*>` |
12 | | - (<.>) :: forall a b. (Functor f) => f (a -> b) -> f a -> f b |
| 9 | + (*>) :: forall a b f. (Apply f) => f a -> f b -> f b |
| 10 | + (*>) a b = const id <$> a <*> b |
13 | 11 |
|
14 | | - (<.) :: forall a b f. (Apply f, Functor f) => f a -> f b -> f a |
15 | | - (<.) a b = const <$> a <.> b |
| 12 | + lift2 :: forall a b c f. (Apply f) => (a -> b -> c) -> f a -> f b -> f c |
| 13 | + lift2 f a b = f <$> a <*> b |
16 | 14 |
|
17 | | - (.>) :: forall a b f. (Apply f, Functor f) => f a -> f b -> f b |
18 | | - (.>) a b = const id <$> a <.> b |
| 15 | + lift3 :: forall a b c d f. (Apply f) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d |
| 16 | + lift3 f a b c = f <$> a <*> b <*> c |
19 | 17 |
|
20 | | - lift2 :: forall a b c f. (Apply f, Functor f) => (a -> b -> c) -> f a -> f b -> f c |
21 | | - lift2 f a b = f <$> a <.> b |
| 18 | + 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 | + lift4 f a b c d = f <$> a <*> b <*> c <*> d |
22 | 20 |
|
23 | | - lift3 :: forall a b c d f. (Apply f, Functor f) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d |
24 | | - lift3 f a b c = f <$> a <.> b <.> c |
| 21 | + 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 | + 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