NonRecursiveCoinductiveRecord.agda 956 B

123456789101112131415161718192021222324252627
  1. -- Andreas, 2014-04-23 test case by Andrea Vezzosi
  2. {-# OPTIONS --sized-types --copatterns #-}
  3. -- {-# OPTIONS --show-implicit -v term:60 #-}
  4. module _ where
  5. open import Common.Size
  6. -- Invalid coinductive record, since not recursive.
  7. record ▸ (A : Size → Set) (i : Size) : Set where
  8. coinductive -- This should be an error, since non-recursive.
  9. constructor delay_
  10. field
  11. force : ∀ {j : Size< i} → A j
  12. open ▸
  13. -- This fixed-point combinator should not pass the termination checker.
  14. ∞fix : ∀ {A : Size → Set} → (∀ {i} → ▸ A i → A i) → ∀ {i} → ▸ A i
  15. force (∞fix {A} f {i}) {j} = f {j} (∞fix {A} f {j})
  16. -- The following fixed-point combinator is not strongly normalizing!
  17. fix : ∀ {A : Size → Set} → (∀ {i} → (∀ {j : Size< i} → A j) → A i) → ∀ {i} {j : Size< i} → A j
  18. fix f = force (∞fix (λ {i} x → f {i} (force x)))
  19. -- test = fix {!!}
  20. -- C-c C-n test gives me a stack overflow