Minor Changes
-
#2006
9a2d1c1
Thanks @github-actions! - With this change we now require a string key to be provided for all tags and renames the dear oldTag
toGenericTag
, so when previously you could do:import { Effect, Context } from "effect"; interface Service { readonly _: unique symbol; } const Service = Context.Tag< Service, { number: Effect.Effect<never, never, number>; } >();
you are now mandated to do:
import { Effect, Context } from "effect"; interface Service { readonly _: unique symbol; } const Service = Context.GenericTag< Service, { number: Effect.Effect<never, never, number>; } >("Service");
This makes by default all tags globals and ensures better debuggaility when unexpected errors arise.
Furthermore we introduce a new way of constructing tags that should be considered the new default:
import { Effect, Context } from "effect"; class Service extends Context.Tag("Service")< Service, { number: Effect.Effect<never, never, number>; } >() {} const program = Effect.flatMap(Service, ({ number }) => number).pipe( Effect.flatMap((_) => Effect.log(`number: ${_}`)), );
this will use "Service" as the key and will create automatically an opaque identifier (the class) to be used at the type level, it does something similar to the above in a single shot.
-
#2006
1a77f72
Thanks @github-actions! - changeEffect
type parameters order fromEffect<R, E, A>
toEffect<A, E = never, R = never>
-
#2006
d3f9f4d
Thanks @github-actions! - Schema: switchreadonlyMapFromSelf
,readonlyMap
from positional arguments to a singleoptions
argument:Before:
import * as S from "@effect/schema/Schema"; S.readonlyMapFromSelf(S.string, S.number); S.readonlyMap(S.string, S.number);
Now:
import * as S from "@effect/schema/Schema"; S.readonlyMapFromSelf({ key: S.string, value: S.number }); S.readonlyMap({ key: S.string, value: S.number });
-
#2006
d3f9f4d
Thanks @github-actions! - Schema: switchhashMapFromSelf
,hashMap
from positional arguments to a singleoptions
argument:Before:
import * as S from "@effect/schema/Schema"; S.hashMapFromSelf(S.string, S.number); S.hashMap(S.string, S.number);
Now:
import * as S from "@effect/schema/Schema"; S.hashMapFromSelf({ key: S.string, value: S.number }); S.hashMap({ key: S.string, value: S.number });
-
#2006
d3f9f4d
Thanks @github-actions! - Schema: switchcauseFromSelf
,cause
from positional arguments to a singleoptions
argument:Before:
import * as S from "@effect/schema/Schema"; S.causeFromSelf(S.string); S.causeFromSelf(S.string, S.unknown); S.cause(S.string); S.cause(S.string, S.unknown);
Now:
import * as S from "@effect/schema/Schema"; S.causeFromSelf({ error: S.string }); S.causeFromSelf({ error: S.string, defect: S.unknown }); S.cause({ error: S.string }); S.cause({ error: S.string, defect: S.unknown });
-
#2006
d3f9f4d
Thanks @github-actions! - Schema: switchexitFromSelf
,exit
from positional arguments to a singleoptions
argument:Before:
import * as S from "@effect/schema/Schema"; S.exitFromSelf(S.string, S.number); S.exit(S.string, S.number);
Now:
import * as S from "@effect/schema/Schema"; S.exitFromSelf({ failure: S.string, success: S.number }); S.exit({ failure: S.string, success: S.number });
-
#2006
a34dbdc
Thanks @github-actions! - - Schema: change type parameters order fromSchema<R, I, A>
toSchema<A, I = A, R = never>
- Serializable: change type parameters order from
Serializable<R, I, A>
toSerializable<A, I, R>
- Class: change type parameters order from
Class<R, I, A, C, Self, Inherited>
toClass<A, I, R, C, Self, Inherited>
- PropertySignature: change type parameters order from
PropertySignature<R, From, FromIsOptional, To, ToIsOptional>
toPropertySignature<From, FromIsOptional, To, ToIsOptional, R = never>
- Serializable: change type parameters order from
-
#2006
d3f9f4d
Thanks @github-actions! - Schema: switcheitherFromSelf
,either
,eitherFromUnion
from positional arguments to a singleoptions
argument:Before:
import * as S from "@effect/schema/Schema"; S.eitherFromSelf(S.string, S.number); S.either(S.string, S.number); S.eitherFromUnion(S.string, S.number);
Now:
import * as S from "@effect/schema/Schema"; S.eitherFromSelf({ left: S.string, right: S.number }); S.either({ left: S.string, right: S.number }); S.eitherFromUnion({ left: S.string, right: S.number });
-
#2006
02c3461
Thanks @github-actions! - With this change we remove theData.Data
type and we makeEqual.Equal
&Hash.Hash
implicit traits.The main reason is that
Data.Data<A>
was structurally equivalent toA & Equal.Equal
but extendingEqual.Equal
doesn't mean that the equality is implemented by-value, so the type was simply adding noise without gaining any level of safety.The module
Data
remains unchanged at the value level, all the functions previously available are supposed to work in exactly the same manner.At the type level instead the functions return
Readonly
variants, so for example we have:import { Data } from "effect"; const obj = Data.struct({ a: 0, b: 1, });
will have the
obj
typed as:declare const obj: { readonly a: number; readonly b: number; };
-
#2006
9a2d1c1
Thanks @github-actions! - This change enablesEffect.serviceConstants
andEffect.serviceMembers
to access any constant in the service, not only the effects, namely it is now possible to do:import { Effect, Context } from "effect"; class NumberRepo extends Context.TagClass("NumberRepo")< NumberRepo, { readonly numbers: Array<number>; } >() { static numbers = Effect.serviceConstants(NumberRepo).numbers; }
-
#2006
56b8691
Thanks @github-actions! - Fix usage of Schema.TaggedError in combination with Unify.When used with Unify we previously had:
import { Schema } from "@effect/schema"; import type { Unify } from "effect"; class Err extends Schema.TaggedError<Err>()("Err", {}) {} // $ExpectType Effect<unknown, unknown, unknown> export type IdErr = Unify.Unify<Err>;
With this fix we now have:
import { Schema } from "@effect/schema"; import type { Unify } from "effect"; class Err extends Schema.TaggedError<Err>()("Err", {}) {} // $ExpectType Err export type IdErr = Unify.Unify<Err>;
Patch Changes
-
#2006
4cd6e14
Thanks @github-actions! - Rename transform type parameters and de/en-coder param names to be more helpful in IDE hints. -
#2006
9dc04c8
Thanks @github-actions! - Introducing Optional Annotations inoptional
API.Previously, when adding annotations to an optional field using
optional
API, you needed to usepropertySignatureAnnotations
. However, a new optional argumentannotations
is now available to simplify this process.Before:
import * as S from "@effect/schema/Schema"; const myschema = S.struct({ a: S.optional(S.string).pipe( S.propertySignatureAnnotations({ description: "my description..." }), ), });
Now:
import * as S from "@effect/schema/Schema"; const myschema = S.struct({ a: S.optional(S.string, { annotations: { description: "my description..." }, }), });
With this update, you can easily include annotations directly within the
optional
API without the need for additional calls. -
Updated dependencies [
96bcee2
,96bcee2
,c77f635
,e343a74
,acf1894
,9a2d1c1
,1a77f72
,c986f0e
,96bcee2
,70dde23
,81b7425
,02c3461
,0e56e99
,8b0ded9
,8dd83e8
,5127afe
,d75f6fe
,7356e5c
,3077cde
,be19ce0
,4a5d01a
,78f47ab
,52e5d20
,c6137ec
,f5ae081
,4a5d01a
,60686f5
,9a2d1c1
,5127afe
,8ee2931
,6727474
,5127afe
]:- effect@2.3.0