所以我有一个函数apply :: proxy tf -> tf Int -> tf Int,它接受一个旨在携带一个类型族的代理,并将Int应用于该类型族以确定第二个参数的类型和返回值.但是,我收到GHC的一些令人困惑的回应.
{-# LANGUAGE TypeFamilies #-}
import Data.Proxy
type family F (a :: *) :: * where
F Int = ()
f :: Proxy F
f = Proxy
apply :: proxy tf -> tf Int -> tf Int
apply _ x = x
-- Doesn't typecheck.
test1 :: ()
test1 = apply f ()
-- Typechecks fine
test2 :: ()
test2 = let g = apply f in g () …Run Code Online (Sandbox Code Playgroud)