Skip to content

Surprising behaviour of StandardVersion #848

Closed
@trskop

Description

@trskop

Latest release redefined StandardVersion as:

data StandardVersion
    = NoVersion
    | V_5_0_0
    | V_4_0_0
    | V_3_0_0
    | V_2_0_0
    | V_1_0_0
    deriving (Enum, Bounded)

defaultStandardVersion :: StandardVersion
defaultStandardVersion = NoVersion

Unfortunately, with this definition it is not possible to get latest supported version, of the standard, in a nice way. The dhall command fails victim to this as well:

⊢ dhall version
Haskell package version: 1.21.0
Standard version: none

My first reaction after seeing that there is a Bounded instance available was to use maxBound :: StandardVersion. Unfortunately that doesn't work as expected due to ordering of data constructors:

>>> renderStandardVersion (maxBound :: StandardVersion)
"1.0.0"

These are possible solutions that I came up with:

  1. Reorder data constructors to get expected behaviour from Enum and Bounded instances.
  2. Define Enum and Bounded instances manually.
  3. Introduce latestSupportedStandardVersion :: StandardVersion that would, at the moment, point to V_5_0_0.

I'm happy to help with the implementation as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions