2020-06-11 22:30:16 +03:00
|
|
|
import Data.Nat
|
|
|
|
import Data.Vect
|
2020-06-01 17:01:52 +03:00
|
|
|
import Language.Reflection
|
|
|
|
|
|
|
|
%language ElabReflection
|
|
|
|
|
2020-08-07 03:58:02 +03:00
|
|
|
fc : FC
|
|
|
|
fc = EmptyFC
|
|
|
|
|
|
|
|
quoteTest : TTImp -> TTImp -> List Decl
|
|
|
|
quoteTest f arg = `[ myFunc : ~(IApp fc f arg) ]
|
|
|
|
|
2020-06-11 22:30:16 +03:00
|
|
|
axes : (n : Nat) -> {auto gt : GT n 0} -> {auto lte : LTE n 4} -> Vect n String
|
|
|
|
axes 1 = ["x"]
|
|
|
|
axes 2 = "y" :: axes 1
|
|
|
|
axes 3 = "z" :: axes 2
|
|
|
|
axes 4 = "w" :: axes 3
|
2021-02-22 12:53:30 +03:00
|
|
|
axes (S (S (S (S (S _))))) {lte} = absurd lte
|
2020-06-11 22:30:16 +03:00
|
|
|
|
|
|
|
mkPoint : (n : Nat) -> {auto gt : GT n 0} -> {auto lte : LTE n 4} -> Decl
|
|
|
|
mkPoint n
|
|
|
|
= let type = "Point" ++ show n ++ "D" in
|
2021-09-15 15:20:58 +03:00
|
|
|
let mkMainUN = NS (MkNS ["Main"]) . UN . Basic in
|
2021-12-08 19:08:26 +03:00
|
|
|
IRecord emptyFC Nothing Public Nothing
|
2021-09-15 15:20:58 +03:00
|
|
|
(MkRecord emptyFC (mkMainUN type) [] (mkMainUN ("Mk" ++ type))
|
|
|
|
(toList $ map (\axis => MkIField emptyFC MW ExplicitArg (UN (Field axis)) `(Double)) (axes n)))
|
2020-06-11 22:30:16 +03:00
|
|
|
|
2020-06-03 00:41:37 +03:00
|
|
|
logDecls : TTImp -> Elab (Int -> Int)
|
2020-06-01 17:01:52 +03:00
|
|
|
logDecls v
|
|
|
|
= do declare [IClaim EmptyFC MW Public []
|
2021-01-12 15:23:28 +03:00
|
|
|
(MkTy EmptyFC EmptyFC `{ Main.foo }
|
2020-06-01 17:01:52 +03:00
|
|
|
`(Int -> Int -> Int) )]
|
|
|
|
|
|
|
|
declare `[ foo x y = x + y ]
|
|
|
|
|
2020-06-11 22:30:16 +03:00
|
|
|
declare [ mkPoint 3 ]
|
|
|
|
|
2020-06-01 17:01:52 +03:00
|
|
|
declare `[ multBy : Int -> Int
|
|
|
|
multBy x = x * ~(v) ]
|
|
|
|
declare `[ myplus : Nat -> Nat -> Nat
|
|
|
|
myplus Z y = y
|
|
|
|
myplus (S k) y = S (myplus k y) ]
|
|
|
|
check `( multBy )
|
|
|
|
|
|
|
|
mkMult : Int -> Int
|
|
|
|
mkMult = %runElab logDecls `(4)
|
2020-06-11 22:30:16 +03:00
|
|
|
|
|
|
|
point : Point3D
|
|
|
|
point = MkPoint3D 1.0 2.0 3.0
|