Skip to content

Instantly share code, notes, and snippets.

@jcaesar
Created November 26, 2020 02:45
Show Gist options
  • Select an option

  • Save jcaesar/d20d79e706660ccf3b7e3cb7130a318c to your computer and use it in GitHub Desktop.

Select an option

Save jcaesar/d20d79e706660ccf3b7e3cb7130a318c to your computer and use it in GitHub Desktop.
let Expr
: Type → Type
= λ(A : Type) →
∀(Expr : Type → Type) →
∀(If : { cond : Text, thenE : Expr A, elseE : Expr A } → Expr A) →
∀(Ref : Text → Expr A) →
∀(Lit : A → Expr A) →
Expr A
let example
: Expr Natural
= λ(Expr : Type → Type) →
λ ( If
: { cond : Text, thenE : Expr Natural, elseE : Expr Natural } →
Expr Natural
) →
λ(Ref : Text → Expr Natural) →
λ(Lit : Natural → Expr Natural) →
If { cond = "asdf", thenE = Ref "bsdf", elseE = Lit 42 }
let atoms =
λ(A : Type) →
λ(expr : Expr A) →
expr
(λ(ignored : Type) → List Text)
( λ(If : { cond : Text, thenE : List Text, elseE : List Text }) →
[ If.cond ] # If.thenE # If.elseE
)
(λ(Ref : Text) → [ Ref ])
(λ(Lit : A) → [] : List Text)
in atoms Natural example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment