From 1c4a175e00e727ac4987f60503bd7dbaeb3f26ad Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Tue, 28 Oct 2025 16:42:28 +0100 Subject: wip: use de Bruijn indices representation provide sample complex terms to evaluate --- .../haskell/test/Minilang/Lambda/DeBruijnSpec.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs (limited to 'lambda-calcul/haskell/test') diff --git a/lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs b/lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs new file mode 100644 index 0000000..ef8903c --- /dev/null +++ b/lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs @@ -0,0 +1,18 @@ +module Minilang.Lambda.DeBruijnSpec where + +import Minilang.Lambda.DeBruijn (DeBruijn (..), eval, toDeBruijn) +import qualified Minilang.Lambda.Eval as Eval +import Test.Hspec (Spec, it, shouldBe) + +spec :: Spec +spec = do + it "convert term to deBruijn representation" $ do + let term = Eval.Lam "x" (Eval.Lam "y" (Eval.Var "x")) + deBruijn = toDeBruijn term + + deBruijn `shouldBe` Lam (Lam (Var 1)) + + it "evaluates deBruijn term" $ do + let term = App (App (Lam (Lam (Var 1))) (Var 12)) (Var 34) + + eval term `shouldBe` Var 12 -- cgit v1.3.1