Skip to content

Commit

Permalink
Docs: add Semigroup examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Sep 24, 2020
1 parent 6a3c7cb commit 231c2d0
Show file tree
Hide file tree
Showing 7 changed files with 390 additions and 85 deletions.
48 changes: 23 additions & 25 deletions code2comment.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>code 2 comment</title>
</head>

<head>
<meta charset="UTF-8" />
<title>code 2 comment</title>
</head>

<body>
<div id="app">
<textarea id="code" cols="100" rows="20"></textarea>
<textarea id="comment" cols="100" rows="20"></textarea>
<button id="transform">transform</button>
</div>
<script>
const transform = document.getElementById('transform')
const code = document.getElementById('code')
const comment = document.getElementById('comment')
transform.onclick = () => {
comment.value = t(code.value)
}
function t(src) {
const lines = src.split('\n').map(line => '* ' + line.replace('../src/', 'fp-ts/lib/'))
return '*\n* @example\n' + lines.join('\n') + '\n'
}
</script>
</body>

<body>
<div id="app">
<textarea id="code" cols="100" rows="20"></textarea>
<textarea id="comment" cols="100" rows="20"></textarea>
<button id="transform">transform</button>
</div>
<script>
const transform = document.getElementById('transform')
const code = document.getElementById('code')
const comment = document.getElementById('comment')
transform.onclick = () => {
comment.value = t(code.value)
}
function t(src) {
const lines = src.split('\n').map((line) => '* ' + line.replace('../src/', 'fp-ts/'))
return '*\n* @example\n' + lines.join('\n') + '\n'
}
</script>
</body>
</html>
4 changes: 2 additions & 2 deletions docs/modules/Array.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ Break an array into its first element and remaining elements
**Signature**

```ts
export declare const foldLeft: <A, B>(onNil: Lazy<B>, onCons: (head: A, tail: A[]) => B) => (as: A[]) => B
export declare const foldLeft: <A, B>(onEmpty: Lazy<B>, onCons: (head: A, tail: A[]) => B) => (as: A[]) => B
```

**Example**
Expand All @@ -1317,7 +1317,7 @@ Break an array into its initial elements and the last element
**Signature**

```ts
export declare const foldRight: <A, B>(onNil: Lazy<B>, onCons: (init: A[], last: A) => B) => (as: A[]) => B
export declare const foldRight: <A, B>(onEmpty: Lazy<B>, onCons: (init: A[], last: A) => B) => (as: A[]) => B
```

Added in v2.0.0
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ReadonlyArray.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ Break an array into its first element and remaining elements

```ts
export declare function foldLeft<A, B>(
onNil: Lazy<B>,
onEmpty: Lazy<B>,
onCons: (head: A, tail: ReadonlyArray<A>) => B
): (as: ReadonlyArray<A>) => B
```
Expand All @@ -1199,7 +1199,7 @@ Break an array into its initial elements and the last element

```ts
export declare function foldRight<A, B>(
onNil: Lazy<B>,
onEmpty: Lazy<B>,
onCons: (init: ReadonlyArray<A>, last: A) => B
): (as: ReadonlyArray<A>) => B
```
Expand Down
Loading

0 comments on commit 231c2d0

Please sign in to comment.