[Haskell-beginners] containers and extensibility, typeclasses vs. multiple value constructors

Stephen Tetley stephen.tetley at gmail.com
Mon Sep 6 10:57:07 EDT 2010


Hello Greg

Supposing you are working with GnuPlot - one option is to make Plot a
functional type that takes a list of some polymorphic input data and
generates a 'GnuPlot' - where GnuPlot is a type representing output in
the GnuPlot format.

type Plot a = [a] -> GnuPlot

Or if GnuPlot accepts drawing styles...

type Plot a = [a] -> DrawingStyle -> GnuPlot

Plots are just functions, so clearly you can define as many as you
like and they are all the same type.

Best wishes

Stephen


More information about the Beginners mailing list