[Haskell-beginners] OPERATOR OVERLOADING AS IN C++

Francesco Ariis fa-ml at ariis.it
Tue Feb 14 13:18:19 UTC 2017


On Tue, Feb 14, 2017 at 06:21:37PM +0530, Praveen Velliengiri wrote:
> I'm new to functional programming, Whether it is possible to do operator
> overloading  in Haskell ? I go through the Idea of TYPECLASSES in Learn you
> haskell tutorial. But I can't understand the idea Can anyone suggest me
> some idea regarding Operator overloading and Type classes in Haskell.
> Thank you guys

Hello Praveen,

    indeed Haskell uses typeclasses to deal with ad hoc polymorphism.
Are you familiar with any of them? If I write in ghci:

    λ> show 707
    "707"
    λ> show True
    "True"
    λ> show 'c'
    "'c'"
    λ> show "palla"
    "\"palla\""

that is possible because numerous types are instances of the typeclass
Show, which provides `show`

    λ> :t show
    show :: Show a => a -> String

Does that help a bit? Or you aren't sure about the typeclass syntax?


More information about the Beginners mailing list