나는 다음과 같은 표현이 있습니다하스켈 - 더 타입 추론 문제
getCount :: (Num a) => a -> [a]
getCount int = foldl
processOneCount
[0,0,0,0,0,0,0,0,0,0]
(map (singleDigitCount) (map (digitToInt) (show int)))
을하고 난 다음 오류 얻을 : 나는 :t [0,0,0,0,0,0,0,0,0,0]
내가 다시 [0,0,0,0,0,0,0,0,0,0] :: (Num t) => [t]
얻을 수행 할 때 아직
Couldn't match expected type `a' against inferred type `Int'
`a' is a rigid type variable bound by
the type signature for `getCount'
at C:\Users\RCIX\Desktop\Haskell Code\test.hs:23:17
Expected type: [a]
Inferred type: [Int]
In the expression:
foldl
processOneCount
[0, 0, 0, 0, ....]
(map (singleDigitCount) (map (digitToInt) (show int)))
In the definition of `getCount':
getCount int
= foldl
processOneCount
[0, 0, 0, ....]
(map (singleDigitCount) (map (digitToInt) (show int)))
합니다. 그렇다면 첫 번째 표현에서 왜 그것을 사용할 수 없습니까?
오. 내가 int 타입을 고수해야 하는가 아니면 출력을 Num로 강요 할 수있는 방법이 있을까요? – RCIX
'fromIntegral :: (Integral a, Num b) => a -> b' – ephemient
도움 주셔서 감사합니다 :) – RCIX