Closed rachelambda closed 2 years ago
It would seem that (to no ones surprise) solving this problem is harder than it first seemed, due to having to add parameters all over the agda backend to keep track of if the functor options is enabled and having to find some way to "intelligently" parameterize all types from categories correctly. I'm giving up on my own attempts.
I think this isn't too hard to get to work.
(Maybe I originally abstained from implementing --functor
for --agda
since Agda did not have Agda.Builtin.Maybe
then, which is needed to implement BNFC'Position
. On the other hand, tuples are also needed and I added them manually... Maybe I just postponed --functor
.)
On the Agda side, we could have:
data Exp' (A : Set) : Set where
int : (a : A) (x : Integer) → Exp' A
BNFC'Position = Maybe (Pair Nat Nat)
Exp = Exp' BNFC'Position
This would limit polymorphism to level 0, but bind directly to the code that the Haskell backend produces.
While the PR you opened would close this particular issue, perhaps it would be nice to keep track of what features can and cannot be used simultaneously? It would be much nicer for BNFC to state that the combination is not supported than to discover later down the line, as was the case here.
Using the
--functor
flag and the--agda
flag simultaneously generates code which passes the agda typechecker but fails to compile. Here is a very simple example:Running make yield the following type errors:
Looking at
ASTTest.agda
andAbsTest.hs
we can see the issue:All that really needs to be done is to parameterize the agda datatype, provide a translation of
BNFC'Position
inASTTest.agda
, correct the type signatures of agda functions handling the AST (and thereby also adding a dummy lambda to the COMPILE pragma because of the new implicit argument).I'm currently looking into the codebase to see if I'd be able to fix this myself.