[Git][ghc/ghc][master] 2 commits: LinearTypes => MonoLocalBinds

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Dec 12 09:37:21 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00
LinearTypes => MonoLocalBinds

- - - - -
8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00
Linear let and where bindings

For expediency, the initial implementation of linear types in GHC
made it so that let and where binders would always be considered
unrestricted. This was rather unpleasant, and probably a big obstacle
to adoption. At any rate, this was not how the proposal was designed.

This patch fixes this infelicity. It was surprisingly difficult to
build, which explains, in part, why it took so long to materialise.

As of this patch, let or where bindings marked with %1 will be
linear (respectively %p for an arbitrary multiplicity p). Unmarked let
will infer their multiplicity.

Here is a prototypical example of program that used to be rejected and
is accepted with this patch:

```haskell
f :: A %1 -> B
g :: B %1 -> C

h :: A %1 -> C
h x = g y
  where
    y = f x
```

Exceptions:
- Recursive let are unrestricted, as there isn't a clear semantics of
  what a linear recursive binding would be.
- Destructive lets with lazy bindings are unrestricted, as their
  desugaring isn't linear (see also #23461).
- (Strict) destructive lets with inferred polymorphic type are
  unrestricted. Because the desugaring isn't linear (See #18461
  down-thread).

Closes #18461 and #18739

Co-authored-by: @jackohughes

- - - - -


30 changed files:

- compiler/GHC/Core.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Arrows.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/ListComp.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match.hs-boot
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Tc/Gen/Arrow.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Match.hs-boot
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Utils/Env.hs
- + compiler/GHC/Tc/Utils/TcMType.hs-boot
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/ThToHs.hs
- compiler/Language/Haskell/Syntax/Binds.hs
- docs/users_guide/9.10.1-notes.rst
- docs/users_guide/exts/linear_types.rst


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/522c12a43b34ad4ca7f3f916fa630d33a4fe6efb...8e0446dfd79099403d005e04f63ea49496b1cab3

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/522c12a43b34ad4ca7f3f916fa630d33a4fe6efb...8e0446dfd79099403d005e04f63ea49496b1cab3
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231212/0784d126/attachment.html>


More information about the ghc-commits mailing list