[Haskell-cafe] How far can you take overloading with type classes?

Hilco Wijbenga hilco.wijbenga at gmail.com
Wed Jun 13 03:58:39 UTC 2018


Hi all,

Given definitions of Line and Lines is it possible to define a type
class (or maybe multiple type classes) that would allow for the
following:

(++) :: Line -> Line -> Lines
(++) :: Line -> Lines -> Lines
(++) :: Lines -> Line -> Lines
(++) :: Lines -> Lines -> Lines

I.e. is there a way to overload (++) such that it supports each of
these 4 combinations? (Let's ignore that (++) already exists for the
moment.)

Cheers,
Hilco


More information about the Haskell-Cafe mailing list