Home > Back-end >  How I can calculate the type of (> 0)?
How I can calculate the type of (> 0)?

Time:06-24

Whenever I have an operator section with its left argument partially applied, i.e:

(0 >)

I just simply rewrite the operator in its prefix form and proceed with calculation:

(>) 0

How can I calculate the type of an operator section that has its right argument partially applied ?

CodePudding user response:

For (>), it doesn't matter, because both arguments have the same type. Remove either Ord a => a from Ord a => a -> a -> Bool, and you are left with Ord a => a -> Bool.

In general, you just remove the type corresponding to the applied argument. For example, given (??) :: a -> b -> c (don't worry that this particular type is uninhabited),

-- with the a argument supplied, you still need a b
(x ??) == (\y -> x ?? y) :: b -> c
-- with the b argument supplied, you still need an a
(?? y) == (\x -> x ?? y) :: a -> c
  • Related