Skip to content

Commit

Permalink
remove last instance references (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Sep 30, 2022
1 parent 08b8ebf commit 435fe15
Show file tree
Hide file tree
Showing 28 changed files with 639 additions and 717 deletions.
30 changes: 15 additions & 15 deletions docs/modules/Const.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ Added in v2.0.0

<h2 class="text-delta">Table of contents</h2>

- [Contravariant](#contravariant)
- [contramap](#contramap)
- [constructors](#constructors)
- [make](#make)
- [error handling](#error-handling)
- [mapLeft](#mapleft)
- [instances](#instances)
- [Bifunctor](#bifunctor)
- [Contravariant](#contravariant-1)
- [Contravariant](#contravariant)
- [Functor](#functor)
- [getApplicative](#getapplicative)
- [getApply](#getapply)
Expand All @@ -49,23 +47,13 @@ Added in v2.0.0
- [type lambdas](#type-lambdas)
- [URI](#uri)
- [URI (type alias)](#uri-type-alias)
- [utils](#utils)
- [contramap](#contramap)
- [zone of death](#zone-of-death)
- [~~const\_~~](#const_)

---

# Contravariant

## contramap

**Signature**

```ts
export declare const contramap: <A, B>(f: (b: B) => A) => <E>(fa: Const<E, A>) => Const<E, B>
```
Added in v2.0.0
# constructors

## make
Expand Down Expand Up @@ -315,6 +303,18 @@ export type URI = typeof URI

Added in v2.0.0

# utils

## contramap

**Signature**

```ts
export declare const contramap: <A, B>(f: (b: B) => A) => <E>(fa: Const<E, A>) => Const<E, B>
```

Added in v2.0.0

# zone of death

## ~~const\_~~
Expand Down
113 changes: 55 additions & 58 deletions docs/modules/Eq.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ Added in v2.0.0

<h2 class="text-delta">Table of contents</h2>

- [Contravariant](#contravariant)
- [contramap](#contramap)
- [constructors](#constructors)
- [fromEquals](#fromequals)
- [instances](#instances)
- [Contravariant](#contravariant-1)
- [Contravariant](#contravariant)
- [eqStrict](#eqstrict)
- [getMonoid](#getmonoid)
- [getSemigroup](#getsemigroup)
Expand All @@ -35,6 +33,7 @@ Added in v2.0.0
- [URI](#uri)
- [URI (type alias)](#uri-type-alias)
- [utils](#utils)
- [contramap](#contramap)
- [struct](#struct)
- [tuple](#tuple)
- [zone of death](#zone-of-death)
Expand All @@ -49,61 +48,6 @@ Added in v2.0.0

---

# Contravariant

## contramap

A typical use case for `contramap` would be like, given some `User` type, to construct an `Eq<User>`.

We can do so with a function from `User -> X` where `X` is some value that we know how to compare
for equality (meaning we have an `Eq<X>`)

For example, given the following `User` type, we want to construct an `Eq<User>` that just looks at the `key` field
for each user (since it's known to be unique).

If we have a way of comparing `UUID`s for equality (`eqUUID: Eq<UUID>`) and we know how to go from `User -> UUID`,
using `contramap` we can do this

**Signature**

```ts
export declare const contramap: <A, B>(f: (b: B) => A) => (fa: Eq<A>) => Eq<B>
```
**Example**
```ts
import { contramap, Eq } from 'fp-ts/Eq'
import { pipe } from 'fp-ts/function'
import * as S from 'fp-ts/string'

type UUID = string

interface User {
readonly key: UUID
readonly firstName: string
readonly lastName: string
}

const eqUUID: Eq<UUID> = S.Eq

const eqUserByKey: Eq<User> = pipe(
eqUUID,
contramap((user) => user.key)
)

assert.deepStrictEqual(
eqUserByKey.equals({ key: 'k1', firstName: 'a1', lastName: 'b1' }, { key: 'k2', firstName: 'a1', lastName: 'b1' }),
false
)
assert.deepStrictEqual(
eqUserByKey.equals({ key: 'k1', firstName: 'a1', lastName: 'b1' }, { key: 'k1', firstName: 'a2', lastName: 'b1' }),
true
)
```

Added in v2.0.0

# constructors

## fromEquals
Expand Down Expand Up @@ -196,6 +140,59 @@ Added in v2.0.0
# utils
## contramap
A typical use case for `contramap` would be like, given some `User` type, to construct an `Eq<User>`.
We can do so with a function from `User -> X` where `X` is some value that we know how to compare
for equality (meaning we have an `Eq<X>`)
For example, given the following `User` type, we want to construct an `Eq<User>` that just looks at the `key` field
for each user (since it's known to be unique).
If we have a way of comparing `UUID`s for equality (`eqUUID: Eq<UUID>`) and we know how to go from `User -> UUID`,
using `contramap` we can do this
**Signature**
```ts
export declare const contramap: <A, B>(f: (b: B) => A) => (fa: Eq<A>) => Eq<B>
```
**Example**
```ts
import { contramap, Eq } from 'fp-ts/Eq'
import { pipe } from 'fp-ts/function'
import * as S from 'fp-ts/string'

type UUID = string

interface User {
readonly key: UUID
readonly firstName: string
readonly lastName: string
}

const eqUUID: Eq<UUID> = S.Eq

const eqUserByKey: Eq<User> = pipe(
eqUUID,
contramap((user) => user.key)
)

assert.deepStrictEqual(
eqUserByKey.equals({ key: 'k1', firstName: 'a1', lastName: 'b1' }, { key: 'k2', firstName: 'a1', lastName: 'b1' }),
false
)
assert.deepStrictEqual(
eqUserByKey.equals({ key: 'k1', firstName: 'a1', lastName: 'b1' }, { key: 'k1', firstName: 'a2', lastName: 'b1' }),
true
)
```

Added in v2.0.0

## struct

**Signature**
Expand Down
86 changes: 40 additions & 46 deletions docs/modules/IOEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ Added in v2.0.0

<h2 class="text-delta">Table of contents</h2>

- [Apply](#apply)
- [apW](#apw)
- [MonadThrow](#monadthrow)
- [throwError](#throwerror)
- [constructors](#constructors)
- [left](#left)
- [leftIO](#leftio)
Expand Down Expand Up @@ -51,6 +47,7 @@ Added in v2.0.0
- [mapLeft](#mapleft)
- [orElse](#orelse)
- [orElseFirst](#orelsefirst)
- [orElseFirstIOK](#orelsefirstiok)
- [orElseFirstW](#orelsefirstw)
- [orElseW](#orelsew)
- [orLeft](#orleft)
Expand All @@ -71,7 +68,7 @@ Added in v2.0.0
- [Functor](#functor)
- [Monad](#monad)
- [MonadIO](#monadio)
- [MonadThrow](#monadthrow-1)
- [MonadThrow](#monadthrow)
- [Pointed](#pointed)
- [interop](#interop)
- [tryCatch](#trycatch)
Expand Down Expand Up @@ -119,12 +116,13 @@ Added in v2.0.0
- [apFirstW](#apfirstw)
- [apSecond](#apsecond)
- [apSecondW](#apsecondw)
- [apW](#apw)
- [bracket](#bracket)
- [bracketW](#bracketw)
- [orElseFirstIOK](#orelsefirstiok)
- [sequenceArray](#sequencearray)
- [sequenceSeqArray](#sequenceseqarray)
- [swap](#swap)
- [throwError](#throwerror)
- [traverseArray](#traversearray)
- [traverseArrayWithIndex](#traversearraywithindex)
- [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)
Expand All @@ -143,36 +141,6 @@ Added in v2.0.0

---

# Apply

## apW

Less strict version of [`ap`](#ap).

The `W` suffix (short for **W**idening) means that the error types will be merged.

**Signature**

```ts
export declare const apW: <E2, A>(
fa: IOEither<E2, A>
) => <E1, B>(fab: IOEither<E1, (a: A) => B>) => IOEither<E2 | E1, B>
```
Added in v2.8.0
# MonadThrow
## throwError
**Signature**
```ts
export declare const throwError: <E, A>(e: E) => IOEither<E, A>
```
Added in v2.7.0
# constructors

## left
Expand Down Expand Up @@ -475,6 +443,16 @@ export declare const orElseFirst: <E, B>(onLeft: (e: E) => IOEither<E, B>) => <A

Added in v2.11.0

## orElseFirstIOK

**Signature**

```ts
export declare const orElseFirstIOK: <E, B>(onLeft: (e: E) => I.IO<B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A>
```

Added in v2.12.0

## orElseFirstW

The `W` suffix (short for **W**idening) means that the error types will be merged.
Expand Down Expand Up @@ -1201,6 +1179,22 @@ export declare const apSecondW: <E2, B>(

Added in v2.12.0

## apW

Less strict version of [`ap`](#ap).

The `W` suffix (short for **W**idening) means that the error types will be merged.

**Signature**

```ts
export declare const apW: <E2, A>(
fa: IOEither<E2, A>
) => <E1, B>(fab: IOEither<E1, (a: A) => B>) => IOEither<E2 | E1, B>
```

Added in v2.8.0

## bracket

Make sure that a resource is cleaned up in the event of an exception (\*). The release action is called regardless of
Expand Down Expand Up @@ -1238,16 +1232,6 @@ export declare const bracketW: <E1, A, E2, B, E3>(

Added in v2.12.0

## orElseFirstIOK

**Signature**

```ts
export declare const orElseFirstIOK: <E, B>(onLeft: (e: E) => I.IO<B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A>
```

Added in v2.12.0

## sequenceArray

**Signature**
Expand Down Expand Up @@ -1278,6 +1262,16 @@ export declare const swap: <E, A>(ma: IOEither<E, A>) => IOEither<A, E>

Added in v2.0.0

## throwError

**Signature**

```ts
export declare const throwError: <E, A>(e: E) => IOEither<E, A>
```

Added in v2.7.0

## traverseArray

**Signature**
Expand Down
Loading

0 comments on commit 435fe15

Please sign in to comment.