5

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?

1 Answer 1

7

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 
Sign up to request clarification or add additional context in comments.

2 Comments

Just a note, you don't need multi line input; you can write let x :: T; x = t.
@user2407038 You don't need it, and you can also use :{ and :}, but I prefer :set +m, it's more like how IPython does multi-line input.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.