-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client generation #15
Conversation
hlint error is due to ndmitchell/hlint#332 |
35c2acb
to
6eeecf7
Compare
Here is a diff that excludes the changes from #12 |
50e9acf
to
46ca0fa
Compare
6eb525a
to
1a43be5
Compare
Ivan, first, thanks again for your contribution! But I feel we need to get a bit more organized here: with 40 commits this becomes longest email thread in my inbox this year. And it is quite hard to review, I don't even know when to start. Could you please make all the intermediate changes in the forked repo, squash changes and send one-diff pull requests, self-contained and ready to merge? It would also help a lot if each pull request will have complete, but relatively small scope: it is much easier to review three 50-line diffs than one 150-line. By the way, feel free to drop support for ghc versions before 7.10.3, just remove them from travis config. |
I can squash the commits, but this change depends on the new properties functions in #12 so its scope really can't be made much smaller, unfortunately. The diff from the tip of #12 (This is what the diff would look like if #12 were merged) is actually not SO bad: You'll notice that almost all of the diff is the addition of a new file: lib/DBus/Generation.hs, and that there are actually only 3 lines that are deleted (changed) which should make this change very safe. Basically, what this change does is add facilities to generate clients and signal/emission/registration functions. I would recommend that you not even try to review lib/DBus/Generation.hs, as reading template haskell code can be very difficult. I did add a test in tests/DBusTests/Client.hs that should give you some confidence that the code actually works. The new files tests/DBusTests/Generation.hs and tests/DBusTests/TH.hs are simply to support that test. They have to be in separate files becuase of annoying limitations of template haskell. You may also want to check out In https://github.com/IvanMalison/status-notifier-item/blob/master/src/StatusNotifier/Item/Constants.hs we load an xml file from which bindings for the client are created in I've included gists of the output that is produced by the generations calls here. Looking at these might help give you a sense of what generation is doing. Client: https://gist.github.com/2df87d651b3f78da87e3198b457054fc |
Also, if it would be helpful, I would be happy to get on a skype call or something like that to walk you through the changes. |
356eaa9
to
8a3c8b1
Compare
3d58173
to
86a695d
Compare
9e232c7
to
82ceb9b
Compare
1663cf3
to
4c877b1
Compare
@rblaze Is there anything I can do to help out here? I'd really like to get this merged so that I can make new releases of several projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I have a few style issues.
, genInterfaceName = fromString "" | ||
, getTHType = defaultGetTHType | ||
, genObjectPath = Nothing | ||
, genTakeSignalErrorHandler = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home/travis/build/rblaze/haskell-dbus/lib/DBus/Generation.hs:96:3: warning: [-Wmissing-fields]
• Fields of ‘GenerationParams’ not initialised: useDBusR
• In the expression:
GenerationParams
{genBusName = Nothing, genInterfaceName = fromString "",
getTHType = defaultGetTHType, genObjectPath = Nothing,
genTakeSignalErrorHandler = False}
|] | ||
getFunctionBody = [| | ||
do | ||
let $( varP methodCallN ) = $( setMethodCallParamsE ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple warnings like this:
This pattern-binding binds no variables:
$(varP methodCallN) = $setMethodCallParamsE
I'm not familiar with template haskell, is this compiler misunderstanding something or a genuine issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is a known issue. See this thread https://mail.haskell.org/pipermail/haskell-cafe/2014-December/117437.html
lib/DBus/TH.hs
Outdated
|
||
import DBus.Client | ||
import DBus.Generation | ||
import qualified DBus.Introspection as I |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The qualified import of ‘DBus.Introspection’ is redundant
except perhaps to import instances from ‘DBus.Introspection’
To import instances alone, use: import DBus.Introspection()
lib/DBus/TH.hs
Outdated
import System.FilePath | ||
|
||
|
||
generateSignalsFromInterface defaultGenerationParams $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like generated code isn't very clean:
Top-level binding with no type signature: signalForPropertiesChanged :: DBus.Internal.Message.Signal
Top-level binding with no type signature: methodCallForInterfaces :: DBus.Internal.Message.MethodCall
Defined but not used: ‘replySuccess’
etc...
Can you make sure it compiles without warnings? It is very annoying when library adds a lot of warning noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got rid of all of these except for the replySuccess not being used. That one only comes up when there are no return values for a method. Getting rid of it would require a lot more code.
lib/DBus/Client.hs
Outdated
import qualified Control.Exception | ||
import Control.Exception (SomeException, throwIO) | ||
import Control.Lens | ||
import Control.Monad | ||
import Control.Monad.Reader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use Reader from transformers? Using mtl and transformers in the same library looks counterintuitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. good catch.
Not sure why the build errored. If you take a look at the output of the build here: https://travis-ci.org/rblaze/haskell-dbus/jobs/357683407 the only thing there is the no bindings for pattern and the (existing) orphan instance issues. |
It timed out. It happens sometimes, restarting build helps usually (you need to login to travis with github account for this). I'll do it now. |
I'm looking into changing library license from GPL to Apache, to make it easier to use in non-GPL projects. Are you okay with releasing your changes under Apache license? |
sure |
This builds on #12 with support for client generation
Fixes #3, #14