|
| 1 | +module Language.FineTypes.Typ where |
| 2 | + |
| 3 | +{-# FOREIGN AGDA2HS |
| 4 | +-- !!! This Haskell module has been autogenerated by agda2hs. |
| 5 | +-- !!! Do NOT change; change the original .agda file instead. |
| 6 | +#-} |
| 7 | + |
| 8 | +open import Haskell.Prelude |
| 9 | + using (String; List; True; False) |
| 10 | + renaming (_×_ to Pair) |
| 11 | +open import Haskell.Law.Eq |
| 12 | +open import Haskell.Prim.Eq |
| 13 | + |
| 14 | +import Haskell.Prelude as Hs |
| 15 | + |
| 16 | +ConstructorName = String |
| 17 | +FieldName = String |
| 18 | +TypName = String |
| 19 | +VarName = String |
| 20 | + |
| 21 | +{-# COMPILE AGDA2HS ConstructorName #-} |
| 22 | +{-# COMPILE AGDA2HS FieldName #-} |
| 23 | +{-# COMPILE AGDA2HS TypName #-} |
| 24 | +{-# COMPILE AGDA2HS VarName #-} |
| 25 | + |
| 26 | +{----------------------------------------------------------------------------- |
| 27 | + Haskell - Typ |
| 28 | +------------------------------------------------------------------------------} |
| 29 | +data TypConst : Set where |
| 30 | + Bool : TypConst |
| 31 | + Bytes : TypConst |
| 32 | + Integer : TypConst |
| 33 | + Natural : TypConst |
| 34 | + Text : TypConst |
| 35 | + Rational : TypConst |
| 36 | + Unit : TypConst |
| 37 | + |
| 38 | +data OpOne : Set where |
| 39 | + Option : OpOne |
| 40 | + Sequence : OpOne |
| 41 | + PowerSet : OpOne |
| 42 | + |
| 43 | +data OpTwo : Set where |
| 44 | + Sum2 : OpTwo |
| 45 | + Product2 : OpTwo |
| 46 | + PartialFunction : OpTwo |
| 47 | + FiniteSupport : OpTwo |
| 48 | + |
| 49 | +data Constraint1 : Set where |
| 50 | + Braces : List Constraint1 → Constraint1 |
| 51 | + Token : String → Constraint1 |
| 52 | + |
| 53 | +Constraint = List Constraint1 |
| 54 | + |
| 55 | +data Typ : Set where |
| 56 | + Var : TypName → Typ |
| 57 | + Zero : TypConst → Typ |
| 58 | + One : OpOne → Typ → Typ |
| 59 | + Two : OpTwo → Typ → Typ → Typ |
| 60 | + ProductN : List (Pair FieldName Typ) → Typ |
| 61 | + SumN : List (Pair ConstructorName Typ) → Typ |
| 62 | + Constrained : VarName → Typ → Constraint → Typ |
| 63 | + |
| 64 | +{-# COMPILE AGDA2HS TypConst #-} |
| 65 | +{-# COMPILE AGDA2HS OpOne #-} |
| 66 | +{-# COMPILE AGDA2HS OpTwo #-} |
| 67 | +{-# COMPILE AGDA2HS Constraint1 #-} |
| 68 | +{-# COMPILE AGDA2HS Constraint #-} |
| 69 | +{-# COMPILE AGDA2HS Typ #-} |
| 70 | + |
| 71 | +{----------------------------------------------------------------------------- |
| 72 | + Agda - Equality |
| 73 | +------------------------------------------------------------------------------} |
| 74 | +instance |
| 75 | + iTypConst : Eq TypConst |
| 76 | + iTypConst ._==_ Bool Bool = True |
| 77 | + iTypConst ._==_ Bytes Bytes = True |
| 78 | + iTypConst ._==_ Integer Integer = True |
| 79 | + iTypConst ._==_ Natural Natural = True |
| 80 | + iTypConst ._==_ Text Text = True |
| 81 | + iTypConst ._==_ Rational Rational = True |
| 82 | + iTypConst ._==_ Unit Unit = True |
| 83 | + iTypConst ._==_ _ _ = Hs.False |
| 84 | + |
| 85 | +{-# COMPILE AGDA2HS iTypConst derive #-} |
| 86 | + |
| 87 | +-- Created by automati case splitting C^c C^c |
| 88 | +-- and automatic goal finding C^c C^a |
| 89 | +instance |
| 90 | + iLawfulEqTypConst : IsLawfulEq TypConst |
| 91 | + |
| 92 | + iLawfulEqTypConst .isEquality Bool Bool = Hs.ofY Hs.refl |
| 93 | + iLawfulEqTypConst .isEquality Bool Bytes = Hs.ofN (λ ()) |
| 94 | + iLawfulEqTypConst .isEquality Bool Integer = Hs.ofN (λ ()) |
| 95 | + iLawfulEqTypConst .isEquality Bool Natural = Hs.ofN (λ ()) |
| 96 | + iLawfulEqTypConst .isEquality Bool Text = Hs.ofN (λ ()) |
| 97 | + iLawfulEqTypConst .isEquality Bool Rational = Hs.ofN (λ ()) |
| 98 | + iLawfulEqTypConst .isEquality Bool Unit = Hs.ofN (λ ()) |
| 99 | + iLawfulEqTypConst .isEquality Bytes Bool = Hs.ofN (λ ()) |
| 100 | + iLawfulEqTypConst .isEquality Bytes Bytes = Hs.ofY Hs.refl |
| 101 | + iLawfulEqTypConst .isEquality Bytes Integer = Hs.ofN (λ ()) |
| 102 | + iLawfulEqTypConst .isEquality Bytes Natural = Hs.ofN (λ ()) |
| 103 | + iLawfulEqTypConst .isEquality Bytes Text = Hs.ofN (λ ()) |
| 104 | + iLawfulEqTypConst .isEquality Bytes Rational = Hs.ofN (λ ()) |
| 105 | + iLawfulEqTypConst .isEquality Bytes Unit = Hs.ofN (λ ()) |
| 106 | + iLawfulEqTypConst .isEquality Integer Bool = Hs.ofN (λ ()) |
| 107 | + iLawfulEqTypConst .isEquality Integer Bytes = Hs.ofN (λ ()) |
| 108 | + iLawfulEqTypConst .isEquality Integer Integer = Hs.ofY Hs.refl |
| 109 | + iLawfulEqTypConst .isEquality Integer Natural = Hs.ofN (λ ()) |
| 110 | + iLawfulEqTypConst .isEquality Integer Text = Hs.ofN (λ ()) |
| 111 | + iLawfulEqTypConst .isEquality Integer Rational = Hs.ofN (λ ()) |
| 112 | + iLawfulEqTypConst .isEquality Integer Unit = Hs.ofN (λ ()) |
| 113 | + iLawfulEqTypConst .isEquality Natural Bool = Hs.ofN (λ ()) |
| 114 | + iLawfulEqTypConst .isEquality Natural Bytes = Hs.ofN (λ ()) |
| 115 | + iLawfulEqTypConst .isEquality Natural Integer = Hs.ofN (λ ()) |
| 116 | + iLawfulEqTypConst .isEquality Natural Natural = Hs.ofY Hs.refl |
| 117 | + iLawfulEqTypConst .isEquality Natural Text = Hs.ofN (λ ()) |
| 118 | + iLawfulEqTypConst .isEquality Natural Rational = Hs.ofN (λ ()) |
| 119 | + iLawfulEqTypConst .isEquality Natural Unit = Hs.ofN (λ ()) |
| 120 | + iLawfulEqTypConst .isEquality Text Bool = Hs.ofN (λ ()) |
| 121 | + iLawfulEqTypConst .isEquality Text Bytes = Hs.ofN (λ ()) |
| 122 | + iLawfulEqTypConst .isEquality Text Integer = Hs.ofN (λ ()) |
| 123 | + iLawfulEqTypConst .isEquality Text Natural = Hs.ofN (λ ()) |
| 124 | + iLawfulEqTypConst .isEquality Text Text = Hs.ofY Hs.refl |
| 125 | + iLawfulEqTypConst .isEquality Text Rational = Hs.ofN (λ ()) |
| 126 | + iLawfulEqTypConst .isEquality Text Unit = Hs.ofN (λ ()) |
| 127 | + iLawfulEqTypConst .isEquality Rational Bool = Hs.ofN (λ ()) |
| 128 | + iLawfulEqTypConst .isEquality Rational Bytes = Hs.ofN (λ ()) |
| 129 | + iLawfulEqTypConst .isEquality Rational Integer = Hs.ofN (λ ()) |
| 130 | + iLawfulEqTypConst .isEquality Rational Natural = Hs.ofN (λ ()) |
| 131 | + iLawfulEqTypConst .isEquality Rational Text = Hs.ofN (λ ()) |
| 132 | + iLawfulEqTypConst .isEquality Rational Rational = Hs.ofY Hs.refl |
| 133 | + iLawfulEqTypConst .isEquality Rational Unit = Hs.ofN (λ ()) |
| 134 | + iLawfulEqTypConst .isEquality Unit Bool = Hs.ofN (λ ()) |
| 135 | + iLawfulEqTypConst .isEquality Unit Bytes = Hs.ofN (λ ()) |
| 136 | + iLawfulEqTypConst .isEquality Unit Integer = Hs.ofN (λ ()) |
| 137 | + iLawfulEqTypConst .isEquality Unit Natural = Hs.ofN (λ ()) |
| 138 | + iLawfulEqTypConst .isEquality Unit Text = Hs.ofN (λ ()) |
| 139 | + iLawfulEqTypConst .isEquality Unit Rational = Hs.ofN (λ ()) |
| 140 | + iLawfulEqTypConst .isEquality Unit Unit = Hs.ofY Hs.refl |
| 141 | + |
| 142 | +{----------------------------------------------------------------------------- |
| 143 | + Agda - Syntactic sugar |
| 144 | +------------------------------------------------------------------------------} |
| 145 | +_×_ : Typ → Typ → Typ |
| 146 | +A × B = Two Product2 A B |
| 147 | + |
| 148 | +_+_ : Typ → Typ → Typ |
| 149 | +A + B = Two Sum2 A B |
0 commit comments