[Haskell-beginners] Polymorphism ad hoc

Arjun Comar nrujac at gmail.com
Wed Jul 6 16:19:37 UTC 2016


Hi Ford,
Haskell does support ad-hoc polymorphism via type classes. In short,

class Foo a where
    -- type declarations for related sets of functions that are polymorphic
in a go here

instance Foo Int where
    -- function definitions with a specialized to Int go here.

The Show class is probably a fairly simple example you can play with in
ghci.

data Test = Test

instance Show Test where
    -- show :: Test -> String
    show t = "Hello World"

Thanks,
Arjun


On Wed, Jul 6, 2016 at 12:05 PM OxFord <fordforox at gmail.com> wrote:

> Hello,
>
> why does haskell support only parametric polymorphism?
>
> Is it because ad hoc p. || multiple dispatch is bad in general?
>
>
> King Regards,
>
> Ford
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160706/1e82699a/attachment.html>


More information about the Beginners mailing list