小编Dob*_*lot的帖子

Haskell类型转换问题

示例代码:

fac :: Int ? Int
fac 0 = 1
fac n = n * fac (n-1)

main = do
        putStrLn show fac 10
Run Code Online (Sandbox Code Playgroud)

错误:

Couldnt match expected type 'String'
       against inferred type 'a -> String'
In the first argument of 'putStrLn', namely 'show'
In the expression: putStrLn show fac 10
Run Code Online (Sandbox Code Playgroud)

haskell types casting

4
推荐指数
1
解决办法
445
查看次数

标签 统计

casting ×1

haskell ×1

types ×1