Skip to content

Commit 727c29b

Browse files
committed
Merge pull request #1 from garyb/master
Add `thisOrBoth` and `thatOrBoth`
2 parents 573b66b + 764e78d commit 727c29b

File tree

5 files changed

+62
-19
lines changed

5 files changed

+62
-19
lines changed

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
node_modules
2-
bower_components
3-
dist
1+
/.*
2+
!/.gitignore
3+
!/.travis.yml
4+
/bower_components/
5+
/node_modules/
6+
/output/

MODULES.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ these :: forall a b c. (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
9696
```
9797

9898

99+
#### `thisOrBoth`
100+
101+
``` purescript
102+
thisOrBoth :: forall a b. a -> Maybe b -> These a b
103+
```
104+
105+
106+
#### `thatOrBoth`
107+
108+
``` purescript
109+
thatOrBoth :: forall a b. b -> Maybe a -> These a b
110+
```
111+
112+
99113
#### `fromThese`
100114

101115
``` purescript

gulpfile.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
require('mandragora-bucket')(require('gulp'), {
2-
paths: {
3-
bower: [
4-
'bower_components/purescript-*/src/**/*.purs',
5-
'bower_components/purescript-*/purescript-*/src/**/*.purs'
6-
],
7-
src: ['src/**/*.purs'],
8-
test: ['test/**/*.purs'],
9-
docs: {
10-
dest: 'MODULES.md'
11-
}
12-
},
13-
tmpDir: 'dist'
1+
/* jshint node: true */
2+
"use strict";
3+
4+
var gulp = require("gulp");
5+
var plumber = require("gulp-plumber");
6+
var purescript = require("gulp-purescript");
7+
8+
var sources = [
9+
"src/**/*.purs",
10+
"bower_components/purescript-*/src/**/*.purs"
11+
];
12+
13+
gulp.task("make", function() {
14+
return gulp.src(sources)
15+
.pipe(plumber())
16+
.pipe(purescript.pscMake());
1417
});
18+
19+
gulp.task("docs", function () {
20+
return gulp.src(["src/**/*.purs"])
21+
.pipe(plumber())
22+
.pipe(purescript.pscDocs())
23+
.pipe(gulp.dest("MODULES.md"));
24+
});
25+
26+
gulp.task("dotpsci", function () {
27+
return gulp.src(sources)
28+
.pipe(plumber())
29+
.pipe(purescript.dotPsci());
30+
});
31+
32+
gulp.task("default", ["make", "docs"]);

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"private": true,
33
"devDependencies": {
4-
"gulp": "~3.8.1",
5-
"bower": "~1.4.1",
6-
"mandragora-bucket": "~0.2.1"
4+
"gulp": "^3.8.11",
5+
"gulp-plumber": "^1.0.0",
6+
"gulp-purescript": "^0.4.2"
77
}
88
}

src/Data/These.purs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ these l _ _ (This a) = l a
8585
these _ r _ (That x) = r x
8686
these _ _ lr (Both a x) = lr a x
8787

88+
thisOrBoth :: forall a b. a -> Maybe b -> These a b
89+
thisOrBoth a Nothing = This a
90+
thisOrBoth a (Just b) = Both a b
91+
92+
thatOrBoth :: forall a b. b -> Maybe a -> These a b
93+
thatOrBoth b Nothing = That b
94+
thatOrBoth b (Just a) = Both a b
95+
8896
fromThese :: forall a b. a -> b -> These a b -> Tuple a b
8997
fromThese _ x (This a) = Tuple a x
9098
fromThese a _ (That x) = Tuple a x

0 commit comments

Comments
 (0)