Authored by Tim Smart
Effect 3.11 has been released! This release includes a number of new features and improvements. Here’s a summary of what’s new:
Effect.fn
The Effect.fn
api allows you to create a function that is automatically traced, and also attaches the location where the function was called to any error traces.
It also doubles as a pipe
function, allowing you to create a pipeline after the function definition.
1 import { Effect } from "effect"
2
3 const logExample = Effect.fn("example")(function* <N extends number>(n: N) {
4 yield* Effect.annotateCurrentSpan("n", n)
5 yield* Effect.logInfo(`got: ${n}`)
6 yield* Effect.fail(new Error())
7 }, Effect.delay("1 second"))
8
9 Effect.runFork(logExample(100).pipe(Effect.catchAllCause(Effect.logError)))
Time zone support in Cron
Cron expressions using the Cron
module now support time zones. You can specify a time zone when creating a cron instance when using Cron.make
or Cron.parse
.
Context.Reference
You can now create a Context.Tag
that also has a default value.
1 import { Context } from "effect"
2
3 export class SpecialNumber extends Context.Reference<SpecialNumber>()(
4 "SpecialNumber",
5 { defaultValue: () => 2048 }
6 ) {}
Micro runtime changes
Micro execution is now using a fiber-runtime based model. This results in the following benefits:
- Improved performance
- Improved interruption model
- Consistency with the Effect data type
Env
& EnvRef
have been removed in favour of Context.Reference
.
Effect.scopedWith
Effect.scopedWith
allows you to create & use a Scope
without adding it to the Effect’s requirements.
1 import { Effect, Scope } from "effect"
2
3 Effect.scopedWith((scope) => Scope.addFinalizer(scope, Effect.log("finalized")))
BigDecimal updates
-
BigDecimal.toExponential
added - format a BigDecimal as a string in exponential notation. -
BigDecimal.fromNumber
has been deprecated in favour ofBigDecimal.unsafeFromNumber
.
Other changes
There were several other smaller changes made. Take a look through the CHANGELOG to see them all: CHANGELOG.
Don’t forget to join our Discord Community to follow the latest updates and discuss every tiny detail!
Top comments (0)