Skip to content

Instantly share code, notes, and snippets.

@TOTBWF
Created October 4, 2022 22:42
Show Gist options
  • Save TOTBWF/0ea18b7393384d6f6ee78ec7dc3b217b to your computer and use it in GitHub Desktop.
Save TOTBWF/0ea18b7393384d6f6ee78ec7dc3b217b to your computer and use it in GitHub Desktop.
A simple Agda tactic that just uses the first valid thing in scope.
module 1Lab.Reflection.Duh where
open import 1Lab.Reflection
open import 1Lab.Prelude
open import Data.List
open import Data.Nat
private
try-all : Term → Nat → Telescope → TC Term
try-all goal _ [] = typeError $ strErr "Couldn't find anything!" ∷ []
try-all goal n ((_ , tp) ∷ tele) =
catchTC (unify goal (Arg.unarg tp) >> pure (var n [])) (try-all goal (suc n) tele)
macro
duh! : Term → TC ⊤
duh! hole = do
ctx ← getContext
goal ← inferType hole
tm ← try-all goal 0 ctx
unify hole tm
test : Nat → List Nat → Nat
test x y = duh!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment