Skip to content

Commit a473ced

Browse files
committed
Docs
1 parent 90fad11 commit a473ced

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

readme.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ const loaded =
2525
const loading =
2626
Loaded.N(55)
2727

28-
const render = Loaded.def( x =>
28+
const render = Loaded.def( loaded =>
2929
Loaded.bifold(
30-
x
31-
, x => `Loading: ${x}%`
32-
, x => `Loaded: ${x}`
30+
loaded
31+
, y => `Loading: ${y}%`
32+
, n => `Loaded: ${n}`
3333
))
3434

35-
const transform = Loaded.def( x =>
35+
const transform = Loaded.def( loaded =>
3636
Loaded.mapY(
37-
x, x => x.toUpperCase()
37+
loaded, x => x.toUpperCase()
3838
))
3939

4040
assert.deepEqual(Loaded.mapN( loading, x => x+'%' ), {...Loaded.N(55), value: '55%' })
@@ -128,8 +128,8 @@ const data = Data.Modified(x)
128128
When we want to transform the value of data we can use any number of useful helpers. Like `map[Tag]`, `flatMap[Tag]`, `get[Tag]` or where `[Tag]` is any one of your tag names. E.g. `mapLoading`.
129129

130130
```typescript
131-
const f = (x: S.Instance<typeof Data>) => Data.mapLoading(
132-
x,
131+
const f = (loading: S.Instance<typeof Data>) => Data.mapLoading(
132+
loading,
133133
x => x * 2
134134
)
135135

@@ -154,8 +154,8 @@ const NoData = Data.otherwise(['Selected', 'Loading'])
154154
const f =
155155
Data.match({
156156
... NoData( () => 'Nothing' )
157-
, Saved: x => 'Saved: ' + x.id
158-
, Modified: x => 'Modified: ' + x.id
157+
, Saved: saved => 'Saved: ' + saved.id
158+
, Modified: modified => 'Modified: ' + modified.id
159159
})
160160

161161
f( Data.Loading() )
@@ -316,7 +316,7 @@ We can then spread that structure into a call to `.match` and typescript will kn
316316
```typescript
317317
const getTitle = Resource.match(instance, {
318318
...NotLoaded(() => null),
319-
Loaded: x => x.title
319+
Loaded: loaded => loaded.title
320320
})
321321
```
322322

@@ -328,7 +328,7 @@ const _ = Resource.otherwise()
328328

329329
const getTitle = Resource.match(instance, {
330330
..._(() => null),
331-
Loaded: x => x.title
331+
Loaded: loaded => loaded.title
332332
})
333333
```
334334

@@ -383,7 +383,7 @@ instance.tag === 'Loaded' ? instance.value.title : 'No Title'
383383
```
384384

385385
```typescript
386-
Resource.getLoaded(instance, 'No Title', x => x.title)
386+
Resource.getLoaded(instance, 'No Title', loaded => loaded.title)
387387
```
388388

389389
### `type.def`
@@ -393,21 +393,21 @@ Useful for defining a reusable function that accepts an instance of your type as
393393
The following two examples are equivalent
394394

395395
```typescript
396-
const render = (x: T.Instance<typeof Loaded> ) =>
396+
const render = (loaded: T.Instance<typeof Loaded> ) =>
397397
Loaded.bifold(
398-
x
399-
, x => `Loading: ${x}%`
400-
, x => `Loaded: ${x}`
398+
loaded
399+
, y => `Loading: ${y}%`
400+
, n => `Loaded: ${n}`
401401
)
402402

403403
```
404404

405405
```typescript
406-
const render = Loaded.def( x =>
406+
const render = Loaded.def( loaded =>
407407
Loaded.bifold(
408-
x
409-
, x => `Loading: ${x}%`
410-
, x => `Loaded: ${x}`
408+
loaded
409+
, y => `Loading: ${y}%`
410+
, n => `Loaded: ${n}`
411411
))
412412
```
413413

@@ -419,10 +419,10 @@ const render = Loaded.def( x =>
419419
const loaded = Resource.Loaded({ id: '1', title: 'cool' })
420420
const loading = Resource.Loading(55)
421421

422-
Resource.mapLoaded(loaded, x => x.title)
422+
Resource.mapLoaded(loaded, loaded => loaded.title)
423423
// => { type: 'Resource', tag: 'Loaded', value: 'cool'
424424

425-
Resource.mapLoaded(loading, x => x.title)
425+
Resource.mapLoaded(loading, loaded => loaded.title)
426426
// => { type: 'Resource', tag: 'Loaded', value: { id: '1', title: 'cool' } }
427427
```
428428

0 commit comments

Comments
 (0)