Skip to content

Commit

Permalink
Polish: add Array.empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Sep 24, 2018
1 parent 61f301f commit cbbbe2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions docs/Array.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ title: Module Array

## Constants

### empty

_constant_

_since 1.9.0_

_Signature_

```ts
empty: Array<never>
```

_Description_

An empty array

### getSetoid

_constant_
Expand Down
12 changes: 10 additions & 2 deletions src/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type URI = typeof URI
export const getMonoid = <A = never>(): Monoid<Array<A>> => {
return {
concat,
empty: []
empty
}
}

Expand Down Expand Up @@ -160,7 +160,15 @@ export function traverse<F>(F: Applicative<F>): <A, B>(ta: Array<A>, f: (a: A) =
return (ta, f) => reduce(ta, F.of(zero()), (fab, a) => liftedSnoc(fab)(f(a)))
}

const zero = <A>(): Array<A> => []
/**
* An empty array
*
* @constant
* @since 1.9.0
*/
export const empty: Array<never> = []

const zero = <A>(): Array<A> => empty

const alt = concat

Expand Down

0 comments on commit cbbbe2f

Please sign in to comment.