Skip to content

Commit 9ccd7db

Browse files
authored
Merge pull request #6 from garyb/0.10-updates
Update dependencies
2 parents cb60f2a + 2d5b8a0 commit 9ccd7db

File tree

3 files changed

+76
-81
lines changed

3 files changed

+76
-81
lines changed

bower.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"url": "git://github.com/ethul/purescript-freeap.git"
1111
},
1212
"dependencies": {
13-
"purescript-exists": "^1.0.0",
14-
"purescript-const": "^1.0.0"
13+
"purescript-exists": "^2.0.0",
14+
"purescript-const": "^2.0.0"
1515
},
1616
"devDependencies": {
17-
"purescript-either": "^1.0.0",
18-
"purescript-integers": "^1.0.0",
19-
"purescript-generics": "^1.0.0",
20-
"purescript-console": "^1.0.0",
21-
"purescript-exceptions": "~1.0.0"
17+
"purescript-either": "^2.0.0",
18+
"purescript-integers": "^2.0.0",
19+
"purescript-generics": "^3.1.0",
20+
"purescript-console": "^2.0.0",
21+
"purescript-exceptions": "^2.0.0"
2222
}
2323
}

docs/Control/Applicative/Free.md

Lines changed: 62 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,62 @@
1-
## Module Control.Applicative.Free
2-
3-
#### `FreeAp`
4-
5-
``` purescript
6-
data FreeAp f a
7-
```
8-
9-
The free applicative functor for a type constructor `f`.
10-
11-
##### Instances
12-
``` purescript
13-
Functor (FreeAp f)
14-
Apply (FreeAp f)
15-
Applicative (FreeAp f)
16-
```
17-
18-
#### `NaturalTransformation`
19-
20-
``` purescript
21-
type NaturalTransformation f g = forall a. f a -> g a
22-
```
23-
24-
#### `liftFreeAp`
25-
26-
``` purescript
27-
liftFreeAp :: forall f a. f a -> FreeAp f a
28-
```
29-
30-
Lift a value described by the type constructor `f` into
31-
the free applicative functor.
32-
33-
#### `retractFreeAp`
34-
35-
``` purescript
36-
retractFreeAp :: forall f a. (Applicative f) => FreeAp f a -> f a
37-
```
38-
39-
Run a free applicative functor using the applicative instance for
40-
the type constructor `f`.
41-
42-
#### `foldFreeAp`
43-
44-
``` purescript
45-
foldFreeAp :: forall f g a. (Applicative g) => NaturalTransformation f g -> FreeAp f a -> g a
46-
```
47-
48-
Run a free applicative functor with a natural transformation from
49-
the type constructor `f` to the applicative functor `g`.
50-
51-
#### `hoistFreeAp`
52-
53-
``` purescript
54-
hoistFreeAp :: forall f g a. NaturalTransformation f g -> FreeAp f a -> FreeAp g a
55-
```
56-
57-
Natural transformation from `FreeAp f a` to `FreeAp g a` given a
58-
natural transformation from `f` to `g`.
59-
60-
#### `analyzeFreeAp`
61-
62-
``` purescript
63-
analyzeFreeAp :: forall f m a. (Monoid m) => (forall b. f b -> m) -> FreeAp f a -> m
64-
```
65-
66-
Perform monoidal analysis over the free applicative functor `f`.
67-
68-
1+
## Module Control.Applicative.Free
2+
3+
#### `FreeAp`
4+
5+
``` purescript
6+
data FreeAp f a
7+
```
8+
9+
The free applicative functor for a type constructor `f`.
10+
11+
##### Instances
12+
``` purescript
13+
Functor (FreeAp f)
14+
Apply (FreeAp f)
15+
Applicative (FreeAp f)
16+
```
17+
18+
#### `liftFreeAp`
19+
20+
``` purescript
21+
liftFreeAp :: forall f a. f a -> FreeAp f a
22+
```
23+
24+
Lift a value described by the type constructor `f` into
25+
the free applicative functor.
26+
27+
#### `retractFreeAp`
28+
29+
``` purescript
30+
retractFreeAp :: forall f a. Applicative f => FreeAp f a -> f a
31+
```
32+
33+
Run a free applicative functor using the applicative instance for
34+
the type constructor `f`.
35+
36+
#### `foldFreeAp`
37+
38+
``` purescript
39+
foldFreeAp :: forall f g a. Applicative g => (f ~> g) -> FreeAp f a -> g a
40+
```
41+
42+
Run a free applicative functor with a natural transformation from
43+
the type constructor `f` to the applicative functor `g`.
44+
45+
#### `hoistFreeAp`
46+
47+
``` purescript
48+
hoistFreeAp :: forall f g a. (f ~> g) -> FreeAp f a -> FreeAp g a
49+
```
50+
51+
Natural transformation from `FreeAp f a` to `FreeAp g a` given a
52+
natural transformation from `f` to `g`.
53+
54+
#### `analyzeFreeAp`
55+
56+
``` purescript
57+
analyzeFreeAp :: forall f m a. Monoid m => (forall b. f b -> m) -> FreeAp f a -> m
58+
```
59+
60+
Perform monoidal analysis over the free applicative functor `f`.
61+
62+

src/Control/Applicative/Free.purs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ module Control.Applicative.Free
77
, analyzeFreeAp
88
) where
99

10-
import Prelude (class Applicative, class Apply, class Functor, type (~>), Unit, (<<<), apply, flip, id, map, pure, unit)
10+
import Prelude hiding (ap)
1111

12-
import Data.Const (Const(Const), getConst)
12+
import Data.Const (Const(..))
1313
import Data.Exists (Exists, mkExists, runExists)
1414
import Data.Monoid (class Monoid)
15+
import Data.Newtype (unwrap)
1516

1617
-- | The free applicative functor for a type constructor `f`.
1718
data FreeAp f a = Pure a | Ap (Exists (ApF f a))
@@ -28,13 +29,13 @@ liftFreeAp a = ap (\_ -> a) (\_ -> Pure id)
2829

2930
-- | Run a free applicative functor using the applicative instance for
3031
-- | the type constructor `f`.
31-
retractFreeAp :: forall f a. (Applicative f) => FreeAp f a -> f a
32+
retractFreeAp :: forall f a. Applicative f => FreeAp f a -> f a
3233
retractFreeAp (Pure a) = pure a
3334
retractFreeAp (Ap x) = runExists (\(ApF v k') -> apply (retractFreeAp (k' unit)) (v unit)) x
3435

3536
-- | Run a free applicative functor with a natural transformation from
3637
-- | the type constructor `f` to the applicative functor `g`.
37-
foldFreeAp :: forall f g a. (Applicative g) => (f ~> g) -> FreeAp f a -> g a
38+
foldFreeAp :: forall f g a. Applicative g => (f ~> g) -> FreeAp f a -> g a
3839
foldFreeAp k (Pure a) = pure a
3940
foldFreeAp k (Ap x) = runExists (\(ApF v k') -> apply (map (flip id) (k (v unit))) (foldFreeAp k (k' unit))) x
4041

@@ -45,8 +46,8 @@ hoistFreeAp k (Pure a) = Pure a
4546
hoistFreeAp k (Ap x) = runExists (\(ApF v k') -> ap (\_ -> k (v unit)) (\_ -> hoistFreeAp k (k' unit))) x
4647

4748
-- | Perform monoidal analysis over the free applicative functor `f`.
48-
analyzeFreeAp :: forall f m a. (Monoid m) => (forall b. f b -> m) -> FreeAp f a -> m
49-
analyzeFreeAp k = getConst <<< foldFreeAp (Const <<< k)
49+
analyzeFreeAp :: forall f m a. Monoid m => (forall b. f b -> m) -> FreeAp f a -> m
50+
analyzeFreeAp k = unwrap <<< foldFreeAp (Const <<< k)
5051

5152
instance functorFreeAp :: Functor (FreeAp f) where
5253
map k (Pure a) = Pure (k a)

0 commit comments

Comments
 (0)