CompiledRecord.agda 633 B

1234567891011121314151617181920212223242526272829
  1. -- Andreas, 2015-08-18 Test case for COMPILED_DATA on record
  2. -- open import Common.String
  3. open import Common.IO
  4. infixr 4 _,_
  5. infixr 2 _×_
  6. record _×_ (A B : Set) : Set where
  7. constructor _,_
  8. field
  9. proj₁ : A
  10. proj₂ : B
  11. open _×_ public
  12. {-# COMPILE GHC _×_ = data (,) ((,)) #-}
  13. -- Note: could not get this to work for Σ.
  14. -- Also, the universe-polymorphic version of _×_ would require more trickery.
  15. swap : ∀{A B : Set} (p : A × B) → B × A
  16. swap (x , y) = y , x
  17. swap' : ∀{A B : Set} (p : A × B) → B × A
  18. swap' p = proj₂ p , proj₁ p
  19. main = putStrLn (proj₁ (swap (swap' (swap ("no" , "yes")))))