Skip to content

improve generic1Laws #59

Open
Open
@chessai

Description

@chessai
Collaborator

@andrewthad from PR #58:

For the most part, this [PR] looks good. Currently, generic1Laws will be exceeding unpleasant to use since it requires (Eq1 (Rep1 f), Show1 (Rep1 f), Arbitrary1 (Rep1 f)). I think that in this case, for the sake of usability, it is probably better to just nail down the type to something like Bool or Integer:

generic1Laws :: (Generic1 f, Eq (f Bool), Arbitrary (f Bool), Show (f Bool), Eq (Rep1 f Bool), Show (Rep1 f Bool), Arbitrary (Rep1 f Bool)) => proxy f -> Laws

As much as I hate FlexibleContexts, the only other option here would be to add Eq1 and Show1 instances to all the generics machinery in base and then to get Arbitrary1 instances for all the same types added to QuickCheck. This would take a while.

Actually, there's another way that involves replicating all the generics machinery and then writing a type family to marshal from the types in GHC.Generics to the copies of the types in this library. Then, we could have our instances. But this would be miserable.
If this [PR] builds, I think I may go ahead and merge this, and then Generic1's laws function could be worked out on a separate PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @chessai

        Issue actions

          improve generic1Laws · Issue #59 · andrewthad/quickcheck-classes