blob: d8ae7a3b996aa15be01d91494b0a6612d0a4c58e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
|