[Haskell-beginners] Haskell wants the type, but I only know the class.

Amy de Buitléir amy at nualeargais.ie
Fri Nov 4 13:51:23 CET 2011


Antoine Latter <aslatter <at> gmail.com> writes:

> A really simple and common way to do this would be using a sum-type:

Here's what I'm trying to accomplish. I want to write a daemon that will cycle
through the files, load each one in turn, and invoke the doSomething method. I
would like to be able to allow people to use my daemon with any assortment of new
types that they create, as long as that type implements the doSomething,
readThing, and writeThing methods.

I could make the sum-type approach work, but then users would have to modify the
type. And there might be dozens of different types in use, some provided by me,
and some provided by the user, so it would get messy. But I might have to go
with that approach.





More information about the Beginners mailing list