[Haskell-beginners] Haskell way of defining and implementing OO interfaces
Thomas Koch
thomas at koch.ro
Sun Jan 4 11:14:07 UTC 2015
Hi,
I'm writing a password manager that implements a dbus-api using the dbus[1]
package. I'd like to separate the code that implements from the dbus api from
the code that stores and retrieves the secrets (passwords). In Java I'd use an
interface, e.g.:
interface PasswordStore {
void store(Path path, String secret, Map metadata);
(String secret, Map metadata) retrieve(Path path);
(String secret, Map metadata) search(Map criteria);
}
And the dbus-api would export this interface:
dbusClient.export(PasswordStore store)
What would be a Haskell way to do the same? My only idea is to define a record:
data PasswordStore {
store :: Path -> Secret -> MetaData -> IO ()
, retrieve :: Path -> IO (Secret, MetaData)
, search :: Criteria -> IO (Secret, MetaData)
}
Thank you for any suggestions! Thomas Koch
[1] http://hackage.haskell.org/package/dbus-0.10.9
More information about the Beginners
mailing list