Skip to content

Commit

Permalink
change Effect type parameters order (#2034)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored and tim-smart committed Feb 9, 2024
1 parent 9a2d1c1 commit 1a77f72
Show file tree
Hide file tree
Showing 326 changed files with 7,154 additions and 7,260 deletions.
21 changes: 21 additions & 0 deletions .changeset/fast-socks-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
"@effect/platform-node-shared": minor
"@effect/platform-browser": minor
"@effect/opentelemetry": minor
"@effect/platform-node": minor
"@effect/rpc-http-node": minor
"@effect/experimental": minor
"@effect/platform-bun": minor
"@effect/printer-ansi": minor
"@effect/rpc-workers": minor
"@effect/rpc-nextjs": minor
"@effect/platform": minor
"@effect/rpc-http": minor
"@effect/printer": minor
"effect": minor
"@effect/schema": minor
"@effect/cli": minor
"@effect/rpc": minor
---

change Effect type parameters order
10 changes: 5 additions & 5 deletions packages/cli/examples/naval-fate/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import { CoordinatesOccupiedError, Mine, Ship, ShipExistsError, ShipNotFoundErro
* Represents the storage layer for the Naval Fate command-line application.
*/
export interface NavalFateStore {
createShip(name: string): Effect.Effect<never, ShipExistsError, Ship>
createShip(name: string): Effect.Effect<Ship, ShipExistsError>
moveShip(
name: string,
x: number,
y: number
): Effect.Effect<never, CoordinatesOccupiedError | ShipNotFoundError, Ship>
shoot(x: number, y: number): Effect.Effect<never, never, void>
setMine(x: number, y: number): Effect.Effect<never, never, void>
removeMine(x: number, y: number): Effect.Effect<never, never, void>
): Effect.Effect<Ship, CoordinatesOccupiedError | ShipNotFoundError>
shoot(x: number, y: number): Effect.Effect<void>
setMine(x: number, y: number): Effect.Effect<void>
removeMine(x: number, y: number): Effect.Effect<void>
}

export const NavalFateStore = Context.GenericTag<NavalFateStore>("NavalFateStore")
Expand Down
30 changes: 24 additions & 6 deletions packages/cli/src/Args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ export const map: {
* @category mapping
*/
export const mapEffect: {
<A, B>(f: (a: A) => Effect<FileSystem | Path | Terminal, HelpDoc, B>): (self: Args<A>) => Args<B>
<A, B>(self: Args<A>, f: (a: A) => Effect<FileSystem | Path | Terminal, HelpDoc, B>): Args<B>
<A, B>(f: (a: A) => Effect<B, HelpDoc, FileSystem | Path | Terminal>): (self: Args<A>) => Args<B>
<A, B>(self: Args<A>, f: (a: A) => Effect<B, HelpDoc, FileSystem | Path | Terminal>): Args<B>
} = InternalArgs.mapEffect

/**
Expand Down Expand Up @@ -404,12 +404,20 @@ export const validate: {
(
args: ReadonlyArray<string>,
config: CliConfig
): <A>(self: Args<A>) => Effect<FileSystem | Path | Terminal, ValidationError, [Array<string>, A]>
): <A>(self: Args<A>) => Effect<
[Array<string>, A],
ValidationError,
FileSystem | Path | Terminal
>
<A>(
self: Args<A>,
args: ReadonlyArray<string>,
config: CliConfig
): Effect<FileSystem | Path | Terminal, ValidationError, [Array<string>, A]>
): Effect<
[Array<string>, A],
ValidationError,
FileSystem | Path | Terminal
>
} = InternalArgs.validate

/**
Expand Down Expand Up @@ -455,9 +463,19 @@ export const withSchema: {
export const wizard: {
(
config: CliConfig
): <A>(self: Args<A>) => Effect<FileSystem | Path | Terminal, ValidationError | QuitException, Array<string>>
): <A>(
self: Args<A>
) => Effect<
Array<string>,
ValidationError | QuitException,
FileSystem | Path | Terminal
>
<A>(
self: Args<A>,
config: CliConfig
): Effect<FileSystem | Path | Terminal, ValidationError | QuitException, Array<string>>
): Effect<
Array<string>,
ValidationError | QuitException,
FileSystem | Path | Terminal
>
} = InternalArgs.wizard
8 changes: 4 additions & 4 deletions packages/cli/src/CliApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ export const make: <A>(config: CliApp.ConstructorArgs<A>) => CliApp<A> = Interna
export const run: {
<R, E, A>(
args: ReadonlyArray<string>,
execute: (a: A) => Effect<R, E, void>
): (self: CliApp<A>) => Effect<CliApp.Environment | R, ValidationError | E, void>
execute: (a: A) => Effect<void, E, R>
): (self: CliApp<A>) => Effect<void | E, CliApp.Environment | R, ValidationError>
<R, E, A>(
self: CliApp<A>,
args: ReadonlyArray<string>,
execute: (a: A) => Effect<R, E, void>
): Effect<CliApp.Environment | R, ValidationError | E, void>
execute: (a: A) => Effect<void, E, R>
): Effect<void | E, CliApp.Environment | R, ValidationError>
} = InternalCliApp.run
48 changes: 24 additions & 24 deletions packages/cli/src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export type TypeId = typeof TypeId
* @since 1.0.0
* @category models
*/
export interface Command<Name extends string, R, E, A> extends Pipeable, Effect<Command.Context<Name>, never, A> {
export interface Command<Name extends string, R, E, A> extends Pipeable, Effect<A, never, Command.Context<Name>> {
readonly [TypeId]: TypeId
readonly descriptor: Descriptor.Command<A>
readonly handler: (_: A) => Effect<R, E, void>
readonly handler: (_: A) => Effect<void, E, R>
readonly tag: Tag<Command.Context<Name>, A>
readonly transform: Command.Transform<R, E, A>
}
Expand Down Expand Up @@ -120,7 +120,7 @@ export declare namespace Command {
* @since 1.0.0
* @category models
*/
export type Transform<R, E, A> = (effect: Effect<any, any, void>, config: A) => Effect<R, E, void>
export type Transform<R, E, A> = (effect: Effect<void, any, any>, config: A) => Effect<void, E, R>
}

/**
Expand All @@ -133,7 +133,7 @@ export const fromDescriptor: {
) => Command<A["name"], never, never, A>

<A extends { readonly name: string }, R, E>(
handler: (_: A) => Effect<R, E, void>
handler: (_: A) => Effect<void, E, R>
): (command: Descriptor.Command<A>) => Command<A["name"], R, E, A>

<A extends { readonly name: string }>(
Expand All @@ -142,7 +142,7 @@ export const fromDescriptor: {

<A extends { readonly name: string }, R, E>(
descriptor: Descriptor.Command<A>,
handler: (_: A) => Effect<R, E, void>
handler: (_: A) => Effect<void, E, R>
): Command<A["name"], R, E, A>
} = Internal.fromDescriptor

Expand Down Expand Up @@ -170,7 +170,7 @@ export const getNames: <Name extends string, R, E, A>(
export const getBashCompletions: <Name extends string, R, E, A>(
self: Command<Name, R, E, A>,
programName: string
) => Effect<never, never, Array<string>> = Internal.getBashCompletions
) => Effect<Array<string>> = Internal.getBashCompletions

/**
* @since 1.0.0
Expand All @@ -179,7 +179,7 @@ export const getBashCompletions: <Name extends string, R, E, A>(
export const getFishCompletions: <Name extends string, R, E, A>(
self: Command<Name, R, E, A>,
programName: string
) => Effect<never, never, Array<string>> = Internal.getFishCompletions
) => Effect<Array<string>> = Internal.getFishCompletions

/**
* @since 1.0.0
Expand All @@ -188,7 +188,7 @@ export const getFishCompletions: <Name extends string, R, E, A>(
export const getZshCompletions: <Name extends string, R, E, A>(
self: Command<Name, R, E, A>,
programName: string
) => Effect<never, never, Array<string>> = Internal.getZshCompletions
) => Effect<Array<string>> = Internal.getZshCompletions

/**
* @since 1.0.0
Expand Down Expand Up @@ -229,7 +229,7 @@ export const make: {
<Name extends string, const Config extends Command.Config, R, E>(
name: Name,
config: Config,
handler: (_: Types.Simplify<Command.ParseConfig<Config>>) => Effect<R, E, void>
handler: (_: Types.Simplify<Command.ParseConfig<Config>>) => Effect<void, E, R>
): Command<
Name,
R,
Expand All @@ -245,7 +245,7 @@ export const make: {
export const prompt: <Name extends string, A, R, E>(
name: Name,
prompt: Prompt<A>,
handler: (_: A) => Effect<R, E, void>
handler: (_: A) => Effect<void, E, R>
) => Command<string, R, E, A> = Internal.prompt

/**
Expand All @@ -271,14 +271,14 @@ export const provide: {
export const provideEffect: {
<I, S, A, R2, E2>(
tag: Tag<I, S>,
effect: Effect<R2, E2, S> | ((_: A) => Effect<R2, E2, S>)
effect: Effect<S, E2, R2> | ((_: A) => Effect<S, E2, R2>)
): <Name extends string, R, E>(
self: Command<Name, R, E, A>
) => Command<Name, R2 | Exclude<R, I>, E2 | E, A>
<Name extends string, R, E, A, I, S, R2, E2>(
self: Command<Name, R, E, A>,
tag: Tag<I, S>,
effect: Effect<R2, E2, S> | ((_: A) => Effect<R2, E2, S>)
effect: Effect<S, E2, R2> | ((_: A) => Effect<S, E2, R2>)
): Command<Name, R2 | Exclude<R, I>, E | E2, A>
} = Internal.provideEffect

Expand All @@ -288,11 +288,11 @@ export const provideEffect: {
*/
export const provideEffectDiscard: {
<A, R2, E2, _>(
effect: Effect<R2, E2, _> | ((_: A) => Effect<R2, E2, _>)
effect: Effect<_, E2, R2> | ((_: A) => Effect<_, E2, R2>)
): <Name extends string, R, E>(self: Command<Name, R, E, A>) => Command<Name, R2 | R, E2 | E, A>
<Name extends string, R, E, A, R2, E2, _>(
self: Command<Name, R, E, A>,
effect: Effect<R2, E2, _> | ((_: A) => Effect<R2, E2, _>)
effect: Effect<_, E2, R2> | ((_: A) => Effect<_, E2, R2>)
): Command<Name, R | R2, E | E2, A>
} = Internal.provideEffectDiscard

Expand All @@ -318,11 +318,11 @@ export const provideSync: {
*/
export const transformHandler: {
<R, E, A, R2, E2>(
f: (effect: Effect<R, E, void>, config: A) => Effect<R2, E2, void>
f: (effect: Effect<void, E, R>, config: A) => Effect<void, E2, R2>
): <Name extends string>(self: Command<Name, R, E, A>) => Command<Name, R | R2, E | E2, A>
<Name extends string, R, E, A, R2, E2>(
self: Command<Name, R, E, A>,
f: (effect: Effect<R, E, void>, config: A) => Effect<R2, E2, void>
f: (effect: Effect<void, E, R>, config: A) => Effect<void, E2, R2>
): Command<Name, R | R2, E | E2, A>
} = Internal.transformHandler

Expand All @@ -346,11 +346,11 @@ export const withDescription: {
*/
export const withHandler: {
<A, R, E>(
handler: (_: A) => Effect<R, E, void>
handler: (_: A) => Effect<void, E, R>
): <Name extends string, XR, XE>(self: Command<Name, XR, XE, A>) => Command<Name, R, E, A>
<Name extends string, XR, XE, A, R, E>(
self: Command<Name, XR, XE, A>,
handler: (_: A) => Effect<R, E, void>
handler: (_: A) => Effect<void, E, R>
): Command<Name, R, E, A>
} = Internal.withHandler

Expand Down Expand Up @@ -411,18 +411,18 @@ export const wizard: {
): <Name extends string, R, E, A>(
self: Command<Name, R, E, A>
) => Effect<
FileSystem | Path | Terminal,
Array<string>,
QuitException | ValidationError,
Array<string>
FileSystem | Path | Terminal
>
<Name extends string, R, E, A>(
self: Command<Name, R, E, A>,
prefix: ReadonlyArray<string>,
config: CliConfig
): Effect<
FileSystem | Path | Terminal,
Array<string>,
QuitException | ValidationError,
Array<string>
FileSystem | Path | Terminal
>
} = Internal.wizard

Expand All @@ -435,9 +435,9 @@ export const run: {
config: Omit<CliApp.ConstructorArgs<never>, "command">
): <Name extends string, R, E, A>(
self: Command<Name, R, E, A>
) => (args: ReadonlyArray<string>) => Effect<R | CliApp.Environment, E | ValidationError, void>
) => (args: ReadonlyArray<string>) => Effect<void, E | ValidationError, R | CliApp.Environment>
<Name extends string, R, E, A>(
self: Command<Name, R, E, A>,
config: Omit<CliApp.ConstructorArgs<never>, "command">
): (args: ReadonlyArray<string>) => Effect<CliApp.Environment | R, ValidationError | E, void>
): (args: ReadonlyArray<string>) => Effect<void, E | ValidationError, R | CliApp.Environment>
} = Internal.run
22 changes: 11 additions & 11 deletions packages/cli/src/CommandDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const getHelp: <A>(self: Command<A>, config: CliConfig) => HelpDoc = Inte
export const getBashCompletions: <A>(
self: Command<A>,
programName: string
) => Effect<never, never, Array<string>> = Internal.getBashCompletions
) => Effect<Array<string>> = Internal.getBashCompletions

/**
* @since 1.0.0
Expand All @@ -123,7 +123,7 @@ export const getBashCompletions: <A>(
export const getFishCompletions: <A>(
self: Command<A>,
programName: string
) => Effect<never, never, Array<string>> = Internal.getFishCompletions
) => Effect<Array<string>> = Internal.getFishCompletions

/**
* @since 1.0.0
Expand All @@ -132,7 +132,7 @@ export const getFishCompletions: <A>(
export const getZshCompletions: <A>(
self: Command<A>,
programName: string
) => Effect<never, never, Array<string>> = Internal.getZshCompletions
) => Effect<Array<string>> = Internal.getZshCompletions

/**
* @since 1.0.0
Expand Down Expand Up @@ -166,8 +166,8 @@ export const map: {
* @category combinators
*/
export const mapEffect: {
<A, B>(f: (a: A) => Effect<FileSystem | Path | Terminal, ValidationError, B>): (self: Command<A>) => Command<B>
<A, B>(self: Command<A>, f: (a: A) => Effect<FileSystem | Path | Terminal, ValidationError, B>): Command<B>
<A, B>(f: (a: A) => Effect<B, ValidationError, FileSystem | Path | Terminal>): (self: Command<A>) => Command<B>
<A, B>(self: Command<A>, f: (a: A) => Effect<B, ValidationError, FileSystem | Path | Terminal>): Command<B>
} = Internal.mapEffect

/**
Expand All @@ -180,12 +180,12 @@ export const parse: {
config: CliConfig
): <A>(
self: Command<A>
) => Effect<FileSystem | Path | Terminal, ValidationError, CommandDirective<A>>
) => Effect<CommandDirective<A>, ValidationError, FileSystem | Path | Terminal>
<A>(
self: Command<A>,
args: ReadonlyArray<string>,
config: CliConfig
): Effect<FileSystem | Path | Terminal, ValidationError, CommandDirective<A>>
): Effect<CommandDirective<A>, ValidationError, FileSystem | Path | Terminal>
} = Internal.parse

/**
Expand Down Expand Up @@ -262,17 +262,17 @@ export const wizard: {
): <A>(
self: Command<A>
) => Effect<
FileSystem | Path | Terminal,
Array<string>,
ValidationError | QuitException,
Array<string>
FileSystem | Path | Terminal
>
<A>(
self: Command<A>,
prefix: ReadonlyArray<string>,
config: CliConfig
): Effect<
FileSystem | Path | Terminal,
Array<string>,
ValidationError | QuitException,
Array<string>
FileSystem | Path | Terminal
>
} = Internal.wizard
2 changes: 1 addition & 1 deletion packages/cli/src/ConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const makeProvider: (
readonly searchPaths?: ReadonlyArray<string>
}
| undefined
) => Effect<Path | FileSystem, ConfigFileError, ConfigProvider> = Internal.makeProvider
) => Effect<ConfigProvider, ConfigFileError, Path | FileSystem> = Internal.makeProvider

/**
* @since 2.0.0
Expand Down
Loading

0 comments on commit 1a77f72

Please sign in to comment.