[Haskell-beginners] overload a function

Karthick Gururaj karthick.gururaj at gmail.com
Wed Mar 16 15:37:14 CET 2011

On Wed, Mar 16, 2011 at 7:57 PM, Britt Anderson
<britt.uwaterloo at gmail.com> wrote:
> I would like to have a function that can accept more than one input
> type and gives the same back as output. For the different eligible
> input types there would be different tests.
> An example of the idea would be something like:
> test :: a -> Bool -> a
> test 0 True = 0
> test False True = False
What is expected from:
test 0 False
test "hello" False

> is it obligatory that I create a typeclass for test and then instance
> each type that might go in the "a" slot? Because that seems like a lot
> of work.

More information about the Beginners mailing list