diff options
Diffstat (limited to 'Examples.hs')
-rw-r--r-- | Examples.hs | 15 |
1 files changed, 9 insertions, 6 deletions
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))) |