Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Without do-notation this is kind of dead on arrival no?


Pipe/do pipe function [0].

Also pipe operator is coming soon [1].

[0] https://effect.website/docs/guides/style/do

[1] https://www.proposals.es/proposals/Pipeline%20Operator


They actually do a decent impression of one using generators: 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
  })




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: