HOAny.agda 914 B

12345678910111213141516171819202122232425262728293031323334353637
  1. module HOAny where
  2. open import Agda.Builtin.Nat
  3. open import Agda.Builtin.Bool
  4. data Wrapper (M : Set → Set) : Set where
  5. mnat : M Nat → Wrapper M
  6. mbool : M Bool → Wrapper M
  7. {-# FOREIGN GHC data AgdaWrapper m = Mnat (m Integer) | Mbool (m Bool) #-}
  8. {-# COMPILE GHC Wrapper = data AgdaWrapper (Mnat | Mbool) #-}
  9. map : ∀ {M N} → (∀ {n} → M n → N n) → Wrapper M → Wrapper N
  10. map f (mnat mn) = mnat (f mn)
  11. map f (mbool mb) = mbool (f mb)
  12. -- Higher-order use of Any in the compiled code:
  13. -- data AgdaWrapper m = Mnat (m Integer) | Mbool (m Bool)
  14. -- map ::
  15. -- (() -> ()) ->
  16. -- (() -> ()) ->
  17. -- (() -> AgdaAny -> AgdaAny) -> AgdaWrapper AgdaAny -> AgdaWrapper AgdaAny
  18. -- WAS:
  19. -- The expected kind to AgdaWrapper's argument is * -> *
  20. -- but AgdaAny's kind is *
  21. -- WANT: SUCCESS
  22. -- made possible by making AgdaAny poly-kinded
  23. open import Common.Prelude
  24. main : IO Unit
  25. main = putStrLn ""