Struggling with Composing Effects in Code: Seeking Intuitive Solutions

How does people know how to compose effect things? I am NEVER able to figure it out myself, and it's very frustating. I like when I can code by intuition by just checking at auto-completion and type signatures, but this is never the case with effect. I can only code what I have already done before, and I only reached that point because I get help from someone here or I found an example that was literally what I was looking for. I never started with an idea, pick up some effect modules that I "feel were the right ones" and write code.
Types are impossible to read in the editor almost all the time (look at the screenshot)
And the way things are supposed to be composed togheter is never clear out of the normal Option, Either, and simple Effects.
An example in code. I had this:
const cookie = pipe(
  HttpServerRequest.schemaCookies(
    Schema.Struct({ auth_session: Schema.String })
  ),
  Effect.mapError(() =>
    HttpError.unauthorized('Expected valid "auth_session" header')
  ),

Now I wanted to check for headers, so it should be as easy as adding another element to the pipe right? Composability right? Something like this?
const cookie = pipe(
  HttpServerRequest.schemaCookies(
    Schema.Struct({ auth_session: Schema.String })
  ),
  HttpServerRequest.schemaHeaders(
    Schema.Struct({
      Origin: Schema.String,
      Host: Schema.String,
    })
  ),
  Effect.mapError(() =>
    HttpError.unauthorized('Expected valid "auth_session" header')
  ),

But no, that gives me a cryptic TS error that is absolutely useless (check second screenshot)
Then I have to figure out what is the right primitive to compose this. Or ask here.
How does people get familiar with this things? Are you constantly reading the effect tests hoping for usage examples? Or what is the mental model that you use?
Screenshot_2024-08-23_at_07.57.33.png
Screenshot_2024-08-23_at_08.07.41.png
Was this page helpful?