Effect CommunityEC
Effect Community2y ago
278 replies
Tim Smart

Updates to the "effect" library: type changes and renaming of "Context.Tag" to "Context.GenericTag"

Hi everyone! (cc @1110198784417345608)

A new minor release of
effect
has gone out, with some big changes we wanted to let you know about:

- Many data types have had their types swapped around. For instance Effect<R, E, A> has been changed to Effect<A, E = never, R = never>. This change makes for cleaner type signatures (Effect<void>) and ensures types are ordered by importance.
- Context.Tag has been renamed to Context.GenericTag, string identifiers are now mandatory, and a new Context.Tag base class has been added. The added class approach assists with creating unique tag identifiers, making use of the opaque type that you get for free using a class. For example:
import { Context, Effect } from "effect"

class MyService extends Context.Tag("MyService")<
  MyService,
  { methodA: Effect.Effect<void> }
>() {}

const effect: Effect.Effect<void, never, MyService> =
  Effect.flatMap(MyService, _ => _.methodA)

- For both of the above changes, a code-mod has been released to make migration as easy as possible. You can run it by executing:
npx @effect/codemod minor-2.3 src/**/*

It might not be perfect - if you encounter issues, let us know! Also make sure you commit any changes before running it, in case you need to revert anything.

- /platform has been refactored to remove re-exports from the base package. You will now need to install both @effect/platform & the corresponding @effect/platform-* package to make use of platform specific implementations.
- A rewrite of the /rpc package has been released, which simplifies the design and adds support for streaming responses. You can see a small example of usage here: https://github.com/Effect-TS/effect/tree/main/packages/rpc-http/examples

There were several other smaller changes made, feel free to read through the changelog to see them all: https://github.com/Effect-TS/effect/blob/main/packages/effect/CHANGELOG.md#230

effect
Was this page helpful?