如何使用 show 在不发出警告的情况下打印出 haskell 中的整数值?

How do I print out Integeral values in haskell without warning using show?

当我 运行 以下 haskell 启用警告的代码时

module Main where
main :: IO()
main = interact (unlines.strout.calc.extinps.words)

--calculates factorial
factorial :: Integral a=> a->a
factorial n = product [1..n]

--Extracts numbers from the input
extinps ::(Read b)=>[String]->[b]
extinps x=map read x

--Calculates the factorial
calc :: (Integral b) => [b] -> [b]
calc x= map factorial x

--Converts the result to a string
strout::(Show b)=>[b]->[[Char]]
strout x=[show a|a<-x]

我收到以下警告:

factout.hs:3:26: Warning:
Defaulting the following constraint(s) to type `Integer'
   (Show b0) arising from a use of `strout' at factout.hs:3:26-31
   (Read b0) arising from a use of `extinps' at factout.hs:3:38-44
   (Integral b0) arising from a use of `calc' at factout.hs:3:33-36    
In the first argument of `(.)', namely `strout'                       
In the second argument of `(.)', namely                                 
   `strout . calc . extinps . words'                                   
In the first argument of `interact', namely                               
   `( unlines . strout . calc . extinps . words)'
Ok, modules loaded: Main.                                            

如何摆脱它?

编译器不知道应该使用 Integral 的哪个具体实现。 估计Integer应该可以吧

如果您注释例如calc,警告将消失:

main :: IO ()
main = interact (unlines . strout . (calc :: [Integer] -> [Integer]) . extinps . words)