Overloading Haskell functions to have different number of arguments

Viewed 1490

Is it possible to have two functions of the same name have a different number of arguments in Haskell? This is what I want to do:

inc = (+) 1

inc x = (+) x

I want to be able to call my increment function with no arguments which defaults to incrementing by 1, or with an argument and have it increment by x.

The I can do either of the following, for example:

map(inc)[1,2,3] --results in [2,3,4]

map(inc 2)[1,2,3] -- results in [3,4,5]

2 Answers
Related