[英]`foreach` in Haskell
This code type-checks:此代码类型检查:
type T :: Type -> foreach (r :: Type) -> Type -> Type
data T k r a
type T' :: Type -> Type
type T' a = T a Identity a
Type -> Type
(ie., Identity
) here?Type -> Type
(即Identity
)? It fails to type-check if you replace Identity
with say Int
.Identity
替换为 say Int
,它将无法进行类型检查。foreach
keyword, and how does one use it in Haskell?foreach
关键字,如何在 Haskell 中使用它? It's not a keyword, just an implicitly quantified type variable.它不是关键字,只是一个隐式量化的类型变量。 It's like when you write a function
就像你写一个 function
foo :: [Int] -> foreach Bool -> Double
foo = undefined
main = print $ foo [1,2,3] (Just True)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.