... | @@ -5,8 +5,8 @@ |
... | @@ -5,8 +5,8 @@ |
|
|
|
|
|
Relevant links
|
|
Relevant links
|
|
|
|
|
|
- [ Thomas Winant's blog post](https://www.fpcomplete.com/user/thomasw/new-in-ghc-7-10-partial-type-signatures)
|
|
- [Thomas Winant's blog post](https://www.fpcomplete.com/user/thomasw/new-in-ghc-7-10-partial-type-signatures)
|
|
- Ticket to track progress: [\#9478](https://gitlab.haskell.org//ghc/ghc/issues/9478)
|
|
- Ticket to track progress: [\#9478](https://gitlab.haskell.org/ghc/ghc/issues/9478)
|
|
|
|
|
|
|
|
|
|
|
|
|
... | @@ -32,11 +32,11 @@ We have been working on a design and an implementation of them for |
... | @@ -32,11 +32,11 @@ We have been working on a design and an implementation of them for |
|
Haskell and GHC. We have worked out the interaction with
|
|
Haskell and GHC. We have worked out the interaction with
|
|
OutsideIn(X) type inference
|
|
OutsideIn(X) type inference
|
|
and generalisation in a
|
|
and generalisation in a
|
|
[ paper](https://lirias.kuleuven.be/bitstream/123456789/423475/3/paper.pdf)
|
|
[paper](https://lirias.kuleuven.be/bitstream/123456789/423475/3/paper.pdf)
|
|
presented at [ PADL'14](http://www.ist.unomaha.edu/padl2014/) and
|
|
presented at [PADL'14](http://www.ist.unomaha.edu/padl2014/) and
|
|
a [ technical report with proofs](https://lirias.kuleuven.be/bitstream/123456789/424883/1/CW649.pdf).
|
|
a [technical report with proofs](https://lirias.kuleuven.be/bitstream/123456789/424883/1/CW649.pdf).
|
|
This document attempts to describe our design and our
|
|
This document attempts to describe our design and our
|
|
[ current implementation](https://github.com/mrBliss/ghc) from a more practical
|
|
[current implementation](https://github.com/mrBliss/ghc) from a more practical
|
|
point of view in the hope to get some feedback from the GHC developers
|
|
point of view in the hope to get some feedback from the GHC developers
|
|
community.
|
|
community.
|
|
|
|
|
... | @@ -50,21 +50,21 @@ Use Keyword = `PartialTypeSignatures` to ensure that a ticket ends up on these l |
... | @@ -50,21 +50,21 @@ Use Keyword = `PartialTypeSignatures` to ensure that a ticket ends up on these l |
|
|
|
|
|
**Open Tickets:**
|
|
**Open Tickets:**
|
|
|
|
|
|
<table><tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10875">#10875</a></th>
|
|
<table><tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10875">#10875</a></th>
|
|
<td>Unexpected defaulting of partial type signatures and inconsistent behaviour when -fdefer-typed-holes is set.</td></tr>
|
|
<td>Unexpected defaulting of partial type signatures and inconsistent behaviour when -fdefer-typed-holes is set.</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11641">#11641</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11641">#11641</a></th>
|
|
<td>Allow wildcards for parameters functionally determined (also type synonyms)</td></tr>
|
|
<td>Allow wildcards for parameters functionally determined (also type synonyms)</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14040">#14040</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14040">#14040</a></th>
|
|
<td>Typed holes regression in GHC 8.0.2: No skolem info: z_a1sY[sk:2]</td></tr>
|
|
<td>Typed holes regression in GHC 8.0.2: No skolem info: z_a1sY[sk:2]</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14662">#14662</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14662">#14662</a></th>
|
|
<td>Partial type signatures + mutual recursion = confusion</td></tr>
|
|
<td>Partial type signatures + mutual recursion = confusion</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14766">#14766</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14766">#14766</a></th>
|
|
<td>Hole-y partial type signatures greatly slow down compile times</td></tr>
|
|
<td>Hole-y partial type signatures greatly slow down compile times</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/15433">#15433</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/15433">#15433</a></th>
|
|
<td>Internal error with PartialTypeSignatures and TH</td></tr>
|
|
<td>Internal error with PartialTypeSignatures and TH</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/16152">#16152</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/16152">#16152</a></th>
|
|
<td>Core lint error from PartialTypeSignatures</td></tr>
|
|
<td>Core lint error from PartialTypeSignatures</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/16203">#16203</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/16203">#16203</a></th>
|
|
<td>Unhelpful names for wildcard type variables</td></tr></table>
|
|
<td>Unhelpful names for wildcard type variables</td></tr></table>
|
|
|
|
|
|
|
|
|
... | @@ -72,19 +72,19 @@ Use Keyword = `PartialTypeSignatures` to ensure that a ticket ends up on these l |
... | @@ -72,19 +72,19 @@ Use Keyword = `PartialTypeSignatures` to ensure that a ticket ends up on these l |
|
|
|
|
|
**Closed Tickets:**
|
|
**Closed Tickets:**
|
|
|
|
|
|
<table><tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10242">#10242</a></th>
|
|
<table><tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10242">#10242</a></th>
|
|
<td>Multiple constraint wildcards allowed with PartialTypeSignatures</td></tr>
|
|
<td>Multiple constraint wildcards allowed with PartialTypeSignatures</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14265">#14265</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14265">#14265</a></th>
|
|
<td>kinded holes</td></tr>
|
|
<td>kinded holes</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14643">#14643</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14643">#14643</a></th>
|
|
<td>Partial type signatures in class constraints behave unexpectedly</td></tr>
|
|
<td>Partial type signatures in class constraints behave unexpectedly</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14658">#14658</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14658">#14658</a></th>
|
|
<td>'Fix two more bugs in partial signatures' broke T10846</td></tr>
|
|
<td>'Fix two more bugs in partial signatures' broke T10846</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14715">#14715</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14715">#14715</a></th>
|
|
<td>GHC 8.4.1-alpha regression with PartialTypeSignatures</td></tr>
|
|
<td>GHC 8.4.1-alpha regression with PartialTypeSignatures</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/15039">#15039</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/15039">#15039</a></th>
|
|
<td>Bizarre pretty-printing of inferred Coercible constraint in partial type signature</td></tr>
|
|
<td>Bizarre pretty-printing of inferred Coercible constraint in partial type signature</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/16334">#16334</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/16334">#16334</a></th>
|
|
<td>Named wildcards in kinds</td></tr></table>
|
|
<td>Named wildcards in kinds</td></tr></table>
|
|
|
|
|
|
|
|
|
... | @@ -179,7 +179,7 @@ normal type signature? |
... | @@ -179,7 +179,7 @@ normal type signature? |
|
|
|
|
|
- **Uninferrable types** Some types cannot be inferred, see the
|
|
- **Uninferrable types** Some types cannot be inferred, see the
|
|
following program (example adapted from
|
|
following program (example adapted from
|
|
[ Practical type inference for arbitrary-rank types](http://research.microsoft.com/en-us/um/people/simonpj/Papers/higher-rank/)).
|
|
[Practical type inference for arbitrary-rank types](http://research.microsoft.com/en-us/um/people/simonpj/Papers/higher-rank/)).
|
|
|
|
|
|
```wiki
|
|
```wiki
|
|
foo x = (x [True, False], x ['a', 'b'])
|
|
foo x = (x [True, False], x ['a', 'b'])
|
... | @@ -214,11 +214,11 @@ normal type signature? |
... | @@ -214,11 +214,11 @@ normal type signature? |
|
```
|
|
```
|
|
|
|
|
|
- **Community** Feature requests or wiki pages for partial type
|
|
- **Community** Feature requests or wiki pages for partial type
|
|
signatures in some form or other already exist: [\#5248](https://gitlab.haskell.org//ghc/ghc/issues/5248),
|
|
signatures in some form or other already exist: [\#5248](https://gitlab.haskell.org/ghc/ghc/issues/5248),
|
|
[ PartialTypeSigs](https://ghc.haskell.org/trac/haskell-prime/wiki/PartialTypeSigs),
|
|
[PartialTypeSigs](https://ghc.haskell.org/trac/haskell-prime/wiki/PartialTypeSigs),
|
|
[ PartialTypeAnnotations](https://ghc.haskell.org/trac/haskell-prime/wiki/PartialTypeAnnotations).
|
|
[PartialTypeAnnotations](https://ghc.haskell.org/trac/haskell-prime/wiki/PartialTypeAnnotations).
|
|
More recently,
|
|
More recently,
|
|
[ a question popped up on Stack Overflow](http://stackoverflow.com/questions/21658438/how-to-define-function-signatures-partially-in-haskell)
|
|
[a question popped up on Stack Overflow](http://stackoverflow.com/questions/21658438/how-to-define-function-signatures-partially-in-haskell)
|
|
asking if there is such a thing as partial type signatures for
|
|
asking if there is such a thing as partial type signatures for
|
|
Haskell. Judging from the comments on our answer, people seemed to
|
|
Haskell. Judging from the comments on our answer, people seemed to
|
|
be interested. After presenting the paper at PADL'14, people told us
|
|
be interested. After presenting the paper at PADL'14, people told us
|
... | @@ -256,7 +256,7 @@ you say something like `monadicComputation :: _ Int` etc. |
... | @@ -256,7 +256,7 @@ you say something like `monadicComputation :: _ Int` etc. |
|
|
|
|
|
|
|
|
|
Other workarounds exist as well (see the
|
|
Other workarounds exist as well (see the
|
|
[ paper](https://lirias.kuleuven.be/bitstream/123456789/423475/3/paper.pdf)
|
|
[paper](https://lirias.kuleuven.be/bitstream/123456789/423475/3/paper.pdf)
|
|
for a discussion). They are typically based on adding computationally
|
|
for a discussion). They are typically based on adding computationally
|
|
useless functions or dead code and we find them all less natural and
|
|
useless functions or dead code and we find them all less natural and
|
|
elegant than our partial signatures.
|
|
elegant than our partial signatures.
|
... | @@ -620,7 +620,7 @@ messages. |
... | @@ -620,7 +620,7 @@ messages. |
|
|
|
|
|
Alejandro Serrano Mena has added Emacs support for interacting with TypedHoles
|
|
Alejandro Serrano Mena has added Emacs support for interacting with TypedHoles
|
|
during his
|
|
during his
|
|
[ GSOC project](http://serras-haskell-gsoc.blogspot.com/2014/08/summer-of-code-on-emacs.html).
|
|
[GSOC project](http://serras-haskell-gsoc.blogspot.com/2014/08/summer-of-code-on-emacs.html).
|
|
He told me this should work fine with [PartialTypeSignatures](partial-type-signatures) as it is, but we
|
|
He told me this should work fine with [PartialTypeSignatures](partial-type-signatures) as it is, but we
|
|
would like to add the ability to let Emacs fill in the hole's inferred type
|
|
would like to add the ability to let Emacs fill in the hole's inferred type
|
|
at the press of a key. We will look into this.
|
|
at the press of a key. We will look into this.
|
... | @@ -676,7 +676,7 @@ partial type signature. |
... | @@ -676,7 +676,7 @@ partial type signature. |
|
|
|
|
|
GHC is slightly more liberal than the strict rule described in the
|
|
GHC is slightly more liberal than the strict rule described in the
|
|
OutsideIn(X) paper though.
|
|
OutsideIn(X) paper though.
|
|
As explained in [ Let generalisation in GHC 7.0](https://ghc.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7),
|
|
As explained in [Let generalisation in GHC 7.0](https://ghc.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7),
|
|
even with the MonoLocalBinds
|
|
even with the MonoLocalBinds
|
|
extension enabled, a local binding without a type signature will still
|
|
extension enabled, a local binding without a type signature will still
|
|
be generalised when all its free variables are closed. Translating
|
|
be generalised when all its free variables are closed. Translating
|
... | @@ -728,7 +728,7 @@ usefulness. |
... | @@ -728,7 +728,7 @@ usefulness. |
|
We worked out a rigorous formalisation of partial type signatures
|
|
We worked out a rigorous formalisation of partial type signatures
|
|
including typing rules, extending the existing formalisation of GHC's
|
|
including typing rules, extending the existing formalisation of GHC's
|
|
type inference system, OutsideIn(X)
|
|
type inference system, OutsideIn(X)
|
|
(as [ described](http://research.microsoft.com/apps/pubs/default.aspx?id=162516)
|
|
(as [described](http://research.microsoft.com/apps/pubs/default.aspx?id=162516)
|
|
in *OutsideIn(X): Modular
|
|
in *OutsideIn(X): Modular
|
|
type inference with local assumptions*). Additionally, we proved
|
|
type inference with local assumptions*). Additionally, we proved
|
|
soundness of our new typing rules.
|
|
soundness of our new typing rules.
|
... | @@ -746,7 +746,7 @@ have the same effect as the old rules. |
... | @@ -746,7 +746,7 @@ have the same effect as the old rules. |
|
|
|
|
|
|
|
|
|
See the
|
|
See the
|
|
[ technical report](https://lirias.kuleuven.be/bitstream/123456789/424883/1/CW649.pdf)
|
|
[technical report](https://lirias.kuleuven.be/bitstream/123456789/424883/1/CW649.pdf)
|
|
for more details.
|
|
for more details.
|
|
|
|
|
|
---
|
|
---
|
... | @@ -755,7 +755,7 @@ for more details. |
... | @@ -755,7 +755,7 @@ for more details. |
|
|
|
|
|
|
|
|
|
We implemented our proposal as a branch of GHC (master), available at
|
|
We implemented our proposal as a branch of GHC (master), available at
|
|
[ github](https://github.com/mrBliss/ghc). This version can be compiled and
|
|
[github](https://github.com/mrBliss/ghc). This version can be compiled and
|
|
should type check the majority of the examples in this proposal.
|
|
should type check the majority of the examples in this proposal.
|
|
|
|
|
|
|
|
|
... | @@ -816,7 +816,7 @@ Here is a summary of the changes we have made in the implementation: |
... | @@ -816,7 +816,7 @@ Here is a summary of the changes we have made in the implementation: |
|
|
|
|
|
- We extended Haddock as well to handle partial type signatures. A single
|
|
- We extended Haddock as well to handle partial type signatures. A single
|
|
commit updating the GHC API and adding printing capabilities can be found in
|
|
commit updating the GHC API and adding printing capabilities can be found in
|
|
our fork of Haddock on [ github](https://github.com/mrBliss/haddock).
|
|
our fork of Haddock on [github](https://github.com/mrBliss/haddock).
|
|
|
|
|
|
### Notes
|
|
### Notes
|
|
|
|
|
... | @@ -875,7 +875,7 @@ some things that may be non-obvious. |
... | @@ -875,7 +875,7 @@ some things that may be non-obvious. |
|
GADTs and
|
|
GADTs and
|
|
TypeFamilies!),
|
|
TypeFamilies!),
|
|
as [intended](partial-type-signatures#). However, for functions affected
|
|
as [intended](partial-type-signatures#). However, for functions affected
|
|
by this restriction (i.e. [ not all free variables are closed](https://ghc.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7#Whichbindingsareaffected)),
|
|
by this restriction (i.e. [not all free variables are closed](https://ghc.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7#Whichbindingsareaffected)),
|
|
partial type signatures aren't properly handled.
|
|
partial type signatures aren't properly handled.
|
|
|
|
|
|
```wiki
|
|
```wiki
|
... | @@ -974,7 +974,7 @@ some things that may be non-obvious. |
... | @@ -974,7 +974,7 @@ some things that may be non-obvious. |
|
|
|
|
|
>
|
|
>
|
|
>
|
|
>
|
|
> Related feature request for TypedHoles: [\#9091](https://gitlab.haskell.org//ghc/ghc/issues/9091).
|
|
> Related feature request for TypedHoles: [\#9091](https://gitlab.haskell.org/ghc/ghc/issues/9091).
|
|
>
|
|
>
|
|
>
|
|
>
|
|
|
|
|
... | @@ -1010,7 +1010,7 @@ some things that may be non-obvious. |
... | @@ -1010,7 +1010,7 @@ some things that may be non-obvious. |
|
|
|
|
|
|
|
|
|
Regarding the
|
|
Regarding the
|
|
[ monomorphism restriction](http://www.haskell.org/onlinereport/decls.html#sect4.5.5),
|
|
[monomorphism restriction](http://www.haskell.org/onlinereport/decls.html#sect4.5.5),
|
|
the existing rules apply. Declarations with a partial type signature
|
|
the existing rules apply. Declarations with a partial type signature
|
|
are treated as declarations without a type signature. Therefore, these
|
|
are treated as declarations without a type signature. Therefore, these
|
|
declarations will be *restricted*, and constrained type variables of
|
|
declarations will be *restricted*, and constrained type variables of
|
... | | ... | |