为什么这种类型的单一用法编译,但将其放入列表失败?
ft1 :: (Foldable t, Num a) => t a -> a
ft1 = (F.foldl (+) 0)
fTest :: [(Foldable t, Num a) => t a -> a ]
fTest = [ F.foldl (+) 0 ]
Run Code Online (Sandbox Code Playgroud)
后者给出错误:
folding.hs:80:10:
Illegal polymorphic or qualified type:
(Foldable t, Num a) => t a -> a
Perhaps you intended to use ImpredicativeTypes
In the type signature for `fTest':
fTest :: [(Foldable t, Num a) => t a -> a]
Run Code Online (Sandbox Code Playgroud)
Simliarly,尝试命名它失败(不同):
type Ftst t a …Run Code Online (Sandbox Code Playgroud) haskell ×1