[Haskell-beginners] weird constraint

Yitzchak Gale gale at sefer.org
Sun Jan 20 00:09:15 UTC 2019


On 16/01/2019 15:52, Dimitri DeFigueiredo wrote:
>> ...I was expecting to get:
>> inc . const :: Num a => a -> b -> a
>>
>> Prelude> inc x = x + 1

On Wed, Jan 16, 2019 at 5:06 PM Sylvain Henry <sylvain at haskus.fr> wrote:
> Remember that a -> b -> a is equivalent to a -> (b -> a)...

To augment Sylvain's explanation: The upshot of this unexpected type -
which would almost certainly lead to a type error in any real program -
is that you probably want
const . inc
rather than
inc . const

-Yitz


More information about the Beginners mailing list