-
Notifications
You must be signed in to change notification settings - Fork 42
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
Levels should not always be erased #357
Comments
Very interesting edge case! What would be the proper way to prevent this though? open import Haskell.Prelude
open import Agda.Primitive using (lzero)
k : a → b → a
k x _ = x
{-# COMPILE AGDA2HS k #-}
l : Level → Nat
l = k 42
{-# COMPILE AGDA2HS l #-}
testK : Nat
testK = l lzero
{-# COMPILE AGDA2HS testK #-} Which would yield: import Numeric.Natural (Natural)
k :: a -> b -> a
k x _ = x
l :: Natural
l = k 42
testK :: Natural
testK = l Seems to me like the only proper fix would be to always compile |
I believe the proper fix here is to decide which arguments to drop based on the uninstantiated type of the function, i.e. when compiling a list of arguments we should decide which arguments to erase based on the type of the function but not on the values of the (previous) arguments. In this case we would then get to actually compiling the |
But if you look at the example I posted with a partial application of a polymorphic function, the term |
Oh you are correct, it would still be a problem. Thinking about it a bit more, the real problem is that the type parameter is instantiated to |
More careful checking of type parameters reveals an issue in our Prelude implementation: the guard : {{ MonadFail m }} → (b : Bool) → m (b ≡ True) However guard : {{ MonadFail m }} → (b : Bool) → m (Erase (b ≡ True)) so its type compiles to the proper |
…fore dropping them
…fore dropping them
…fore dropping them
…fore dropping them
… x)` to `(->)`
The types a and b do not appear in Haskell code, so they should be marked as erased
The interaction of levels and polymorphism pose problems, as demonstrated by the following example:
In the use site we erase the level argument completely, resulting in the wrong number of arguments when applying the polymorphic
k
function:The text was updated successfully, but these errors were encountered: