【发布时间】:2016-03-13 13:46:24
【问题描述】:
为什么我不能这样做?
genList :: Num a => Int -> [a]
genList m_size = [1..m_size]
上面写着:
Couldn't match expected type `a' with actual type `Int'
`a' is a rigid type variable bound by
the type signature for genList :: Num a => Int -> [a]
at uloha1.hs:105:12
Relevant bindings include
genList :: Int -> [a] (bound at uloha1.hs:106:1)
In the expression: m_size
In the expression: [1 .. m_size]
为什么不能隐式地将 Int 重新输入为 Num? Int 是 Num 的实例,不是吗? 我在这方面找不到任何东西。 我正在使用最新的 Haskell 平台 Ghci 我对 haskell 也完全陌生。
【问题讨论】:
标签: haskell