OPERATOR OVERLOADING AS IN C++

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

OPERATOR OVERLOADING AS IN C++

Praveen Velliengiri
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
 Praveen v

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: OPERATOR OVERLOADING AS IN C++

Francesco Ariis
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?
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners