Путаница с выводом типа в Haskell

Я не понимаю, почему работает следующая функция :

isLongerThanN :: Integral n => n -> [a] -> Bool
isLongerThanN n xs = length xs > fromIntegral n

, но следующая не работает :

isLongerThanN' :: Integral n => n -> [a] -> Bool
isLongerThanN' n xs = length xs > n

, что выдает ошибку

Could not deduce (n ~ Int)
    from the context (Integral n)
      bound by the type signature for
                 isLongerThanN' :: Integral n => n -> [a] -> Bool
      at blah.hs:140:1-35
      `n' is a rigid type variable bound by
          the type signature for
            isLongerThanN' :: Integral n => n -> [a] -> Bool
          at blah.hs:140:1
    In the second argument of `(>)', namely `n'
    In the expression: length xs > n
    In an equation for `isLongerThanN'':
        isLongerThanN' n xs = length xs > n

(что я, вероятно, неправильно понял)

Во всяком случае, я ожидал бы, что это будет наоборот, так как fromIntegral эффективно расширяет тип переменной n.

5
задан Inept 29 April 2012 в 03:21
поделиться