| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Reflection utilities |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Reflection.TCM.Utilities where |
| 10 |
|
| 11 |
open import Data.List using (List; []; _∷_; _++_; map) |
| 12 |
open import Data.Unit using (⊤; tt) |
| 13 |
open import Effect.Applicative using (RawApplicative; mkRawApplicative) |
| 14 |
open import Function.Base using (case_of_) |
| 15 |
open import Reflection.AST.Meta using (Meta) |
| 16 |
open import Reflection.AST.Term using (Term) |
| 17 |
open import Reflection.TCM using (TC; pure; blockTC; blockerAll; blockerMeta) |
| 18 |
|
| 19 |
import Reflection.AST.Traversal as Traversal |
| 20 |
|
| 21 |
blockOnMetas : Term → TC ⊤ |
| 22 |
blockOnMetas t = |
| 23 |
case traverseTerm actions (0 , []) t of λ where |
| 24 |
[] → pure tt |
| 25 |
xs@(_ ∷ _) → blockTC (blockerAll (map blockerMeta xs)) |
| 26 |
where |
| 27 |
applicative : ∀ {ℓ} → RawApplicative {ℓ} (λ _ → List Meta) |
| 28 |
applicative = mkRawApplicative (λ _ → List Meta) (λ _ → []) _++_ |
| 29 |
|
| 30 |
open Traversal applicative |
| 31 |
|
| 32 |
actions : Actions |
| 33 |
actions = record defaultActions { onMeta = λ _ x → x ∷ [] } |