为什么 Prog A 编译并运行良好,而 Prog B 编译失败?谢谢
前卫A
func :: String -> String
func a = a
mydofn a = do
x <- func a
return x
main = print "Finished"
编B
func :: Int -> Int
func a = a
mydofn a = do
x <- func a
return x
main = print "Finished"
程序 B 编译错误:
Couldn't match expected type `m0 t0' with actual type `Int'
In the return type of a call of `func'
In a stmt of a 'do' block: x <- func a
In the expression:
do { x <- func a;
return x }