Skip to content

Instantly share code, notes, and snippets.

@larrytheliquid
Last active October 26, 2017 23:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save larrytheliquid/079e6c3f182587bb3ea931ea0d406533 to your computer and use it in GitHub Desktop.
Save larrytheliquid/079e6c3f182587bb3ea931ea0d406533 to your computer and use it in GitHub Desktop.
module Weed where
data ⊥ : Set where
magic : {A : Set} → ⊥ → A
magic ()
data Weed (A : Set) : Set where
grow : (A → Weed A) → Weed A
smoke : {A : Set} (P : Weed A → Set)
(p : (f : A → Weed A) (ih : (a : A) → P (f a)) → P (grow f))
(w : Weed A) → P w
smoke P p (grow f) = p f λ a → smoke P p (f a)
smokeout : {A : Set} → A → Weed A → ⊥
smokeout a = smoke _ λ f ih → ih a
weed-is-magic : {A B : Set} → A → Weed A → B
weed-is-magic a w = magic (smokeout a w)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment