我试图在Haskell中试验System-F类型,并通过实现自然数的Church编码type.
加载此代码时
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE RankNTypes #-}
type CNat = forall t . (t -> t) -> (t -> t)
c0 :: CNat
c0 _ x = x
type CPair a b = forall t . (a -> b -> t) -> t
cpair :: a -> b -> CPair a b
cpair a b f = f a b
-- pair3 :: CPair CNat String
pair3 = cpair c0 "hello"
Run Code Online (Sandbox Code Playgroud)
进入ghci 7.8.2我收到警告:
?: :l …Run Code Online (Sandbox Code Playgroud)