<div dir="ltr">Consider that<div><br></div><div>interface PasswordStore {</div><div>  void store(Path path, String secret, Map metadata);</div><div>}</div><div><br></div><div>is identical to</div><div><br></div><div>void store (PasswordStore store, Path path, String secret, Map metadata)</div><div><br></div><div>or</div><div><br></div><div>store :: PasswordStore -> Path -> secret -> MetaData -> IO ()</div><div><br></div><div>So, you can treat PasswordStore as a pure data structure (that has things like connection details) and just define functions that use it.  I wouldn't worry about grouping the functions together.(*) I'm going to assume you don't really need an actual interface, but if you did, you could investigate typeclasses.</div><div><br></div><div>Julian.</div><div><br></div><div>(*) In general terms, the only reason to group functions together is to enforce laws that relate the behaviours together e.g. that you can retrieve something you stored.</div><div class="gmail_extra"><br><div class="gmail_quote">On 4 January 2015 at 11:14, Thomas Koch <span dir="ltr"><<a href="mailto:thomas@koch.ro" target="_blank">thomas@koch.ro</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm writing a password manager that implements a dbus-api using the dbus[1]<br>
package. I'd like to separate the code that implements from the dbus api from<br>
the code that stores and retrieves the secrets (passwords). In Java I'd use an<br>
interface, e.g.:<br>
<br>
interface PasswordStore {<br>
  void store(Path path, String secret, Map metadata);<br>
  (String secret, Map metadata) retrieve(Path path);<br>
  (String secret, Map metadata) search(Map criteria);<br>
}<br>
<br>
And the dbus-api would export this interface:<br>
<br>
dbusClient.export(PasswordStore store)<br>
<br>
What would be a Haskell way to do the same? My only idea is to define a record:<br>
<br>
data PasswordStore {<br>
    store :: Path -> Secret -> MetaData -> IO ()<br>
  , retrieve :: Path -> IO (Secret, MetaData)<br>
  , search :: Criteria -> IO (Secret, MetaData)<br>
}<br>
<br>
Thank you for any suggestions! Thomas Koch<br>
<br>
[1] <a href="http://hackage.haskell.org/package/dbus-0.10.9" target="_blank">http://hackage.haskell.org/package/dbus-0.10.9</a><br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div></div>