Skip to content

Should favour names in patterns and DU subtypes #525

@knocte

Description

@knocte

There are two ways to write things, named or unnamed.

Unnamed:

type Data =
    | TwoParts of string * string
    | OnePart of string

let examineData x =
    match data with
    | OnePart p1 -> p1
    | TwoPart (p1, p2) -> p1 + p2

Named:

type Data =
    | TwoParts of part1: string * part2: string
    | OnePart of part1: string

let examineData x =
    match data with
    | OnePartData(part1=p1) -> p1
    | TwoPartData(part1=p1; part2=p2) -> p1 + p2

We could have a rule that warns about the former and prefers the latter.

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