From d4abcc3b2dfefbbcb7cd4a182eec64f1da42d951 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 27 Jun 2021 18:34:35 +0200 Subject: Things --- Examples.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Examples.hs') diff --git a/Examples.hs b/Examples.hs index 9d9cda7..0719f1f 100644 --- a/Examples.hs +++ b/Examples.hs @@ -4,11 +4,11 @@ import AST import qualified Language as L -sumSq :: Exp env (Array (Int, ()) Double -> Double) +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 (Int, ()) Double -> Array (Int, ()) Double) +mapSq :: Exp env (Array L.DIM1 Double -> Array L.DIM1 Double) mapSq = Lam (TArray (STC STZ) TDouble) (L.map (Lam TDouble @@ -16,13 +16,16 @@ mapSq = (Pair (Var TDouble Zero) (Var TDouble Zero)))) (Var (TArray (STC STZ) TDouble) Zero)) -mapSqIota :: Exp env (Array (Int, ()) Double) +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 (LInt 5)) (Lit LNil)) - (Lam (TPair TInt TNil) + (Pair (Lit LNil) (Lit (LInt 5))) + (Lam L.infer (App (Const CtoF) - (Fst (Var (TPair TInt TNil) Zero))))) + (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))) -- cgit v1.2.3-70-g09d2