Skip to content

Proposal: Derive Read instance for Scheme type #1847

@nattybear

Description

@nattybear

Background

Currently, the Scheme type in this package derives Show, but not Read.
As a result, it’s not possible to parse a Scheme value directly from a string using the standard Read interface (e.g. read "Http" :: Scheme).

Proposal

I propose adding a deriving (Read) clause to the Scheme data type, so that users can easily reconstruct Scheme values from textual representations.

Example:

data Scheme = Http | Https
  deriving (Eq, Show, Read)

Rationale

  • Improves consistency with other simple enumerations that derive both Show and Read.
  • Enables convenient usage in debugging, testing, and serialization scenarios.
  • The generated instance will match the existing constructor names ("Http", "Https"), which keeps it predictable.

Alternatives

  • Keep as-is and let users define their own Read instance if needed.
  • Provide a custom parser instead of a Read instance.

Questions for Discussion

  • Would adding deriving (Read) be acceptable given backward compatibility expectations?
  • Should the Read instance be case-sensitive (default) or should we consider a custom, case-insensitive one?

If there’s consensus, I can prepare a small PR adding the Read derivation.

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