In a number of occasions I have a collection of functions that I'd like to implement in different ways. The most obvious example of this would be to abstract from specific databases. In an object-oriented language you would use an interface for this:
interface DB {
ResultSet query(String query);
void persist(Object o);
...
}
In speudo code I would want to do something like this:
(ns dbbackend)
(abstractfn query [q])
(abstractfn persist! [o])
And then implementations for each database:
(ns dbbackend.mysql :implements dbbackend)
(defn query [q] ...)
(defn persist! [o] ...)
It is not entirely clear to me what the best practice is to do something similar in a functional language, specifically Clojure. Should I use multi-methods for this?