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
})