`openInput` return value is unstable
Closed this issue · 6 comments
In the first screenshot, we see that opening an device won't work unless the call to openInput is prefaced by a call to getDeviceInfo. Very strange indeed...
In this second one, we see that calling isLeft on a device will cause it to switch! (but only the first time. It settles into an equilibrium of error.)
Also, I'd like to politely point out that the Left value in an Either should be the erroneous value, and the Right should be the valid one. That is, if one hopes to use Either as a monad.
Thank you,
Ben
Hi @bgrange, I quickly looked at the C code, and I suspect a missing call (on your side) to PortMidi.initialize
, can you please double check?
Also, I'd like to politely point out that the Left value in an Either should be the erroneous value, and the Right should be the valid one. That is, if one hopes to use Either as a monad.
Absolutely, and the Either conventions for returning errors are changed in master
but not pushed to hackage yet.
@bgrange did the suggested fix work for you? It seems to me that that's the problem so I'll close the issue. Feel free to reopen if you think otherwise.
Oh, I see.
The problem here is that the second time, you're trying to open a stream that's already opened : it errors, and it's normal. I think for it to work you'd need to first close the stream using the close
function.
Thanks.
Btw, the new version is on Hackage now, with Either conventions fixed (since you were mentionning this issue at the beginning!).