{-# OPTIONS --safe --with-K #-}
module Examples.WithMacros.Acc where
open import Prelude hiding (lookupAny)
open import Generics.Description
open import Generics.Recursion
open import Generics.Reflection
open import Generics.RecursionScheme
open import Generics.SimpleContainer
open import Generics.SimpleContainer.Any
data Acc {A : Set ℓ} (R : A → A → Set ℓ') : A → Set (ℓ ⊔ ℓ') where
acc : {x : A} → ((y : A) → R y x → Acc R y) → Acc R x
instance
AccC : Named (quote Acc) _
unNamed AccC = genDataC AccD (genDataT AccD Acc)
where AccD = genDataD Acc
private
foldAccP : FoldP
foldAccP = fold-operator (quote Acc)
unquoteDecl foldAcc = defineFold foldAccP foldAcc
instance foldAccC = genFoldC foldAccP foldAcc
instance
AccS : SCᵈ (findDataD (quote Acc))
AccS = record
{ El = λ (A , _) → A
; pos = (true ∷ tt ∷ []) ∷ []
; coe = λ _ → (refl ,ωω λ _ → lift tt) ,ωω lift tt }
private
AccAnyD : DataD
AccAnyD = AnyD (quote Acc)
unquoteDecl data AccAny constructor here there = defineByDataD AccAnyD AccAny (AccAny.here ∷ AccAny.there ∷ [])
instance
AccAnyC : Named (quote AccAny) _
unNamed AccAnyC = genDataC AccAnyD AccAnyT
where AccAnyT = genDataT AccAnyD AccAny
private
lookupAnyAccP : FoldP
lookupAnyAccP = lookupAny (quote Acc)
unquoteDecl lookupAnyAcc = defineFold lookupAnyAccP lookupAnyAcc
instance lookupAnyAccC = genFoldC lookupAnyAccP lookupAnyAcc