Idris2/tests/idris2/reflection002/power.idr
Edwin Brady 2a75731916 In reflection, check now takes a concrete type
So the type of Elab now gives the expected type that's being elaborated
to, meaning that we can run 'check' in the middle of scripts and use the
result.
2020-06-02 22:41:37 +01:00

15 lines
252 B
Idris

import Language.Reflection
%language ElabReflection
powerFn : Nat -> TTImp
powerFn Z = `(const 1)
powerFn (S k) = `(\x => mult x (~(powerFn k) x))
%macro
power : Nat -> Elab (Nat -> Nat)
power n = check (powerFn n)
cube : Nat -> Nat
cube = power 3