
4 Nov
2011
4 Nov
'11
8:51 a.m.
Antoine Latter
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.