Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Haskell way of defining and implementing OO interfaces
(Thomas Koch)
2. Generate API implementations from XML (Thomas Koch)
----------------------------------------------------------------------
Message: 1
Date: Sun, 04 Jan 2015 12:14:07 +0100
From: Thomas Koch <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Haskell way of defining and implementing
OO interfaces
Message-ID: <4373916.AyiZNG9BE1@x121e>
Content-Type: text/plain; charset="us-ascii"
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
------------------------------
Message: 2
Date: Sun, 04 Jan 2015 12:26:54 +0100
From: Thomas Koch <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Generate API implementations from XML
Message-ID: <4360512.CQEcta1ySS@x121e>
Content-Type: text/plain; charset="us-ascii"
Hi,
as written in my previous mail, I'm implementing a dbus interface in Haskell.
The interface definition is given in XML[1] according to a given dtd[2].
For every dbus method one need to invoke[3]
export :: Client -> ObjectPath -> [Method] -> IO ()
What would be a good way to autogenerate all this export calls and Method
instances? All necessary informations are given in the dbus spec xml.
One could write a script that writes Haskell code.
Or one could use template haskell that reads the xml file at compile time?
Or?
Do you know other examples to learn from that autogenerate Haskell code from
interface definitions?
Thank you, Thomas Koch
[1]
http://code.metager.de/source/xref/freedesktop/xdg/specs/secret-service/org.freedesktop.Secrets.xml
[2] http://standards.freedesktop.org/dbus/1.0/introspect.dtd
[3]
http://hackage.haskell.org/package/dbus-0.10.9/docs/DBus-Client.html#v:export
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 79, Issue 4
****************************************