Skip to content

Commit 0c56250

Browse files
committed
Merge branch 'master' of github.com:purescript/purescript-control
Conflicts: README.md
2 parents 7e25f63 + 6fa92ca commit 0c56250

File tree

6 files changed

+121
-3
lines changed

6 files changed

+121
-3
lines changed

README.md

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Module Documentation
22

3+
## Module Control.Alt
4+
5+
### Type Classes
6+
7+
class (Functor f) <= Alt f where
8+
(<|>) :: forall a. f a -> f a -> f a
9+
10+
11+
## Module Control.Alternative
12+
13+
### Type Classes
14+
15+
class (Applicative f, Plus f) <= Alternative f where
16+
17+
18+
### Values
19+
20+
many :: forall f a. (Alternative f, Lazy1 f) => f a -> f [a]
21+
22+
some :: forall f a. (Alternative f, Lazy1 f) => f a -> f [a]
23+
24+
325
## Module Control.Apply
426

527
### Values
@@ -54,8 +76,6 @@
5476

5577
instance extendArr :: (Semigroup w) => Extend (Prim.Function w)
5678

57-
instance extendArray :: Extend Prim.Array
58-
5979

6080
### Values
6181

@@ -68,6 +88,29 @@
6888
duplicate :: forall a w. (Extend w) => w a -> w (w a)
6989

7090

91+
## Module Control.Lazy
92+
93+
### Type Classes
94+
95+
class Lazy l where
96+
defer :: (Unit -> l) -> l
97+
98+
class Lazy1 l where
99+
defer1 :: forall a. (Unit -> l a) -> l a
100+
101+
class Lazy2 l where
102+
defer2 :: forall a b. (Unit -> l a b) -> l a b
103+
104+
105+
### Values
106+
107+
fix :: forall l a. (Lazy l) => (l -> l) -> l
108+
109+
fix1 :: forall l a. (Lazy1 l) => (l a -> l a) -> l a
110+
111+
fix2 :: forall l a b. (Lazy2 l) => (l a b -> l a b) -> l a b
112+
113+
71114
## Module Control.Monad
72115

73116
### Values
@@ -78,4 +121,24 @@
78121

79122
unless :: forall m. (Monad m) => Boolean -> m Unit -> m Unit
80123

81-
when :: forall m. (Monad m) => Boolean -> m Unit -> m Unit
124+
when :: forall m. (Monad m) => Boolean -> m Unit -> m Unit
125+
126+
127+
## Module Control.MonadPlus
128+
129+
### Type Classes
130+
131+
class (Monad m, Alternative m) <= MonadPlus m where
132+
133+
134+
### Values
135+
136+
guard :: forall m. (MonadPlus m) => Boolean -> m Unit
137+
138+
139+
## Module Control.Plus
140+
141+
### Type Classes
142+
143+
class (Alt f) <= Plus f where
144+
empty :: forall a. f a

src/Control/Alt.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Control.Alt where
2+
3+
infixl 3 <|>
4+
5+
class (Functor f) <= Alt f where
6+
(<|>) :: forall a. f a -> f a -> f a

src/Control/Alternative.purs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Control.Alternative where
2+
3+
import Control.Alt
4+
import Control.Lazy
5+
import Control.Plus
6+
7+
class (Applicative f, Plus f) <= Alternative f
8+
9+
some :: forall f a. (Alternative f, Lazy1 f) => f a -> f [a]
10+
some v = (:) <$> v <*> defer1 (\_ -> many v)
11+
12+
many :: forall f a. (Alternative f, Lazy1 f) => f a -> f [a]
13+
many v = some v <|> pure []
14+

src/Control/Lazy.purs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Control.Lazy where
2+
3+
class Lazy l where
4+
defer :: (Unit -> l) -> l
5+
6+
class Lazy1 l where
7+
defer1 :: forall a. (Unit -> l a) -> l a
8+
9+
class Lazy2 l where
10+
defer2 :: forall a b. (Unit -> l a b) -> l a b
11+
12+
fix :: forall l a. (Lazy l) => (l -> l) -> l
13+
fix f = defer (\_ -> f (fix f))
14+
15+
fix1 :: forall l a. (Lazy1 l) => (l a -> l a) -> l a
16+
fix1 f = defer1 (\_ -> f (fix1 f))
17+
18+
fix2 :: forall l a b. (Lazy2 l) => (l a b -> l a b) -> l a b
19+
fix2 f = defer2 (\_ -> f (fix2 f))

src/Control/MonadPlus.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Control.MonadPlus where
2+
3+
import Control.Alternative
4+
import Control.Plus
5+
6+
class (Monad m, Alternative m) <= MonadPlus m
7+
8+
guard :: forall m. (MonadPlus m) => Boolean -> m Unit
9+
guard true = return unit
10+
guard false = empty

src/Control/Plus.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Control.Plus where
2+
3+
import Control.Alt
4+
5+
class (Alt f) <= Plus f where
6+
empty :: forall a. f a

0 commit comments

Comments
 (0)