RE: ANNOUNCE: Object I/O released
Hello Krasimir, I am very curious about your implementation of the Object I/O system, but unfortunately could not open the .zip files either (same symptoms as Arjan van IJzendoorn wrote). Could you check the formats of these files? Thanks in advance. Simon Peyton-Jones wrote:
Krasimir
| The version that I release is based entirely on LS | version. I think that it is more elegant and more | useful for customer.
I'm delighted and impressed that you have completed the Object I/O port, but I don't think I agree with you about the MVar/LS issue.
A note to other readers: the issue is whether it is better, from the programmer's point of view, to use MVars to manipulate state, or to use the state parameterisation that Clean uses. This issue is discussed in the paper by Peter Achten and mself http://research.microsoft.com/~simonpj/Papers/haskellobjectio.htm
My defence of the MVar approach is not because I simply think that MVars are best for everything! It's because I have really struggled to understand the types in the Clean I/O system, and they become *so* much simpler when the state parameterisation is left out. And if I struggle, then I fear that novice programmers may be in real difficulty.
I think that even Peter Achten thought this too, having done it both ways (but I should let him speak for himself).
This issue was one of the key design issues Simon and I had to resolve when porting the Clean Object I/O system to Haskell. The arguments in the above mentioned paper are still valid. Briefly, one can summarise them as: MVar-s offer many significant advantages (simpler types, simpler implementation, more expressive power, programming style similar to handling of identifier values) but have one disadvantage (state management is done by the programmer). As it happens, I am about to spend a couple of weeks (re)designing/implementing/bug-fixing the Object I/O library, and this issue is high on my priority list. I think this is a delicate design decision that should be taken with care, as it has impact on all existing programs and all implementations :-). Regards, Peter Additional remarks to those of Simon:
To respond to your points:
| 1) In the MVAR version each event handler must like | this: | | eventHandler state = do | st <- takeMVar state | ... | ... | putMVAR state st' | | In LS version there isn't need of takeMVar/putMVAR and | the handler is more easy.
But the reverse case is also true: in the LS version, an event handler must modify local state. So a function that is really not interested in the local state is either polymorphic in the local state or uses the local state lifting function (noLS and noLS1). In the MVAR version one wouldn't be bothered with this.
| | 2) In MVAR version the event handlers in the device | definitions must be defined as curry functions | | Example MVAR: | state <- newMVAR (0::Int) | openWindow (Window NilLS [WindowClose (closeWin | state)]) | | Example LS: | openWindow (0::Int) (Window NilLS [WindowClose | closeWin])
Both are true, but you can easily wrap up the state passing if that is what you want:
state <- newMVAR (0::Int) openWindow (Window NilLS [WindowClose (handle state closeWin)])
handle :: MVar a -> (a -> IO a) -> IO () handle m t = do { s <- getMVar m; r <- t s'; putMVar m s' }
Now you can write closeWin :: WinState -> IO WinState if you want.
Of course the reference to the state is still explicit, but I do not think that is a bad thing. It tells you where that MVar can be modified (and where it can't!). There might be two pieces of state for one component, one modified by one set of events and one by another, and it would be nice to make that apparent.
| 3) Modification of local state doesn't mean | modification of device behaviour. The behaviour of the | device is described with both local state and internal | device data. This means that direct access to the | state isn't a good idea. In the LS version the local | state is encapsulated in the device and I think that | this is more OOP style.
I don't understand this; you can encapsulate the MVars too, in just the same way:
windowDevice = do { s <- newMVar 0; openWindow ... }
No caller of WindowDevice can see the encapsulated MVar.
The main point of 'LS advocates' is that encapsulation is guaranteed by construction, while it is a program property in the MVAR system. This is of course a GOOD thing. However, this characteristic of LS is also its weakness: one simply can't (partially) share local state between GUI components of different top-level parents (except of course on the highest level within the interactive process) even though in practice this would make a lot of sense. One also can't easily modify event handlers once a GUI structure has been created, even if one would `know' the proper local state type because of the strong encapsulation (you can do it, but this requires quite some overhead, using typed message passing). In short, we have the following: MVAR subsumes LS (we can write more programs), but the price to pay is at least: less static error checking and more proof obligations wrt. locality of state. Perhaps there is an interesting alternative that covers all GOOD points and has fewer BAD points.
--- Peter Achten <peter88@cs.kun.nl> wrote:
Perhaps there is an interesting alternative that covers all GOOD points and has fewer BAD points.
Some pieces of library can be simplified if redefine: data WindowLSHandle ls ps = WindowLSHandle { wlsState :: ls , wlsHandle :: WindowHandle ls ps } as data WindowLSHandle ls ps = WindowLSHandle { wlsState :: MVar ls -- or IORef ls , wlsHandle :: WindowHandle ls ps } That let Object I/O to manage local state but simplifies implementation of WindowDevice (see WindowDevice.hs). There isn't need of fixIO and not need to use of build function. This also simplifies creation of modal dialogs and synchronous message passing. The current implementation uses unsafeTypeCast function which is not a good idea. In this implementation the type system is still complicated but my decision is just to skip type declarations and let compiler to resolve function types for me. In my experience with Object I/O I notice that type error is usually logical error. So types for me isn't a trouble. __________________________________________________ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/
Hello all, Peter Achten and Arjan van IJzendoorn wrote:
I <...> unfortunately could not open the .zip files
and Peter asked
Could you check the formats of these files?
After having tried to download the file a few times, I believe the problem is not in the zip file format, but download failure. (Until now, I didn't manage to download more than 3 MB, though the file should be 4 MB.) Krasimir, can you please put the file on another server (maybe the cvs.haskell.org maintainers are willing to store the file; ask Jeff Lewis, jlewis@cse.ogi.edu)? Regards, Rijk-Jan
--- Peter Achten <peter88@cs.kun.nl> wrote:
Hello Krasimir,
I am very curious about your implementation of the Object I/O system, but unfortunately could not open the .zip files either (same symptoms as Arjan van IJzendoorn wrote). Could you check the formats of these files? Thanks in advance.
Try again. The trouble is resolved __________________________________________________ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/
The quick reference still gives problems.
I managed to download the quick reference. Get it at http://www.students.cs.uu.nl/people/rjchaaft/ObjectIO/objectio-ref.zip This is a very temporarily available service, so if anyone has a suitable server (again, cvs.haskell.org?), please take over hosting the file. Rijk-Jan
Dear all, Using a download manager, I 'managed to download' the Object IO library. Get DLExpert from http://www.rocketdownload.com/dnload/dlexpert.exe (not at rocket speed, but not too bad) or from the developer directly http://www.yanew.com/english.htm (very, very, very slow) http://www.yanew.com/dlexpert099.exe (slow) Then, use DLExpert to download the both Object IO files: http://free.top.bg/ka2_mail/objectio-ref.zip http://free.top.bg/ka2_mail/objectio.zip Use the maximum number of threads (1000) to download the file, or wait a long time (using 30 threads takes an hour). A few more points: The zip file is NOT corrupt :-) I'm sorry I don't have room to put the ObjectIO lib online as I did with the reference:-( With DLExpert, you can download the file in 5 minutes People at the Computer Science departement, Utrecht University: look in /net/tmp/ObjectIO Regards, Rijk-Jan
participants (4)
-
Arjan van IJzendoorn -
Krasimir Angelov -
Peter Achten -
Rijk J. C. van Haaften