Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/modules/Reader.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ Changes the value of the local context during the execution of the action `ma` (
**Signature**

```ts
export declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: Reader<R1, A>) => Reader<R2, A>
export declare const local: <R1, R2 = R1>(f: (r2: R2) => R1) => <A>(ma: Reader<R1, A>) => Reader<R2, A>
```

Added in v3.0.0
Expand Down
4 changes: 3 additions & 1 deletion docs/modules/ReaderEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ Changes the value of the local context during the execution of the action `ma` (
**Signature**

```ts
export declare const local: <R2, R1>(f: (r2: R2) => R1) => <E, A>(ma: ReaderEither<R1, E, A>) => ReaderEither<R2, E, A>
export declare const local: <R1, R2 = R1>(
f: (r2: R2) => R1
) => <E, A>(ma: ReaderEither<R1, E, A>) => ReaderEither<R2, E, A>
```

Added in v3.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ReaderIO.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ Changes the value of the local context during the execution of the action `ma` (
**Signature**

```ts
export declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderIO<R1, A>) => ReaderIO<R2, A>
export declare const local: <R1, R2 = R1>(f: (r2: R2) => R1) => <A>(ma: ReaderIO<R1, A>) => ReaderIO<R2, A>
```

Added in v3.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ReaderTask.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ Changes the value of the local context during the execution of the action `ma` (
**Signature**

```ts
export declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderTask<R1, A>) => ReaderTask<R2, A>
export declare const local: <R1, R2 = R1>(f: (r2: R2) => R1) => <A>(ma: ReaderTask<R1, A>) => ReaderTask<R2, A>
```

Added in v3.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ReaderTaskEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ Changes the value of the local context during the execution of the action `ma` (
**Signature**

```ts
export declare const local: <R2, R1>(
export declare const local: <R1, R2 = R1>(
f: (r2: R2) => R1
) => <E, A>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R2, E, A>
```
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/StateReaderTaskEither.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ Changes the value of the local context during the execution of the action `ma` (
**Signature**

```ts
export declare const local: <R2, R1>(
export declare const local: <R1, R2 = R1>(
f: (r2: R2) => R1
) => <S, E, A>(ma: StateReaderTaskEither<S, R1, E, A>) => StateReaderTaskEither<S, R2, E, A>
```
Expand Down
34 changes: 34 additions & 0 deletions dtslint/ts4.1/Reader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
import * as _ from '../../src/Reader'
import { pipe } from '../../src/function'

declare function modifyA<R extends { a: string }>(r: R): R

//
// local
//

// $ExpectType Reader<{ a: string; }, string>
pipe(
_.of<string, { a: string }>('a'),
_.local((env) => ({
a: env.a
}))
)

// $ExpectType Reader<{ b: string; }, string>
pipe(
_.of<string, { a: string }>('a'),
_.local((env: { b: string }) => ({
a: env.b
}))
)

// $ExpectType Reader<{ b: string; }, string>
pipe(
_.of<string, { a: string; b: string }>('a'),
_.local((env: { b: string }) => ({
...env,
a: env.b
}))
)

// $ExpectType Reader<{ a: string; b: string; }, string>
pipe(_.of<string, { a: string; b: string }>('a'), _.local(modifyA))

//
// chainW
//
Expand Down
34 changes: 34 additions & 0 deletions dtslint/ts4.1/ReaderEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@ import * as R from '../../src/Reader'
import * as E from '../../src/Either'
import { pipe } from '../../src/function'

declare function modifyA<R extends { a: string }>(r: R): R

//
// local
//

// $ExpectType ReaderEither<{ a: string; }, number, string>
pipe(
_.of<string, { a: string }, number>('a'),
_.local((env) => ({
a: env.a
}))
)

// $ExpectType ReaderEither<{ b: string; }, number, string>
pipe(
_.of<string, { a: string }, number>('a'),
_.local((env: { b: string }) => ({
a: env.b
}))
)

// $ExpectType ReaderEither<{ b: string; }, number, string>
pipe(
_.of<string, { a: string; b: string }, number>('a'),
_.local((env: { b: string }) => ({
...env,
a: env.b
}))
)

// $ExpectType ReaderEither<{ a: string; b: string; }, number, string>
pipe(_.of<string, { a: string; b: string }, number>('a'), _.local(modifyA))

//
// getOrElseW
//
Expand Down
36 changes: 36 additions & 0 deletions dtslint/ts4.1/ReaderIO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as _ from '../../src/ReaderIO'
import { pipe } from '../../src/function'

declare function modifyA<R extends { a: string }>(r: R): R

//
// local
//

// $ExpectType ReaderIO<{ a: string; }, string>
pipe(
_.of<string, { a: string }>('a'),
_.local((env) => ({
a: env.a
}))
)

// $ExpectType ReaderIO<{ b: string; }, string>
pipe(
_.of<string, { a: string }>('a'),
_.local((env: { b: string }) => ({
a: env.b
}))
)

// $ExpectType ReaderIO<{ b: string; }, string>
pipe(
_.of<string, { a: string; b: string }>('a'),
_.local((env: { b: string }) => ({
...env,
a: env.b
}))
)

// $ExpectType ReaderIO<{ a: string; b: string; }, string>
pipe(_.of<string, { a: string; b: string }>('a'), _.local(modifyA))
34 changes: 34 additions & 0 deletions dtslint/ts4.1/ReaderTask.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
import * as _ from '../../src/ReaderTask'
import { pipe } from '../../src/function'

declare function modifyA<R extends { a: string }>(r: R): R

//
// local
//

// $ExpectType ReaderTask<{ a: string; }, string>
pipe(
_.of<string, { a: string }>('a'),
_.local((env) => ({
a: env.a
}))
)

// $ExpectType ReaderTask<{ b: string; }, string>
pipe(
_.of<string, { a: string }>('a'),
_.local((env: { b: string }) => ({
a: env.b
}))
)

// $ExpectType ReaderTask<{ b: string; }, string>
pipe(
_.of<string, { a: string; b: string }>('a'),
_.local((env: { b: string }) => ({
...env,
a: env.b
}))
)

// $ExpectType ReaderTask<{ a: string; b: string; }, string>
pipe(_.of<string, { a: string; b: string }>('a'), _.local(modifyA))

//
// Do
//
Expand Down
34 changes: 34 additions & 0 deletions dtslint/ts4.1/ReaderTaskEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ import * as TE from '../../src/TaskEither'
import * as IOE from '../../src/IOEither'
import { pipe } from '../../src/function'

declare function modifyA<R extends { a: string }>(r: R): R

//
// local
//

// $ExpectType ReaderTaskEither<{ a: string; }, number, string>
pipe(
_.of<string, { a: string }, number>('a'),
_.local((env) => ({
a: env.a
}))
)

// $ExpectType ReaderTaskEither<{ b: string; }, number, string>
pipe(
_.of<string, { a: string }, number>('a'),
_.local((env: { b: string }) => ({
a: env.b
}))
)

// $ExpectType ReaderTaskEither<{ b: string; }, number, string>
pipe(
_.of<string, { a: string; b: string }, number>('a'),
_.local((env: { b: string }) => ({
...env,
a: env.b
}))
)

// $ExpectType ReaderTaskEither<{ a: string; b: string; }, number, string>
pipe(_.of<string, { a: string; b: string }, number>('a'), _.local(modifyA))

//
// getOrElseW
//
Expand Down
34 changes: 34 additions & 0 deletions dtslint/ts4.1/StateReaderTaskEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ import * as RTE from '../../src/ReaderTaskEither'
import * as IOE from '../../src/IOEither'
import { pipe } from '../../src/function'

declare function modifyA<R extends { a: string }>(r: R): R

//
// local
//

// $ExpectType StateReaderTaskEither<boolean, { a: string; }, number, string>
pipe(
_.of<string, boolean, { a: string }, number>('a'),
_.local((env) => ({
a: env.a
}))
)

// $ExpectType StateReaderTaskEither<boolean, { b: string; }, number, string>
pipe(
_.of<string, boolean, { a: string }, number>('a'),
_.local((env: { b: string }) => ({
a: env.b
}))
)

// $ExpectType StateReaderTaskEither<boolean, { b: string; }, number, string>
pipe(
_.of<string, boolean, { a: string; b: string }, number>('a'),
_.local((env: { b: string }) => ({
...env,
a: env.b
}))
)

// $ExpectType StateReaderTaskEither<boolean, { a: string; b: string; }, number, string>
pipe(_.of<string, boolean, { a: string; b: string }, number>('a'), _.local(modifyA))

//
// chainW
//
Expand Down
2 changes: 1 addition & 1 deletion src/Reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const asksReader: <R, A>(f: (r: R) => Reader<R, A>) => Reader<R, A> = ask
* @category combinators
* @since 3.0.0
*/
export const local = <R2, R1>(f: (r2: R2) => R1) => <A>(ma: Reader<R1, A>): Reader<R2, A> => (r2) => ma(f(r2))
export const local = <R1, R2 = R1>(f: (r2: R2) => R1) => <A>(ma: Reader<R1, A>): Reader<R2, A> => (r2) => ma(f(r2))

/**
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
Expand Down
2 changes: 1 addition & 1 deletion src/ReaderEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export const toUnion: <R, E, A>(fa: ReaderEither<R, E, A>) => Reader<R, E | A> =
* @category combinators
* @since 3.0.0
*/
export const local: <R2, R1>(f: (r2: R2) => R1) => <E, A>(ma: ReaderEither<R1, E, A>) => ReaderEither<R2, E, A> =
export const local: <R1, R2 = R1>(f: (r2: R2) => R1) => <E, A>(ma: ReaderEither<R1, E, A>) => ReaderEither<R2, E, A> =
R.local

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ReaderIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const fromIO: FromIO2<URI>['fromIO'] = /*#__PURE__*/ R.of
* @category combinators
* @since 3.0.0
*/
export const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderIO<R1, A>) => ReaderIO<R2, A> = R.local
export const local: <R1, R2 = R1>(f: (r2: R2) => R1) => <A>(ma: ReaderIO<R1, A>) => ReaderIO<R2, A> = R.local

/**
* Less strict version of [`asksReaderIO`](#asksreaderio).
Expand Down
2 changes: 1 addition & 1 deletion src/ReaderTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const fromIO: FromIO2<URI>['fromIO'] =
* @category combinators
* @since 3.0.0
*/
export const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderTask<R1, A>) => ReaderTask<R2, A> = R.local
export const local: <R1, R2 = R1>(f: (r2: R2) => R1) => <A>(ma: ReaderTask<R1, A>) => ReaderTask<R2, A> = R.local

/**
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
Expand Down
2 changes: 1 addition & 1 deletion src/ReaderTaskEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export const chainNullableK: <E>(
* @category combinators
* @since 3.0.0
*/
export const local: <R2, R1>(
export const local: <R1, R2 = R1>(
f: (r2: R2) => R1
) => <E, A>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R2, E, A> = R.local

Expand Down
2 changes: 1 addition & 1 deletion src/StateReaderTaskEither.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export const fromReaderTaskEither: NaturalTransformation34<RTE.URI, URI> =
* @category combinators
* @since 3.0.0
*/
export const local = <R2, R1>(f: (r2: R2) => R1) => <S, E, A>(
export const local = <R1, R2 = R1>(f: (r2: R2) => R1) => <S, E, A>(
ma: StateReaderTaskEither<S, R1, E, A>
): StateReaderTaskEither<S, R2, E, A> => flow(ma, R.local(f))

Expand Down