Re: [Haskell-cafe] A use case for *real* existential types

2013-05-18 Thread oleg
I must say though that I'd rather prefer Adres solution because his init init :: (forall a. Inotify a - IO b) - IO b ensures that Inotify does not leak, and so can be disposed of at the end. So his init enforces the region discipline and could, after a It's probably not easy to do

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-16 Thread Roman Cheplyaka
* o...@okmij.org o...@okmij.org [2013-05-11 05:26:55-] I must say though that I'd rather prefer Adres solution because his init init :: (forall a. Inotify a - IO b) - IO b ensures that Inotify does not leak, and so can be disposed of at the end. So his init enforces the region

[Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread Leon Smith
I've been working on a new Haskell interface to the linux kernel's inotify system, which allows applications to subscribe to and be notified of filesystem events. An application first issues a system call that returns a file descriptor that notification events can be read from, and then issues

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread Andres Löh
Hi. So the natural question here is if we can employ the type system to enforce this correspondence. Phantom types immediately come to mind, as this problem is almost the same as ensuring that STRefs are only ever used in a single ST computation. The twist is that the inotify interface

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread MigMit
Maybe I understand the problem incorrectly, but it seems to me that you're overcomplicating things. With that kind of interface you don't actually need existential types. Or phantom types. You can just keep Inotify inside the Watch, like this: import Prelude hiding (init, map) import

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread Leon Smith
On Fri, May 10, 2013 at 9:00 AM, Andres Löh and...@well-typed.com wrote: This twist is very simple to deal with if you have real existential types, with the relevant part of the interface looking approximately like init :: exists a. IO (Inotify a) addWatch :: Inotify a - FilePath - IO

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread Leon Smith
On Fri, May 10, 2013 at 9:04 AM, MigMit miguelim...@yandex.ru wrote: With that kind of interface you don't actually need existential types. Or phantom types. You can just keep Inotify inside the Watch, like this: Right, that is an alternative solution, but phantom types are a relatively

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread Alexander Solla
I'm not sure if it would work for your case, but have you considered using DataKinds instead of phantom types? At least, it seems like it would be cheap to try out. http://www.haskell.org/ghc/docs/7.4.2/html/users_guide/kind-polymorphism-and-promotion.html On Fri, May 10, 2013 at 12:52 PM,

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread Leon Smith
On Fri, May 10, 2013 at 5:49 PM, Alexander Solla alex.so...@gmail.comwrote: I'm not sure if it would work for your case, but have you considered using DataKinds instead of phantom types? At least, it seems like it would be cheap to try out.

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread Alexander Solla
On Fri, May 10, 2013 at 3:31 PM, Leon Smith leon.p.sm...@gmail.com wrote: On Fri, May 10, 2013 at 5:49 PM, Alexander Solla alex.so...@gmail.comwrote: I'm not sure if it would work for your case, but have you considered using DataKinds instead of phantom types? At least, it seems like it

Re: [Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread Leon Smith
A value has an indefinite extent if it's lifetime is independent of any block of code or related program structure, think malloc/free or new/gc. A value has a dynamic extent if is lifetime is statically determined relative to the dynamic execution of the program (e.g. a stack variable): in this

[Haskell-cafe] A use case for *real* existential types

2013-05-10 Thread oleg
But Haskell (and GHC) have existential types, and your prototype code works with GHC after a couple of trivial changes: main = do W nd0 - init wd0 - addWatch nd0 foo wd1 - addWatch nd0 bar W nd1 - init wd3 - addWatch nd1 baz printInotifyDesc nd0 printInotifyDesc nd1