diff options
Diffstat (limited to 'testsuite/tests/simplCore/should_compile/T20894.hs')
-rw-r--r-- | testsuite/tests/simplCore/should_compile/T20894.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T20894.hs b/testsuite/tests/simplCore/should_compile/T20894.hs new file mode 100644 index 0000000000..d8ae7a3b99 --- /dev/null +++ b/testsuite/tests/simplCore/should_compile/T20894.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE Haskell2010 #-} + +module T20894 where + +import Prelude (Int) + +data LitE = IntLit !Int | StringLit +data Term = LitE LitE | Term :$ Term | S Term | VarE +data Val = LitV LitE + +eval :: Term -> Val +eval (LitE l) = LitV l +eval (S a) = eval a +eval _ = LitV StringLit + +church :: Int -> Term +church 0 = VarE +church _ = S VarE + +evalChurchId :: Int -> Int -> Int +evalChurchId i arg = + case eval (S (S (church i)) :$ LitE (IntLit arg) ) of + LitV (IntLit res) -> res |