Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agda2hs inlines function with explicit forall but not without #376

Open
jespercockx opened this issue Oct 3, 2024 · 1 comment
Open
Labels
bug Something isn't working
Milestone

Comments

@jespercockx
Copy link
Member

Here is a minimal example of the issue reported by @HeinrichApfelmus in #366 (comment):

open import Haskell.Prelude

member :  {a : Set} {{_ : Ord a}}  a  a
member w = w

prune : {{_ : Ord a}}  a  a
prune w = member w

{-# COMPILE AGDA2HS member #-}
{-# COMPILE AGDA2HS prune #-}

This is compiled to

member :: Ord a => a -> a
member w = w

prune :: Ord a => a -> a
prune w = w

However, removing the ∀ {a : Set} from the type of member produces the non-inlined version

prune w = member w

Looking at the debug output, this is actually the fault of agda2hs, not of agda itself:

compiling clause:  <unnamedclause> w = member w
[...]
compiling term: member w
Reached variable
@jespercockx jespercockx added the bug Something isn't working label Oct 3, 2024
@jespercockx
Copy link
Member Author

jespercockx commented Oct 3, 2024

Once again, the culprit is the projection-like optimization: using --no-projection-like makes the problem disappear. So Agda is (partially) to blame after all: why does it recognize member as being projection-like when an explicit quantification is used, but not when a is a generalized variable? (I reported this upstream as agda/agda#7530)

@jespercockx jespercockx added this to the 1.4 milestone Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant