在 Haskell 中,为什么会这样编译:
splice :: String -> String -> String
splice a b = a ++ b
main = print (splice "hi" "ya")
但这不会:
splice :: (String a) => a -> a -> a
splice a b = a ++ b
main = print (splice "hi" "ya")
>> Type constructor `String' used as a class
我会认为这些是同一件事。有没有办法使用第二种样式,避免重复类型名称 3 次?