| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- The Pair type which calls out to Haskell via the FFI |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible #-} |
| 8 |
|
| 9 |
module Foreign.Haskell.Pair where |
| 10 |
|
| 11 |
open import Level using (Level; _⊔_) |
| 12 |
open import Data.Product.Base using (_×_; _,_) |
| 13 |
|
| 14 |
private |
| 15 |
variable |
| 16 |
a b : Level |
| 17 |
A : Set a |
| 18 |
B : Set b |
| 19 |
|
| 20 |
------------------------------------------------------------------------ |
| 21 |
-- Definition |
| 22 |
|
| 23 |
record Pair (A : Set a) (B : Set b) : Set (a ⊔ b) where |
| 24 |
constructor _,_ |
| 25 |
field fst : A |
| 26 |
snd : B |
| 27 |
infixr 4 _,_ |
| 28 |
open Pair public |
| 29 |
|
| 30 |
{-# FOREIGN GHC type AgdaPair l1 l2 a b = (a , b) #-} |
| 31 |
{-# COMPILE GHC Pair = data MAlonzo.Code.Foreign.Haskell.Pair.AgdaPair ((,)) #-} |
| 32 |
|
| 33 |
------------------------------------------------------------------------ |
| 34 |
-- Conversion |
| 35 |
|
| 36 |
toForeign : A × B → Pair A B |
| 37 |
toForeign (a , b) = (a , b) |
| 38 |
{-# WARNING_ON_USAGE toForeign |
| 39 |
"Warning: toForeign was deprecated in 2.0. |
| 40 |
Please use Foreign.Haskell.Coerce.coerce instead." |
| 41 |
#-} |
| 42 |
|
| 43 |
fromForeign : Pair A B → A × B |
| 44 |
fromForeign (a , b) = (a , b) |
| 45 |
{-# WARNING_ON_USAGE fromForeign |
| 46 |
"Warning: fromForeign was deprecated in 2.0. |
| 47 |
Please use Foreign.Haskell.Coerce.coerce instead." |
| 48 |
#-} |