blob: cff047d593123eb45ffed82a1a3951e8fcf96e56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
{-# LANGUAGE TypeApplications #-}
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)
import Data.Text (Text)
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 "x" (Lam "y" (Var "x" 1))
it "evaluates deBruijn term" $ do
let term = App (App (Lam "x" (Lam "y" (Var "x" 1))) (FV "z")) (FV "t")
eval @Text term `shouldBe` FV "z"
|