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

Leon Smith leon.p.smith at gmail.com
Sat May 11 01:02:10 CEST 2013


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 case the type system ensures that no references to the inotify
descriptor can exist after the callback returns.

Best,
Leon


On Fri, May 10, 2013 at 6:52 PM, Alexander Solla <alex.solla at gmail.com>wrote:

>
>
>
> On Fri, May 10, 2013 at 3:31 PM, Leon Smith <leon.p.smith at gmail.com>wrote:
>
>> On Fri, May 10, 2013 at 5:49 PM, Alexander Solla <alex.solla at gmail.com>wrote:
>>
>>> 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
>>>
>>
>> I do like DataKinds a lot,  and I did think about them a little bit with
>> respect to this problem,  but a solution isn't obvious to me,  and perhaps
>> more importantly I'd like to be able to support older versions of GHC,
>>  probably back to 7.0 at least.
>>
>> The issue is that every call to init needs to return a slightly different
>> type,  and whether this is achieved via phantom types or datakinds,  it
>> seems to me some form of existential typing is required.  As both Andres
>> and MigMit pointed out,  you can sort of achieve this by using a
>> continuation-like construction and higher-ranked types (is there a name for
>> this transform?  I've seen it a number of times and it is pretty well
>> known...),  but this enforces a dynamic extent on the descriptor whereas
>> the original interface I proposed allows an indefinite extent.
>>
>
> I know what extensions (of predicates and the like) are, but what exactly
> does "dynamic" and "indefinite" mean in this context?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130510/f07705aa/attachment.htm>


More information about the Haskell-Cafe mailing list