Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell point-free compilation type

Tags:

haskell

So I'm really new to Haskell, but I was playing around with the point free notation and came across this issue. I'm in the console:

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

but negate takes a Number, so why is it being constrained to an Integer type?

like image 218
Nimnam1 Avatar asked Sep 25 '15 18:09

Nimnam1


1 Answers

This is another case of the extended defaulting 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
|
> :t c
Num a => (b -> a) -> b -> a -> b
like image 132
bheklilr Avatar answered Sep 27 '22 18:09

bheklilr