aboutsummaryrefslogtreecommitdiff
path: root/test/Main.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-10-03 23:05:24 +0200
committerTom Smeding <tom@tomsmeding.com>2025-10-03 23:05:24 +0200
commit4772025626d78127536c341c38052d23ca953ae3 (patch)
tree56374b80987c42598b63b785ba8207bc290cc835 /test/Main.hs
parentbb44859684ee8f241da6d2d0a4ebed1639b11b81 (diff)
Move TH experiments to test-th
Diffstat (limited to 'test/Main.hs')
-rw-r--r--test/Main.hs51
1 files changed, 0 insertions, 51 deletions
diff --git a/test/Main.hs b/test/Main.hs
deleted file mode 100644
index 5a4d335..0000000
--- a/test/Main.hs
+++ /dev/null
@@ -1,51 +0,0 @@
-{-# LANGUAGE GADTs #-}
-{-# LANGUAGE LambdaCase #-}
-{-# LANGUAGE QuantifiedConstraints #-}
-{-# LANGUAGE RankNTypes #-}
-{-# LANGUAGE StandaloneDeriving #-}
-module Main where
-
-import Data.Expr.SharingRecovery
-import Data.Expr.SharingRecovery.Internal
-
-import Arith
-
-
--- TODO: test cyclic expressions
-
-
-a_bin :: (KnownType a, KnownType b, KnownType c)
- => PrimOp (a, b) c
- -> PHOASExpr Typ v ArithF a
- -> PHOASExpr Typ v ArithF b
- -> PHOASExpr Typ v ArithF c
-a_bin op a b = PHOASOp τ (A_Prim op (PHOASOp τ (A_Pair a b)))
-
-lam :: (KnownType a, KnownType b)
- => (PHOASExpr Typ v f a -> PHOASExpr Typ v f b) -> PHOASExpr Typ v f (a -> b)
-lam f = PHOASLam τ τ $ \arg -> f (PHOASVar τ arg)
-
-(+!) :: PHOASExpr Typ v ArithF Int -> PHOASExpr Typ v ArithF Int -> PHOASExpr Typ v ArithF Int
-(+!) = a_bin POAddI
-
-(*!) :: PHOASExpr Typ v ArithF Int -> PHOASExpr Typ v ArithF Int -> PHOASExpr Typ v ArithF Int
-(*!) = a_bin POMulI
-
--- λx. x + x
-ea_1 :: PHOASExpr Typ v ArithF (Int -> Int)
-ea_1 = lam $ \arg -> arg +! arg
-
--- λx. let y = x + x in y * y
-ea_2 :: PHOASExpr Typ v ArithF (Int -> Int)
-ea_2 = lam $ \arg -> let y = arg +! arg
- in y *! y
-
-ea_3 :: PHOASExpr Typ v ArithF (Int -> Int)
-ea_3 = lam $ \arg ->
- let y = arg +! arg
- x = y *! arg
- -- in (y +! x) +! (x +! y)
- in (x +! y) +! (y +! x)
-
-main :: IO ()
-main = putStrLn $ prettyBExpr prettyArithF (sharingRecovery ea_3)