Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ Update dependency effect to v3 #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Apr 16, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
effect (source) 2.2.5 -> 3.7.2 age adoption passing confidence

Release Notes

Effect-TS/effect (effect)

v3.7.2

Compare Source

Patch Changes

v3.7.1

Compare Source

Patch Changes

v3.7.0

Compare Source

Minor Changes
  • #​3410 2f456cc Thanks @​vinassefranche! - preserve Array.modify Array.modifyOption non emptiness

  • #​3410 8745e41 Thanks @​patroza! - improve: type Fiber.awaitAll as Exit<A, E>[].

  • #​3410 e557838 Thanks @​titouancreach! - New constructor Config.nonEmptyString

  • #​3410 d6e7e40 Thanks @​KhraksMamtsov! - preserve Array.replace Array.replaceOption non emptiness

  • #​3410 8356321 Thanks @​KhraksMamtsov! - add Effect.bindAll api

    This api allows you to combine Effect.all with Effect.bind. It is useful
    when you want to concurrently run multiple effects and then combine their
    results in a Do notation pipeline.

    import { Effect } from "effect"
    
    const result = Effect.Do.pipe(
      Effect.bind("x", () => Effect.succeed(2)),
      Effect.bindAll(
        ({ x }) => ({
          a: Effect.succeed(x + 1),
          b: Effect.succeed("foo")
        }),
        { concurrency: 2 }
      )
    )
    assert.deepStrictEqual(Effect.runSync(result), {
      x: 2,
      a: 3,
      b: "foo"
    })
    
  • #​3410 192f2eb Thanks @​tim-smart! - add propagateInterruption option to Fiber{Handle,Set,Map}

    This option will send any external interrupts to the .join result.

  • #​3410 718cb70 Thanks @​dilame! - feat(Stream): implement race operator, which accepts two upstreams and returns a stream that mirrors the first upstream to emit an item and interrupts the other upstream.

    import { Stream, Schedule, Console, Effect } from "effect"
    
    const stream = Stream.fromSchedule(Schedule.spaced("2 millis")).pipe(
      Stream.race(Stream.fromSchedule(Schedule.spaced("1 millis"))),
      Stream.take(6),
      Stream.tap((n) => Console.log(n))
    )
    
    Effect.runPromise(Stream.runDrain(stream))
    // Output each millisecond from the first stream, the rest streams are interrupted
    // 0
    // 1
    // 2
    // 3
    // 4
    // 5
    
  • #​3410 e9d0310 Thanks @​mikearnaldi! - Avoid automatic propagation of finalizer concurrency, closes #​3440

  • #​3410 6bf28f7 Thanks @​tim-smart! - add Context.getOrElse api, for gettings a Tag's value with a fallback

Patch Changes

v3.6.8

Compare Source

Patch Changes

v3.6.7

Compare Source

Patch Changes

v3.6.6

Compare Source

Patch Changes

v3.6.5

Compare Source

Patch Changes

v3.6.4

Compare Source

Patch Changes

v3.6.3

Compare Source

Patch Changes

v3.6.2

Compare Source

Patch Changes

v3.6.1

Compare Source

Patch Changes

v3.6.0

Compare Source

Minor Changes
  • #​3380 1e0fe80 Thanks @​tim-smart! - make List.Cons extend NonEmptyIterable

  • #​3380 8135294 Thanks @​tim-smart! - add DateTime module

    The DateTime module provides functionality for working with time, including
    support for time zones and daylight saving time.

    It has two main data types: DateTime.Utc and DateTime.Zoned.

    A DateTime.Utc represents a time in Coordinated Universal Time (UTC), and
    a DateTime.Zoned contains both a UTC timestamp and a time zone.

    There is also a CurrentTimeZone service, for setting a time zone contextually.

    import { DateTime, Effect } from "effect";
    
    Effect.gen(function* () {
      // Get the current time in the current time zone
      const now = yield* DateTime.nowInCurrentZone;
    
      // Math functions are included
      const tomorrow = DateTime.add(now, 1, "day");
    
      // Convert to a different time zone
      // The UTC portion of the `DateTime` is preserved and only the time zone is
      // changed
      const sydneyTime = tomorrow.pipe(
        DateTime.unsafeSetZoneNamed("Australia/Sydney"),
      );
    }).pipe(DateTime.withCurrentZoneNamed("America/New_York"));
    
  • #​3380 cd255a4 Thanks @​tim-smart! - add Stream.asyncPush api

    This api creates a stream from an external push-based resource.

    You can use the emit helper to emit values to the stream. You can also use
    the emit helper to signal the end of the stream by using apis such as
    emit.end or emit.fail.

    By default it uses an "unbounded" buffer size.
    You can customize the buffer size and strategy by passing an object as the
    second argument with the bufferSize and strategy fields.

    import { Effect, Stream } from "effect";
    
    Stream.asyncPush<string>(
      (emit) =>
        Effect.acquireRelease(
          Effect.gen(function* () {
            yield* Effect.log("subscribing");
            return setInterval(() => emit.single("tick"), 1000);
          }),
          (handle) =>
            Effect.gen(function* () {
              yield* Effect.log("unsubscribing");
              clearInterval(handle);
            }),
        ),
      { bufferSize: 16, strategy: "dropping" },
    );
    
  • #​3380 3845646 Thanks @​mikearnaldi! - Implement Struct.keys as a typed alternative to Object.keys

    import { Struct } from "effect";
    
    const symbol: unique symbol = Symbol();
    
    const value = {
      a: 1,
      b: 2,
      [symbol]: 3,
    };
    
    const keys: Array<"a" | "b"> = Struct.keys(value);
    
  • #​3380 2d09078 Thanks @​sukovanej! - Add Random.choice.

    import { Random } from "effect";
    
    Effect.gen(function* () {
      const randomItem = yield* Random.choice([1, 2, 3]);
      console.log(randomItem);
    });
    
  • #​3380 4bce5a0 Thanks @​vinassefranche! - Add onlyEffect option to Effect.tap

  • #​3380 4ddbff0 Thanks @​KhraksMamtsov! - Support Refinement in Predicate.tuple and Predicate.struct

  • #​3380 e74cc38 Thanks @​dilame! - Implement Stream.onEnd that adds an effect to be executed at the end of the stream.

    import { Console, Effect, Stream } from "effect";
    
    const stream = Stream.make(1, 2, 3).pipe(
      Stream.map((n) => n * 2),
      Stream.tap((n) => Console.log(`after mapping: ${n}`)),
      Stream.onEnd(Console.log("Stream ended")),
    );
    
    Effect.runPromise(Stream.runCollect(stream)).then(console.log);
    // after mapping: 2
    // after mapping: 4
    // after mapping: 6
    // Stream ended
    // { _id: 'Chunk', values: [ 2, 4, 6 ] }
    
  • #​3380 bb069b4 Thanks @​dilame! - Implement Stream.onStart that adds an effect to be executed at the start of the stream.

    import { Console, Effect, Stream } from "effect";
    
    const stream = Stream.make(1, 2, 3).pipe(
      Stream.onStart(Console.log("Stream started")),
      Stream.map((n) => n * 2),
      Stream.tap((n) => Console.log(`after mapping: ${n}`)),
    );
    
    Effect.runPromise(Stream.runCollect(stream)).then(console.log);
    // Stream started
    // after mapping: 2
    // after mapping: 4
    // after mapping: 6
    // { _id: 'Chunk', values: [ 2, 4, 6 ] }
    
  • #​3380 cd255a4 Thanks @​tim-smart! - add bufferSize option to Stream.fromEventListener

  • #​3380 7d02174 Thanks @​fubhy! - Changed various function signatures to return Array instead of ReadonlyArray

v3.5.9

Compare Source

Patch Changes
  • #​3377 6359644 Thanks @​tim-smart! - add MicroScheduler to Micro module

  • #​3362 7f41e42 Thanks @​IMax153! - Add Service and Identifier to Context.Tag.

    These helpers can be used, for example, to extract the service shape from a tag:

    import * as Context from "effect/Context";
    
    export class Foo extends Context.Tag("Foo")<
      Foo,
      {
        readonly foo: Effect.Effect<void>;
      }
    >() {}
    
    type ServiceShape = typeof Foo.Service;
    
  • #​3373 f566fd1 Thanks @​KhraksMamtsov! - Add test for Hash.number(0.1) !== Has.number(0)

v3.5.8

Compare Source

Patch Changes

v3.5.7

Compare Source

Patch Changes

v3.5.6

Compare Source

Patch Changes

v3.5.5

Compare Source

Patch Changes

v3.5.4

Compare Source

Patch Changes

v3.5.3

Compare Source

Patch Changes

v3.5.2

Compare Source

Patch Changes

v3.5.1

Compare Source

Patch Changes

v3.5.0

Compare Source

Minor Changes
  • #​3048 a1f5b83 Thanks @​tim-smart! - add renderErrorCause option to Cause.pretty

  • #​3048 60bc3d0 Thanks @​tim-smart! - add RcRef module

    An RcRef wraps a reference counted resource that can be acquired and released multiple times.

    The resource is lazily acquired on the first call to get and released when the last reference is released.

    import { Effect, RcRef } from "effect";
    
    Effect.gen(function* () {
      const ref = yield* RcRef.make({
        acquire: Effect.acquireRelease(Effect.succeed("foo"), () =>
          Effect.log("release foo"),
        ),
      });
    
      // will only acquire the resource once, and release it
      // when the scope is closed
      yield* RcRef.get(ref).pipe(Effect.andThen(RcRef.get(ref)), Effect.scoped);
    });
    
  • #​3048 5ab348f Thanks @​tim-smart! - allowing customizing Stream pubsub strategy

    import { Schedule, Stream } from "effect";
    
    // toPubSub
    Stream.fromSchedule(Schedule.spaced(1000)).pipe(
      Stream.toPubSub({
        capacity: 16, // or "unbounded"
        strategy: "dropping", // or "sliding" / "suspend"
      }),
    );
    
    // also for the broadcast apis
    Stream.fromSchedule(Schedule.spaced(1000)).pipe(
      Stream.broadcastDynamic({
        capacity: 16,
        strategy: "dropping",
      }),
    );
    
  • #​3048 60bc3d0 Thanks @​tim-smart! - add Duration.isZero, for checking if a Duration is zero

  • #​3048 3e04bf8 Thanks @​sukovanej! - Add Success type util for Config.

  • #​3048 e7fc45f Thanks @​tim-smart! - add Logger.prettyLogger and Logger.pretty

    Logger.pretty is a new logger that leverages the features of the console APIs to provide a more visually appealing output.

    To try it out, provide it to your program:

    import { Effect, Logger } from "effect";
    
    Effect.log("Hello, World!").pipe(Effect.provide(Logger.pretty));
    
  • #​3048 a1f5b83 Thanks @​tim-smart! - add .groupCollapsed to UnsafeConsole

  • #​3048 4626de5 Thanks @​giacomoran! - export Random.make taking hashable values as seed

  • #​3048 f01e7db Thanks @​tim-smart! - add replay option to PubSub constructors

    This option adds a replay buffer in front of the given PubSub. The buffer will
    replay the last n messages to any new subscriber.

    Effect.gen(function*() {
      const messages = [1, 2, 3, 4, 5]
      const pubsub = yield* PubSub.bounded<number>({ capacity: 16, replay: 3 })
      yield* PubSub.publishAll(pubsub, messages)
      const sub = yield* PubSub.subscribe(pubsub)
      assert.deepStrictEqual(Chunk.toReadonlyArray(yield* Queue.takeAll(sub)), [3, 4, 5])
    }))
    
  • #​3048 60bc3d0 Thanks @​tim-smart! - add RcMap module

    An RcMap can contain multiple reference counted resources that can be indexed
    by a key. The resources are lazily acquired on the first call to get and
    released when the last reference is released.

    Complex keys can extend Equal and Hash to allow lookups by value.

    import { Effect, RcMap } from "effect";
    
    Effect.gen(function* () {
      const map = yield* RcMap.make({
        lookup: (key: string) =>
          Effect.acquireRelease(Effect.succeed(`acquired ${key}`), () =>
            Effect.log(`releasing ${key}`),
          ),
      });
    
      // Get "foo" from the map twice, which will only acquire it once
      // It will then be released once the scope closes.
      yield* RcMap.get(map, "foo").pipe(
        Effect.andThen(RcMap.get(map, "foo")),
        Effect.scoped,
      );
    });
    
  • #​3048 ac71f37 Thanks @​dilame! - Ensure Scope is excluded from R in the Channel / Stream run* functions.

    This fix ensures that Scope is now properly excluded from the resulting effect environment.
    The affected functions include run, runCollect, runCount, runDrain and other non-scoped run* in both Stream and Channel modules.
    This fix brings the type declaration in line with the runtime implementation.

  • #​3048 8432360 Thanks @​dilame! - refactor(Stream/mergeLeft): rename self/that argument names to left/right for clarity

    refactor(Stream/mergeRight): rename self/that argument names to left/right for clarity

  • #​3048 e4bf1bf Thanks @​dilame! - feat(Stream): implement "raceAll" operator, which returns a stream that mirrors the first source stream to emit an item.

    import { Stream, Schedule, Console, Effect } from "effect";
    
    const stream = Stream.raceAll(
      Stream.fromSchedule(Schedule.spaced("1 millis")),
      Stream.fromSchedule(Schedule.spaced("2 millis")),
      Stream.fromSchedule(Schedule.spaced("4 millis")),
    ).pipe(Stream.take(6), Stream.tap(Console.log));
    
    Effect.runPromise(Stream.runDrain(stream));
    // Output only from the first stream, the rest streams are interrupted
    // 0
    // 1
    // 2
    // 3
    // 4
    // 5
    
  • #​3048 13cb861 Thanks @​dilame! - refactor(Stream): use new built-in Types.TupleOf instead of Stream.DynamicTuple and deprecate it

  • #​3048 79d2d91 Thanks @​tim-smart! - support ErrorOptions in YieldableError constructor

  • #​3048 9f66825 Thanks @​tim-smart! - allow customizing the output buffer for the Stream.async* apis

    import { Stream } from "effect";
    
    Stream.async<string>(
      (emit) => {
        // ...
      },
      {
        bufferSize: 16,
        strategy: "dropping", // you can also use "sliding" or "suspend"
      },
    );
    
Patch Changes

v3.4.9

Compare Source

Patch Changes

v3.4.8

Compare Source

Patch Changes

v3.4.7

Compare Source

Patch Changes

v3.4.6

Compare Source

Patch Changes
  • #​3096 5c0ceb0 Thanks @​gcanti! - 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
  • #​3096 5c0ceb0 Thanks @​gcanti! - Micro: rename timeout to timeoutOption, and add a timeout that fails with a TimeoutException

  • #​3121 33735b1 Thanks @​KhraksMamtsov! - Support for the tacit usage of external handlers for Match.tag and Match.tagStartsWith functions

    type Value = { _tag: "A"; a: string } | { _tag: "B"; b: number };
    const handlerA = (_: { _tag: "A"; a: number }) => _.a;
    
    // $ExpectType string | number
    pipe(
      M.type<Value>(),
      M.tag("A", handlerA), // <-- no type issue
      M.orElse((_) => _.b),
    )(value);
    
  • #​3096 5c0ceb0 Thanks @​gcanti! - Micro: move MicroExit types to a namespace

  • #​3134 139d4b3 Thanks @​tim-smart! - use Channel.acquireUseRelease for Channel.withSpan

v3.4.5

Compare Source

Patch Changes

v3.4.4

Compare Source

Patch Changes

v3.4.3

Compare Source

Patch Changes

v3.4.2

Compare Source

Patch Changes

v3.4.1

Compare Source

Patch Changes

v3.4.0

Compare Source

Minor Changes
  • #​2938 c0ce180 Thanks @​LaureRC! - Make Option.liftPredicate dual

  • #​2938 61707b6 Thanks @​LaureRC! - Add Effect.liftPredicate

    Effect.liftPredicate transforms a Predicate function into an Effect returning the input value if the predicate returns true or failing with specified error if the predicate fails.

    import { Effect } from "effect";
    
    const isPositive = (n: number): boolean => n > 0;
    
    // succeeds with `1`
    Effect.liftPredicate(1, isPositive, (n) => `${n} is not positive`);
    
    // fails with `"0 is not positive"`
    Effect.liftPredicate(0, isPositive, (n) => `${n} is not positive`);
    
  • #​2938 9c1b5b3 Thanks @​tim-smart! - add EventListener type to Stream to avoid use of dom lib

  • #​2938 a35faf8 Thanks @​gcanti! - Add lastNonEmpty function to Chunk module, closes #​2946

  • #​2938 ff73c0c Thanks @​dilame! - feat(Stream): implement Success, Error, Context type accessors

  • #​2938 984d516 Thanks @​tim-smart! - add Micro module

    A lightweight alternative to Effect, for when bundle size really matters.

    At a minimum, Micro adds 5kb gzipped to your bundle, and scales with the amount
    of features you use.

  • #​2938 8c3b8a2 Thanks @​gcanti! - add ManagedRuntime type utils (Context, and Error)

  • #​2938 017e2f9 Thanks @​LaureRC! - Add Either.liftPredicate

  • #​2938 91bf8a2 Thanks @​msensys! - Add Tuple.at api, to retrieve an element at a specified index from a tuple.

    import { Tuple } from "effect";
    
    assert.deepStrictEqual(Tuple.at([1, "hello", true], 1), "hello");
    
  • #​2938 c6a4a26 Thanks @​datner! - add ensure util for Array, used to normalize A | ReadonlyArray<A>

    import { ensure } from "effect/Array";
    
    // lets say you are not 100% sure if it's a member or a collection
    declare const someValue: { foo: string } | Array<{ foo: string }>;
    
    // $ExpectType ({ foo: string })[]
    const normalized = ensure(someValue);
    

[v3.3.5](https://redirect.github.com/Effect-TS/effect/blob/HEA


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot added renovate upgrade Any kind of dependency updates labels Apr 16, 2024
Copy link
Contributor Author

renovate bot commented Apr 16, 2024

⚠ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: package-lock.json
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @effect/[email protected]
npm error Found: [email protected]
npm error node_modules/effect
npm error   effect@"3.1.3" from the root project
npm error
npm error Could not resolve dependency:
npm error peer effect@"^2.1.1" from @effect/[email protected]
npm error node_modules/@effect/schema
npm error   @effect/schema@"0.60.4" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/effect
npm error   peer effect@"^2.1.1" from @effect/[email protected]
npm error   node_modules/@effect/schema
npm error     @effect/schema@"0.60.4" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /tmp/renovate/cache/others/npm/_logs/2024-05-08T22_22_18_081Z-eresolve-report.txt

npm error A complete log of this run can be found in: /tmp/renovate/cache/others/npm/_logs/2024-05-08T22_22_18_081Z-debug-0.log

@renovate renovate bot force-pushed the renovate/effect-3.x branch 8 times, most recently from ac64789 to 5c44085 Compare April 25, 2024 04:19
@renovate renovate bot force-pushed the renovate/effect-3.x branch 10 times, most recently from 9d2cf0f to d4fa257 Compare May 2, 2024 22:37
@renovate renovate bot force-pushed the renovate/effect-3.x branch 9 times, most recently from b3879b8 to a7c2703 Compare May 8, 2024 22:22
@renovate renovate bot force-pushed the renovate/effect-3.x branch 6 times, most recently from e4bc5bb to ffd8690 Compare August 8, 2024 22:54
@renovate renovate bot force-pushed the renovate/effect-3.x branch 5 times, most recently from 60fb972 to 25cb4ef Compare August 16, 2024 22:46
@renovate renovate bot force-pushed the renovate/effect-3.x branch 6 times, most recently from eff77b6 to 8e23f1f Compare August 24, 2024 00:12
@renovate renovate bot force-pushed the renovate/effect-3.x branch 7 times, most recently from cef075c to 469c527 Compare September 1, 2024 15:48
@renovate renovate bot force-pushed the renovate/effect-3.x branch 4 times, most recently from fb7a5e3 to 13e8338 Compare September 4, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
renovate upgrade Any kind of dependency updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants