module Examples where import AST import qualified Language as L sumSq :: Exp env (Array L.DIM1 Double -> Double) sumSq = Lam (TArray (STC STZ) TDouble) (L.sum (App mapSq (Var (TArray (STC STZ) TDouble) Zero))) mapSq :: Exp env (Array L.DIM1 Double -> Array L.DIM1 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 L.DIM1 Double) mapSqIota = L.map (Lam TDouble (App (Const CMulF) (Pair (Var TDouble Zero) (Var TDouble Zero)))) (Build (STC STZ) (Pair (Lit LNil) (Lit (LInt 5))) (Lam L.infer (App (Const CtoF) (Snd (L.var Zero))))) transpose2 :: Exp env (Array L.DIM2 Double -> Array L.DIM2 Double) transpose2 = Lam L.infer (App (L.transpose L.infer) (App (L.transpose L.infer) (L.var Zero)))