相关疑难解决方法(0)

具有RankNTypes扩展名的奇怪类型推断

我试图在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)

haskell ghc

6
推荐指数
2
解决办法
172
查看次数

标签 统计

ghc ×1

haskell ×1