Check this out http://lukasz.langa.pl/8/single-dispatch-generic-functions/