3 ms·
Without do-notation this is kind of dead on arrival no?
by fire_lake 2y ago
Without do-notation this is kind of dead on arrival no?
- riwsky 2y agoThey actually do a decent impression of one using generators: https://effect.website/docs/guides/style/do#using-effectgen https://effect.website/docs/guides/style/do#using-effectgen import { Effect } from "effect" // Get the current timestamp const now = Effect.sync(() => new Date().getTime()) // Prints the elapsed time occurred to `self` to execute const elapsed = <R, E, A>( self: Effect.Effect<A, E, R> ): Effect.Effect<A, E, R> => Effect.gen(function\* () { const startMillis = yield\* now const result = yield\* self const endMillis = yield\* now // Calculate the elapsed time in milliseconds const elapsed = endMillis - startMillis // Log the elapsed time console.log(`Elapsed: ${elapsed}`) return result })
- mirekrusin 2y agoPipe/do pipe function [0]. Also pipe operator is coming soon [1]. [0] https://effect.website/docs/guides/style/do https://effect.website/docs/guides/style/do [1] https://www.proposals.es/proposals/Pipeline%20Operator https://www.proposals.es/proposals/Pipeline%20Operator