haskus / packages

Haskus packages
https://haskus.org/
24 stars 11 forks source link

How to compare 2 EADT values ? #19

Open pcarbonn opened 5 years ago

pcarbonn commented 5 years ago

I'm tring to compare 2 EADT values, but I get:

No instance for (Data.Functor.Classes.Eq1  (VariantF '[ValF, EmptyNoteF]))
    arising from a use of ‘==’
hsyl20 commented 5 years ago

I have added the missing instances (cf 971cfd807cebfecb6091391b7c73c975cebe157e) and released haskus-utils-variant-2.6.1

You have to add Eq1 instances for your functors (ValF, EmptyNoteF) similarly to what I've done in the test here: https://github.com/haskus/packages/commit/971cfd807cebfecb6091391b7c73c975cebe157e#diff-098a4303323c6f5065eca85c4601d802R62

pcarbonn commented 5 years ago

Terrific ! You are a genius.

When I upgrade from 2.4 to 2.6, I get an error message because of AlgVariantF has an extra parameter "r" in the 3rd place since 2.5. Apparently, I have to duplicate the type of the result of the algebra. However, documentation does not seem to be updated.

hsyl20 commented 5 years ago

Thanks for your comment! It forced me to give more thoughts to what we are doing with those algebras. Hence I have completely removed the ad-hoc AlgVariantF/EADT things and replaced them with AlgebraC,Algebras, fromAlgebraC and fromAlgebras as briefly documented here

I have added some EADT tests that also show how to use them.

I still need to update the documentation and to make a release but if you can give me your feedback on this approach beforehand it would be better (less releases on Hackage...). Thanks!

pcarbonn commented 5 years ago

Salut ! I find the approach very interesting, but I fail to see whether the tuple of Algebras could be a limitation. Will it have the flexibility to support the 3 approaches of Constructor removal https://docs.haskus.org/eadt/constructor_removal.html, for example ? I could see it work for fixed-input/fixed-matches, but not for the other cases. Or am I missing something ?

PC

On Tue, Mar 5, 2019 at 5:09 PM Sylvain Henry notifications@github.com wrote:

Thanks for your comment! It forced me to give more thoughts to what we are doing with those algebras. Hence I have completely removed the ad-hoc AlgVariantF/EADT things and replaced them with AlgebraC,Algebras, fromAlgebraC and fromAlgebras as briefly documented here https://github.com/haskus/packages/blob/5f6b5f0b2019442989681bab60b23e1c9d3ebf9b/haskus-utils-variant/src/lib/Haskus/Utils/VariantF.hs#L350

I have added some EADT tests https://github.com/haskus/packages/blob/5f6b5f0b2019442989681bab60b23e1c9d3ebf9b/haskus-utils-variant/src/lib/Haskus/Utils/EADT.hs#L80 that also show how to use them.

I still need to update the documentation and to make a release but if you can give me your feedback on this approach beforehand it would be better (less releases on Hackage...). Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/haskus/packages/issues/19#issuecomment-469739586, or mute the thread https://github.com/notifications/unsubscribe-auth/AAa5aY79A6Xi8Je6MB5mYr0Pg5jZTpJ7ks5vTpbOgaJpZM4bcurQ .