As far as I know, haskell infers the most general possible type , being
integers = [1,2,3]
integersOrNot = [1,2,3]
routine :: IO ()
routine = do
let x = map (\i -> i / 2) integersOrNot
return ()
When I test type of integersOrNot
, I get
*Main> :t integersOrNot
integers_ :: [Double]
Given
*Main> :t 1
1 :: Num a => a
Haskell didn't have much options. But how come
*Main> :t integers
integers :: [Integer]
not integers :: (Num a) => [a]
? Does that mean Integer
is a "default" real type for Num
kind?
http://wiki.haskell.org/MonomorphismRestriction
as suggested by @leftaroundabout
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.