You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
open importClass.HasHsTypeopen importTactic.Derive.HsTypemoduleIssue.ExamplewheredataX:SetdataY:SetdataXwhereMkX : Y → X
dataYwhereMkY : X → Y
instanceHSTy-X : HasHsType X
HSTy-Y : HasHsType Y
HSTy-X = autoHsType X
HSTy-Y = autoHsType Y
After looking into this with @zahnsimo it appears that fixing this would be quite complicated. There is no awareness of mutually recursive types, so what happens is that first X is encountered, which generates the following type (Note: I'm adding a ' to distinguish from the type we already have, what's being generated is a bit different but equivalent):
dataX':SetwhereMkX' : Y → X'
Y doesn't have a ' here because it doesn't know that a copy of Y should have been mutually defined with X'. This is why data X = MkX (MAlonzo.Code.Class.HasHsType.HasHsType.HsType MAlonzo.Code.Issue.Example.HSTy-Y) is being generated: there is no HSTy-Y yet, so this term doesn't reduce. Then the other type is generated:
dataY':SetwhereMkY' : X' → Y'
Note that this time the type is correct, because now we have a generated type to resolve to. I guess the _ that appears for this on the Haskell is somehow an artefact of the duplicated names (it's part of the name that we get from Agda).
So in the end the real problem is that the types on the Agda side aren't correctly generated in the first place. Fixing this would probably be quite a large refactor where you pass in X and Y simultaneously and some detection of where the mutual invocations are (which would probably be quite brittle). I'm not sure it's worth the effort, especially because you can just provide the HasHsType and the FFI code by hand in this case.
I'm using the branch
upstream-convertible-hstype
.The example
generates
where I would expect
The text was updated successfully, but these errors were encountered: