Skip to content

Inconsistent behavior of enumFromTo for bounded enums #15

Closed
@sharkdp

Description

@sharkdp

With the canonical Enum instance for the following data type

data T = A | B | C | D

I get:

> enumFromTo A A :: Array T
[A]
> enumFromTo A B :: Array T
[A,B]
> enumFromTo A C :: Array T
[A,B,C]
> enumFromTo A D :: Array T
[A,B,C]

The last one returns a wrong result with the current implementation for enumFromTo because the unfoldr-function calls succ D, which short-circuits in the Maybe monad and breaks the unfoldr 'loop'.

Note: this only fails for bounded Enums

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