I am trying to return the length of a list as an Integer
type, but applying length xs
returns the length as an Int
type. How can I work around this issue?
This is what I am trying to achieve: (it does not work)
sizeList :: [Integer] -> Integer
sizeList xs = length xs
It works as soon as I change the return to sizeList :: [Integer] -> Int
but I don't want to do so.
You can either call genericLength
from Data.List
, or call length
and use fromIntegral
to convert the result.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句