Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deriving Ord #3184

Merged
merged 7 commits into from
Nov 28, 2024
Merged

Deriving Ord #3184

merged 7 commits into from
Nov 28, 2024

Conversation

janmasrovira
Copy link
Collaborator

@janmasrovira janmasrovira commented Nov 21, 2024

Allows automatic derivation of Ord instances. It generates a lexicographical order equivalent to the one defined by Haskell's stock deriving.

@janmasrovira janmasrovira added enhancement New feature or request deriving labels Nov 21, 2024
@janmasrovira janmasrovira self-assigned this Nov 21, 2024
@janmasrovira janmasrovira force-pushed the deriving-ord branch 3 times, most recently from 881b1ef to 123220b Compare November 22, 2024 12:13
@paulcadman paulcadman added this to the 0.6.9 milestone Nov 22, 2024
@janmasrovira janmasrovira marked this pull request as ready for review November 22, 2024 16:52
Copy link
Collaborator

@lukaszcz lukaszcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated function for Ord should directly call itself recursively for recursive constructor arguments instead of implicitly relying on instance resolution to do this (which results in inefficient code later on). So instead of creating a lambda, create a local recursive function with a let and check the type of constructor arguments, like in the PR:

commit 432114c2de274bfb7c20e5d406e50e69ed095559
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Tue Nov 26 16:19:56 2024 +0100

    test086 -> test087

commit 8b3f47b
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Fri Nov 22 17:50:05 2024 +0100

    move

commit 7f97da9
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Fri Nov 22 15:35:19 2024 +0100

    change order of definition

commit 094c6e9
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Fri Nov 22 13:39:14 2024 +0100

    add test

commit 42a3476
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Fri Nov 22 13:13:09 2024 +0100

    refactor

commit b5fe58f
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Fri Nov 22 11:05:24 2024 +0100

    change order of Bool constructors

commit 03210ab
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Fri Nov 22 10:12:17 2024 +0100

    update stdlib

commit 59456df
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Thu Nov 21 19:52:23 2024 +0100

    update stdlib

commit 0f2fae6
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Thu Nov 21 19:42:00 2024 +0100

    decrease clause number

commit 25325bc
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Thu Nov 21 19:28:53 2024 +0100

    improve

commit 6fe818e
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Thu Nov 21 18:53:31 2024 +0100

    fixes

commit 5858b9b
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Thu Nov 21 16:59:39 2024 +0100

    derive ord

commit 6c4db73
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Wed Nov 20 18:05:12 2024 +0100

    wip
@lukaszcz lukaszcz merged commit c64420e into main Nov 28, 2024
4 checks passed
@lukaszcz lukaszcz deleted the deriving-ord branch November 28, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deriving enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants