Why does ghci print (Num a) => a for: t 4 and not (Ord a) => a?

When I enter :t 4ghci, I get

Prelude> :t 4
4 :: Num t => t

I understand why it 4is not only Int or Integer, but it is also displayed from the bottom up, but I do not understand why something like this is 4not displayed as Ord t => tor even more correctly:

4 :: (Ord t || Num t) => t

Since it 4is both Ord, and Num, but Ordalso Numhave no connection ...

So why :t 4only outputs Num?

+4
source share
1 answer

Num Ord, fromInteger Num, Haskell. , Complex Data.Complex Num, Ord. 4 Ord.

ghci> import Data.Complex
ghci> let x = 1 :: Complex Double
ghci> let y = 2 :: Complex Double
ghci> x < y
<interactive>
    * No instance for (Ord (complex Double)) arising from use of `<'
    * In the expression: x < y
      In the equation for `it': it = x < y
ghci>

@Lee, , report.

+9

Source: https://habr.com/ru/post/1659465/


All Articles