github Effect-TS/effect effect@3.9.0

Minor Changes

  • #3620 ff3d1aa Thanks @vinassefranche! - Adds HashMap.HashMap.Entry type helper

  • #3620 0ba66f2 Thanks @tim-smart! - add deno support to Inspectable

  • #3620 bf77f51 Thanks @KhraksMamtsov! - Latch implements Effect<void> with .await semantic

  • #3620 0779681 Thanks @KhraksMamtsov! - Effect.mapAccum & Array.mapAccum preserve non-emptiness

  • #3620 534129f Thanks @KhraksMamtsov! - Pool is now a subtype of Effect, equivalent to Pool.get

  • #3620 d75140c Thanks @mikearnaldi! - Support providing an array of layers via Effect.provide and Layer.provide

  • #3620 be0451c Thanks @leonitousconforti! - support ManagedRuntime in Effect.provide

  • #3620 be0451c Thanks @leonitousconforti! - ManagedRuntime<R, E> is subtype of Effect<Runtime<R>, E, never>

  • #3620 5b36494 Thanks @KhraksMamtsov! - Tuple.map transforms each element of tuple using the given function, treating tuple homomorphically

    import { pipe, Tuple } from "effect"
    
    const result = pipe(
      //  ^? [string, string, string]
      ["a", 1, false] as const,
      T.map((el) => {
        //^? "a" | 1 | false
        return el.toString().toUppercase()
      })
    )
    assert.deepStrictEqual(result, ["A", "1", "FALSE"])
  • #3620 c716adb Thanks @AlexGeb! - Add Array.pad function

  • #3620 4986391 Thanks @ianbollinger! - Add an isRegExp type guard

  • #3620 d75140c Thanks @mikearnaldi! - Implement Effect.Service as a Tag and Layer with Opaque Type.

    Namely the following is now possible:

    class Prefix extends Effect.Service<Prefix>()("Prefix", {
      sync: () => ({
        prefix: "PRE"
      })
    }) {}
    
    class Postfix extends Effect.Service<Postfix>()("Postfix", {
      sync: () => ({
        postfix: "POST"
      })
    }) {}
    
    const messages: Array<string> = []
    
    class Logger extends Effect.Service<Logger>()("Logger", {
      accessors: true,
      effect: Effect.gen(function* () {
        const { prefix } = yield* Prefix
        const { postfix } = yield* Postfix
        return {
          info: (message: string) =>
            Effect.sync(() => {
              messages.push(`[${prefix}][${message}][${postfix}]`)
            })
        }
      }),
      dependencies: [Prefix.Default, Postfix.Default]
    }) {}
    
    describe("Effect", () => {
      it.effect("Service correctly wires dependencies", () =>
        Effect.gen(function* () {
          const { _tag } = yield* Logger
          expect(_tag).toEqual("Logger")
          yield* Logger.info("Ok")
          expect(messages).toEqual(["[PRE][Ok][POST]"])
          const { prefix } = yield* Prefix
          expect(prefix).toEqual("PRE")
          const { postfix } = yield* Postfix
          expect(postfix).toEqual("POST")
        }).pipe(Effect.provide([Logger.Default, Prefix.Default, Postfix.Default]))
      )
    })
  • #3620 d1387ae Thanks @KhraksMamtsov! - Resource<A, E> is subtype of Effect<A, E>.
    ScopedRed<A> is subtype of Effect<A>.

Patch Changes

Don't miss a new effect release

NewReleases is sending notifications on new releases.