Skip to content

Commit

Permalink
Micro: renaming to align with Effect module (#3096)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim <[email protected]>
  • Loading branch information
gcanti and tim-smart committed Jun 30, 2024
1 parent 8513d7e commit 5c0ceb0
Show file tree
Hide file tree
Showing 7 changed files with 1,043 additions and 702 deletions.
73 changes: 73 additions & 0 deletions .changeset/angry-falcons-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
"effect": patch
---

Micro: align with `Effect` module (renamings and new combinators).

General naming convention rule: `<reference module (start with lowercase)><api (start with Uppercase)>`.

- `Failure` -> `MicroCause`
- `Failure.Expected<E>` -> `MicroCause.Fail<E>`
- `Failure.Unexpected` -> `MicroCause.Die`
- `Failure.Aborted` -> `MicroCause.Interrupt`
- `FailureExpected` -> `causeFail`
- `FailureUnexpected` -> `causeDie`
- `FailureAborted` -> `causeInterrupt`
- `failureIsExpected` -> `causeIsFail`
- `failureIsExpected` -> `causeIsFail`
- `failureIsUnexpected` -> `causeIsDie`
- `failureIsAborted` -> `causeIsInterrupt`
- `failureSquash` -> `causeSquash`
- `failureWithTrace` -> `causeWithTrace`
- `Result` -> `MicroExit`
- `ResultAborted` -> `exitInterrupt`
- `ResultSuccess` -> `exitSucceed`
- `ResultFail` -> `exitFail`
- `ResultFailUnexpected` -> `exitDie`
- `ResultFailWith` -> `exitFailCause`
- `resultIsSuccess` -> `exitIsSuccess`
- `resultIsFailure` -> `exitIsFailure`
- `resultIsAborted` -> `exitIsInterrupt`
- `resultIsFailureExpected` -> `exitIsFail`
- `resultIsFailureUnexpected` -> `exitIsDie`
- `resultVoid` -> `exitVoid`
- `DelayFn` -> `MicroSchedule`
- `delayExponential` -> `scheduleExponential`
- `delaySpaced` -> `scheduleSpaced`
- `delayWithMax` -> `scheduleWithMaxDelay`
- `delayWithMaxElapsed` -> `scheduleWithMaxElapsed`
- `delayWithRecurs` -> `scheduleRecurs` and make it a constructor
- add `scheduleAddDelay` combinator
- add `scheduleUnion` combinator
- add `scheduleIntersect` combinator
- `Handle`
- `abort` -> `interrupt`
- `unsafeAbort` -> `unsafeInterrupt`
- `provideServiceMicro` -> `provideServiceEffect`
- `fromResult` -> `fromExit`
- `fromResultSync` -> `fromExitSync`
- `failWith` -> `failCause`
- `failWithSync` -> `failCauseSync`
- `asResult` -> `exit`
- `filterOrFailWith` -> `filterOrFailCause`
- `repeatResult` -> `repeatExit`
- `catchFailure` -> `catchAllCause`
- `catchFailureIf` -> `catchCauseIf`
- `catchExpected` -> `catchAll`
- `catchUnexpected` -> `catchAllDefect`
- `tapFailure` -> `tapErrorCause`
- `tapFailureIf` -> `tapErrorCauseIf`
- `tapExpected` -> `tapError`
- `tapUnexpected` -> `tapDefect`
- `mapFailure` -> `mapErrorCause`
- `matchFailureMicro` -> `matchCauseEffect`
- `matchFailure` -> `matchCause`
- `matchMicro` -> `matchEffect`
- `onResult` -> `onExit`
- `onResultIf` -> `onExitIf`
- `onFailure` -> `onError`
- `onAbort` -> `onInterrupt`
- `abort` -> `interrupt`
- `runPromiseResult` -> `runPromiseExit`
- `runSyncResult` -> `runSyncExit`
- rename `delay` option to `schedule`
5 changes: 5 additions & 0 deletions .changeset/fuzzy-bananas-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Micro: rename `timeout` to `timeoutOption`, and add a `timeout` that fails with a `TimeoutException`
5 changes: 5 additions & 0 deletions .changeset/olive-rockets-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Micro: move MicroExit types to a namespace
22 changes: 22 additions & 0 deletions packages/effect/dtslint/Micro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { hole, Micro } from "effect"

// -------------------------------------------------------------------------------------
// catchCauseIf
// -------------------------------------------------------------------------------------

// $ExpectType Micro<number | Date, number | boolean, "a" | "b">
hole<Micro.Micro<number, string | number, "a">>().pipe(Micro.catchCauseIf(
(cause): cause is Micro.MicroCause<string> => true,
(
_cause // $ExpectType MicroCause<string>
) => hole<Micro.Micro<Date, boolean, "b">>()
))

// $ExpectType Micro<number | Date, number | boolean, "a" | "b">
Micro.catchCauseIf(
hole<Micro.Micro<number, string | number, "a">>(),
(cause): cause is Micro.MicroCause<string> => true,
(
_cause // $ExpectType MicroCause<string>
) => hole<Micro.Micro<Date, boolean, "b">>()
)
Loading

0 comments on commit 5c0ceb0

Please sign in to comment.