[ghc-steering-committee] Proposal #111: Linear Types

Richard Eisenberg rae at cs.brynmawr.edu
Mon Aug 27 21:33:26 UTC 2018


Let's keep the conversation going here. I know this is a *big* proposal, but we owe it to the authors to form a quorum-based consensus (I'd love more voices in these threads!) and offer a response.

> On Aug 7, 2018, at 1:50 AM, Iavor Diatchki <iavor.diatchki at gmail.com> wrote:
> 
> The main high level concern I have is the overloading of the function space arrow.  We already have it overloaded in all kinds of ways, and adding one more dimension without any kind of underlying system seems too much.  I am not at all convinced that we will be able to "hide" multiplicities when the extension is not enabled.

I agree. I've mused about making (->) be indexed by a type-level record. Right now, that record would look like

> data ArrowIndex = ArrowIndex { argRep :: RuntimeRep, resRep :: RuntimeRep }
> (->) :: forall (ind :: ArrowIndex). TYPE (argRep ind) -> TYPE (resRep ind) -> Type

With this proposal, we move up to

> data ArrowIndex = ArrowIndex { argRep :: RuntimeRep, resRep :: RuntimeRep, multiplicity :: Multiplicity }
> (->) :: forall (ind :: ArrowIndex). TYPE (argRep ind) -> TYPE (resRep ind) -> Type

But I don't have great ideas of how to make this work syntactically -- never mind the fact we don't have type-level records yet.

> 
> Overall, while I like the core ideas, I would prefer a different way of integrating them into Haskell, one that is more modular, even at the cost of having to duplicate some code.  My reasoning is that while linearity might be useful in some cases, most of the time it is not something that we'd care about much, so we should not add it (at least straight away) to the core part of the language (functions and data types).

Is this essentially proposing that we don't make any change to datatypes? That would mean that a library that wishes to have linear datatypes would have to explicitly declare them as such. I think this is a stable middle ground. But, if we can guarantee good error-message behavior, etc., I think the "default datatypes to linear" behavior is the right one.

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20180827/09b431ae/attachment.html>


More information about the ghc-steering-committee mailing list