Issue4168-shirr.agda 804 B

12345678910111213141516171819202122232425262728293031323334353637
  1. -- Andreas, 2019-11-06 issue #4168, version with shape-irrelevance.
  2. -- Eta-contraction of records with all-irrelevant fields is unsound.
  3. -- In this case, it lead to a compilation error.
  4. {-# OPTIONS --irrelevant-projections #-}
  5. -- {-# OPTIONS -v tc.cc:20 #-}
  6. open import Agda.Builtin.Unit
  7. open import Common.IO using (IO; return)
  8. main : IO ⊤
  9. main = return _
  10. record Box (A : Set) : Set where
  11. constructor box
  12. field
  13. ..unbox : A
  14. open Box
  15. record R (M : Set → Set) : Set₁ where
  16. field
  17. bind : (A B : Set) → M A → (A → M B) → M B
  18. open R
  19. works : R Box
  20. works .bind A B x g .unbox = unbox (g (unbox x))
  21. test : R Box
  22. test .bind A B x g = box (unbox (g (unbox x)))
  23. -- WAS eta-contracted to: test .bind A B x g = g (unbox x)
  24. -- crashing compilation.
  25. -- Compilation should succeed.