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

Stock Eq instances have changed #55

Open
Lysxia opened this issue May 12, 2022 · 5 comments
Open

Stock Eq instances have changed #55

Lysxia opened this issue May 12, 2022 · 5 comments
Labels
question Further information is requested

Comments

@Lysxia
Copy link
Owner

Lysxia commented May 12, 2022

They now use dataToTag#... https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6955

@Lysxia Lysxia added the question Further information is requested label May 12, 2022
@Lysxia
Copy link
Owner Author

Lysxia commented May 12, 2022

I think I want to change the generic implementation to match it...

@pwm
Copy link

pwm commented Nov 10, 2024

Does this issue cause the following?

data Foo a = Bar [a] [a]
  deriving stock (Eq, Generic1)
  deriving Eq1 via (Generically1 Foo)

leads to

No instance for ‘Eq1
                     (GHC.Generics.D1
...
arising from the 'deriving' clause of a data type declaration
  Possible fix:
    use a standalone 'deriving instance' declaration,
      so you can specify the instance context yourself
• When deriving the instance for (Eq1 Foo)typecheck(-Wdeferred-type-errors)

@Lysxia
Copy link
Owner Author

Lysxia commented Nov 11, 2024

Try importing Generic.Data.Orphans.

@pwm
Copy link

pwm commented Nov 11, 2024

That solved it, thank you.

Out of curiosity: is there any pros/cons using Generic.Data vs. say Data.Functor.Classes.Generic?

Say I have:

data Expr a
  = Var String
  | Lam String a
  | App a a
  deriving stock (Eq, Ord, Show, Functor, Foldable, Traversable, Generic1)

then I can either do

instance Eq1 Expr where
  liftEq = liftEqDefault

instance Ord1 Expr where
  liftCompare = liftCompareDefault

instance Show1 Expr where
  liftShowsPrec = liftShowsPrecDefault

or

deriving (Eq1, Ord1, Show1) via (Generically1 Expr)

the latter is nice for brevity but I don't know if there are any other differences one should be aware of?

@Lysxia
Copy link
Owner Author

Lysxia commented Nov 12, 2024

I'm assuming you mean Data.Functor.Classes.Generic from transformers-compat. As far as I can tell these are equivalent. Note that with the upcoming GHC 9.12 you will be able to do deriving via for Eq1 and others directly without dependencies outside of base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants