@@ -214,9 +214,24 @@ convertBranches r BsNil bp = return CBranchesNil
214214convertBranches r (BsCons bsh bst) bp =
215215 caseBsCons bp (λ where bph bpt ⦃ refl ⦄ →
216216 CBranchesCons <$> convertBranch r bsh bph <*> convertBranches r bst bpt)
217-
218217{-# COMPILE AGDA2HS convertBranches #-}
219218
219+ convertEtaGeneric : ⦃ fl : Fuel ⦄
220+ → Singleton α
221+ → (@0 x : Name)
222+ → (f : Term α)
223+ → (b : Term (α ▸ x))
224+ → TCM (b ≅ (TApp (weakenTerm _ f) (TVar (VZero x))))
225+ convertEtaGeneric r x f b = do
226+ let
227+ subsetProof = subWeaken subRefl
228+ newScope = singBind r
229+ term = TApp (weakenTerm subsetProof f)
230+ (TVar (VZero x))
231+ convertCheck newScope b term
232+ {-# COMPILE AGDA2HS convertEtaGeneric #-}
233+
234+
220235convertWhnf : ⦃ fl : Fuel ⦄ → Singleton α → (t q : Term α) → TCM (t ≅ q)
221236convertWhnf r (TVar x) (TVar y) = convVars x y
222237convertWhnf r (TDef x) (TDef y) = convDefs x y
@@ -231,19 +246,14 @@ convertWhnf r (TPi x tu tv) (TPi y tw tz) = convPis r x y tu tw tv tz
231246convertWhnf r (TSort s) (TSort t) = convSorts s t
232247--let and ann shouldn't appear here since they get reduced away
233248convertWhnf r functionTerm (TLam x b) =
234- let
235- subsetProof = (subWeaken subRefl)
236- newScope = singBind r
237- term = TApp (weakenTerm subsetProof functionTerm) (TVar (VZero x))
238- in
239249 do
240- conversionProof <- convertCheck newScope b term
241- return (CEtaFunctions x functionTerm b conversionProof)
242- convertWhnf r a b = do
243- conversionProof <- convertCheck r b a
244- return (CSym conversionProof)
245- -- convertWhnf r (TLam x v) (TVar x') = tcError "implement eta-functions 2"
246- -- convertWhnf r (TApp _ _) (TLam _ _) = tcError "implement eta-functions 3 "
250+ conversionProof <- convertEtaGeneric r x functionTerm b
251+ return (CEtaFunctionsLeft x functionTerm b conversionProof)
252+ convertWhnf r (TLam x b) functionTerm =
253+ do
254+ conversionProof <- convertEtaGeneric r x functionTerm b
255+ return (CEtaFunctionsRight x functionTerm b conversionProof)
256+ convertWhnf r _ _ = tcError "two terms are not the same and aren't convertible "
247257
248258{-# COMPILE AGDA2HS convertWhnf #-}
249259
0 commit comments