Trees that Grow and constraints
Alan & Kim Zimmerman
alan.zimm at gmail.com
Mon Nov 13 09:23:36 UTC 2017
At the moment the Trees that Grow implementation in GHC master makes use of
massive constraint types to provide Data instances for the hsSyn AST.
I am trying to remove the need for this, and have hit a problem.
The example I have reduced it to is here [1]
The essence of the problem is
-------------------
data Experiment p
= Experiment {
e_ext :: (XEOverLit p),
e_val :: Int }
| XExperiment (XXOverLit p)
deriving instance (Data (GhcPass p)) => Data (Experiment (GhcPass p))
type family XEOverLit x
type family XXOverLit x
-- The following line works
-- type instance XEOverLit (GhcPass _) = PlaceHolder
-- The following 3 lines do noe
type instance XEOverLit (GhcPass 'Parsed ) = PlaceHolder
type instance XEOverLit (GhcPass 'Renamed ) = PlaceHolder
type instance XEOverLit (GhcPass 'Typechecked) = PlaceHolder
type instance XXOverLit (GhcPass _) = PlaceHolder
-------------------
Where specifying the type instance with a wild card keeps GHC happy (the
XXOverLit case), but specifying for each of the three constructors for pass
does not (the XEOverLit case)
The exact error message is
------------------------------
Experiment.hs:34:1: error:
• Could not deduce (Data (XEOverLit (GhcPass p)))
arising from a use of ‘k’
from the context: Data (GhcPass p)
bound by the instance declaration at Experiment.hs:34:1-69
• In the first argument of ‘k’, namely ‘(z Experiment `k` a1)’
In the expression: ((z Experiment `k` a1) `k` a2)
In an equation for ‘gfoldl’:
gfoldl k z Experiment a1 a2 = ((z Experiment `k` a1) `k` a2)
When typechecking the code for ‘gfoldl’
in a derived instance for ‘Data (Experiment (GhcPass p))’:
To see the code I am typechecking, use -ddump-deriv
|
34 | deriving instance (Data (GhcPass p)) => Data (Experiment (GhcPass p))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
------------------------------
Alan
[1] http://lpaste.net/360017
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20171113/c703f249/attachment.html>
More information about the ghc-devs
mailing list