Closed ndmitchell closed 7 years ago
There is a branch here: https://github.com/ndmitchell/derive/tree/hse-1.18
It doesn't work, but I certainly did a lot of the conversion.
I finished the conversion but I'm not completely sure it's 100% correct. Do you have regression tests?
In .ghci
if you type :test
it will run:
:main --generate
:reload
:main --test
That's the regression tests.
I get:
*Main> :test
[20 of 25] Compiling Data.Derive.All ( src/Data/Derive/All.hs, interpreted )
src/Data/Derive/All.hs:9:16:
Not in scope: ‘make’
Perhaps you meant ‘take’ (imported from Prelude)
Did I accidentally mess up the tests? I don't understand how the tests are supposed to work.
Can you try running the tests with the HEAD version, or the last released version, so you can see how they are meant to work? That should give us a clue as to whether you are running the test wrong, or in the conversion something has broken which was not yet visible due to other changes.
Can't even successfully run the tests for 2.5.26 with hse-1.17.1
*Main> :test
Generating Arbitrary
[snip]
Testing Arbitrary
[snip]
Type checking examples
src/Language/Haskell.hs:288:31:
Ambiguous occurrence ‘FieldDecl’
It could refer to either ‘Language.Haskell.FieldDecl’,
defined at src/Language/Haskell.hs:210:1
or ‘Language.Haskell.Exts.FieldDecl’,
imported from ‘Language.Haskell.Exts’ at src/Language/Haskell.hs:4:1-57
(and originally defined in ‘Language.Haskell.Exts.Syntax’)
*** Exception: Failed to typecheck results
Ah, I see something weird. In this patch, "#19, start moving to haskell-src-exts", you add takeBaseName x == "Data"
to the test filter. That expression is always false and no tests should be generated. That's then combined with a bug that generates invalid code when there are no tests.
I fixed the test generator code and each test checks out OK. I hope that means it works. :)
Thank you @Lemmih :)
This is now a blocker for using GHC 8.0.2 / LTS 8
The lack of support for haskell-src-exts 1.18.x also blocks openSUSE from distributing this package since we're following LTS 8.x, too. Right now, the build fails (https://build.opensuse.org/package/show/devel:languages:haskell/derive), but at some point we'll have to remove derive from the package set.
Sorry for the radio silence for some time. I'll endeavour to take a look at this over the weekend and see what I can do.
So much appreciated @ndmitchell
I've uploaded Derive 2.6, mainly thanks to the work of @Lemmih. Can people check it works - the whole package is in a bit of a state (it needs a lot of love applying to it), so I'm no longer as confident the tests mirror real-world usage as I used to be.
I noticed that the bounds were too tight to allow HSE 1.19 so have relaxed them. Can someone confirm it works? And let me know if it needs re-adding to Stackage? Ideally if it were readded it would be by someone other than me :)
@ndmitchell in following line I get
Pos/Data/Attributes.hs:1:1: error:
Exception when trying to run compile-time code:
Could not convert Decl () to Dec
InstDecl () Nothing (IRule () Nothing (Just (CxTuple () [ClassA () (UnQual () (Ident () "NFData")) [TyVar () (Ident () "h_6989586621679297913")]])) (IHApp () (IHCon () (UnQual () (Ident () "NFData"))) (TyParen () (TyApp () (TyCon () (UnQual () (Ident () "Attributes"))) (TyVar () (Ident () "h_6989586621679297913")))))) (Just [InsDecl () (FunBind () [Match () (Ident () "rnf") [PParen () (PApp () (UnQual () (Ident () "Attributes")) [PVar () (Ident () "x1"),PVar () (Ident () "x2")])] (UnGuardedRhs () (InfixApp () (App () (Var () (UnQual () (Ident () "rnf"))) (Var () (UnQual () (Ident () "x1")))) (QVarOp () (UnQual () (Ident () "seq"))) (InfixApp () (App () (Var () (UnQual () (Ident () "rnf"))) (Var () (UnQual () (Ident () "x2")))) (QVarOp () (UnQual () (Ident () "seq"))) (Con () (Special () (UnitCon ())))))) Nothing])])
src/Language/Haskell/Convert.hs:(124,5)-(132,57): Non-exhaustive patterns in function conv
CallStack (from HasCallStack):
error, called at src/Language/Haskell/Convert.hs:21:87 in derive-2.6.1-Fni1nm1Ws9IAIfnzevXAvI:Language.Haskell.Convert
Code: derive makeNFData ''Attributes
@domenkozar I've released 2.6.2 which hopefully fixes that issue.
@ndmitchell thanks, that works :)
OK, happy for someone to submit this to Stackage, but in doing so, they are taking over at least co-maintainership!
I started work on this but it is not yet complete. I expect there are a few more hours work required.
src.zip