I used this Haskell interpreter right here: https://tryhaskell.org/
When I provided the input 5 1
it tells me - I assume it is the type - that the expression is of type (Num a, Num (a -> t)) => t
:
λ 5 1
:: (Num a, Num (a -> t)) => t
Now I have tried to understand how to interpret this and this is what I came up with.
a
is any Num
type and so is a -> t
. The expression results in some type t
that is produced by theoretically applying 1
(type a
) to 5
(type a -> t
).
This really disturbs me because I don't see how the constraint Num (a -> t)
makes sense. Theoretically it looks to be the correct interpretation but I can't find prove for that.
The interpretation is correct
It makes sense because Num
is a polymorphic type - which can be a function.