假设我们有:
data Data a b c = Build (a,b,c) deriving Show
foo :: Data a b c -> Data a b c
foo d = d
main = print $ foo $ Build (1, 1, "a")
有什么方法可以避免每次使用数据类型时都写入a b c
?
使用类型,例如:
foo :: Data -> Data
foo d = d
最佳答案
是的,当然:
foo :: d ~ Data a b c => d -> d
关于haskell - 为什么 haskell 强制总是输入泛型类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42143457/