Haskell Compilation Type Without Header

So, I am really new to Haskell, but I played with a free note and came across this problem. I am in the console:

> let c = (.)negate > :tc > (a -> Integer) -> a -> Integer -> a 

but negate accepts Number, so why is it limited to type Integer?

+5
source share
1 answer

This is another example of extended default rules in GHCi. Do :set -XNoMonomorphismRestriction or just do

 > :set +m -- multiline input in GHCi > let c :: (Num a) => (b -> a) -> b -> a -> b | c = (.) negate | > :tc Num a => (b -> a) -> b -> a -> b 
+7
source

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


All Articles