module Examples where import AST import qualified Language as L sumSq :: Exp env (Array (Int, ()) Double -> Double) sumSq = Lam (TArray (STC STZ) TDouble) (L.sum (App mapSq (Var (TArray (STC STZ) TDouble) Zero))) mapSq :: Exp env (Array (Int, ()) Double -> Array (Int, ()) Double) mapSq = Lam (TArray (STC STZ) TDouble) (L.map (Lam TDouble (App (Const CMulF) (Pair (Var TDouble Zero) (Var TDouble Zero)))) (Var (TArray (STC STZ) TDouble) Zero)) mapSqIota :: Exp env (Array (Int, ()) Double) mapSqIota = L.map (Lam TDouble (App (Const CMulF) (Pair (Var TDouble Zero) (Var TDouble Zero)))) (Build (STC STZ) (Pair (Lit (LInt 5)) (Lit LNil)) (Lam (TPair TInt TNil) (App (Const CtoF) (Fst (Var (TPair TInt TNil) Zero)))))