Go-style error handling

How do I make my URL parser more effectful? Right now it just feels like I'm doing Go-style/neverthrow-style error handling, which I feel like is missing the power of Effect.

const program = Effect.gen(function*() {
  const myurl = new URL("https://example.com/?activeTab=RUN_SEQ__2")

  const runSeq = yield* Effect.gen(function*() {
    const activeTab = myurl.searchParams.get("activeTab")
    if (!activeTab) return yield* new UrlError()
    const runSeqString = activeTab.match(/^RUN_SEQ__([0-9]+)$/)?.[1]
    if (!runSeqString) return yield* new UrlError()
    const runSeq = Number.parse(runSeqString)
    if (Option.isNone(runSeq)) return yield* new UrlError()
    return runSeq.value
  })

  return runSeq
})


Here is a playground: https://effect.website/play#7ce24f7d8251
Was this page helpful?