Skip to content

Record.fromIterableBy is not dual/curried (awkward in pipe) #6092

@jasonkuhrt

Description

@jasonkuhrt

What happened?

Record.fromIterableBy is currently data-first only.

With Effect APIs, many functions are dual/curried so they compose naturally in pipe. For fromIterableBy, I can’t do the equivalent data-last style and have to introduce an adapter lambda.

Current (works, but less ergonomic):

pipe(
  rows,
  (rows) => Record.fromIterableBy(rows, Struct.get("authEmail")),
)

Attempted style (does not type-check):

pipe(
  rows,
  Record.fromIterableBy(Struct.get("authEmail")),
)

This breaks pipeline readability and consistency with other dual APIs.

Repro context

  • Effect version: 3.19.3

What would you like?

Add a dual/curried overload for Record.fromIterableBy (and possibly fromIterableWith for consistency):

export declare const fromIterableBy: {
  <A, K extends string | symbol>(
    f: (a: A) => K,
  ): (items: Iterable<A>) => Record<ReadonlyRecord.NonLiteralKey<K>, A>

  <A, K extends string | symbol>(
    items: Iterable<A>,
    f: (a: A) => K,
  ): Record<ReadonlyRecord.NonLiteralKey<K>, A>
}

That would allow:

pipe(rows, Record.fromIterableBy(Struct.get("authEmail")))

Why this matters

This is mostly an ergonomics / consistency improvement, but it also avoids confusing type errors when users assume dual behavior in pipelines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions