GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:00:27Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/16339Cannot put (.) or (!) type operators into an export list2019-07-07T18:00:27ZRyan ScottCannot put (.) or (!) type operators into an export listThanks to recent work in GHC HEAD, it is now possible to define type operators named `(.)` and `(!)`:
```hs
type (f . g) x = f (g x)
type x ! f = f x
```
However, I was surprised to discover that it's not possible to put them in an exp...Thanks to recent work in GHC HEAD, it is now possible to define type operators named `(.)` and `(!)`:
```hs
type (f . g) x = f (g x)
type x ! f = f x
```
However, I was surprised to discover that it's not possible to put them in an export list! That is to say, this program doesn't parse:
```
{-# LANGUAGE TypeOperators #-}
module Bug (type (.), type (!)) where
type (f . g) x = f (g x)
type x ! f = f x
```
```
$ ~/Software/ghc4/inplace/bin/ghc-stage2 --interactive Bug.hs
GHCi, version 8.7.20190219: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
Bug.hs:2:19: error: parse error on input ‘.’
|
2 | module Bug (type (.), type (!)) where
| ^
```
This problem appears to be specific to the `(.)` and `(!)` type operators, since any other type operator will work in its place:
```hs
{-# LANGUAGE TypeOperators #-}
module Works (type (&)) where
type (f & g) x = f (g x)
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------- |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Parser) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | int-index |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Cannot put (.) or (!) into an export list","status":"New","operating_system":"","component":"Compiler (Parser)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["int-index"],"type":"Bug","description":"Thanks to recent work in GHC HEAD, it is now possible to define type operators named `(.)` and `(!)`:\r\n\r\n{{{#!hs\r\ntype (f . g) x = f (g x)\r\ntype x ! f = f x\r\n}}}\r\n\r\nHowever, I was surprised to discover that it's not possible to put them in an export list! That is to say, this program doesn't parse:\r\n\r\n{{{\r\n{-# LANGUAGE TypeOperators #-}\r\nmodule Bug (type (.), type (!)) where\r\n\r\ntype (f . g) x = f (g x)\r\ntype x ! f = f x\r\n}}}\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghc-stage2 --interactive Bug.hs\r\nGHCi, version 8.7.20190219: https://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n\r\nBug.hs:2:19: error: parse error on input ‘.’\r\n |\r\n2 | module Bug (type (.), type (!)) where\r\n | ^\r\n}}}\r\n\r\nThis problem appears to be specific to the `(.)` and `(!)` type operators, since any other type operator will work in its place:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TypeOperators #-}\r\nmodule Works (type (&)) where\r\n\r\ntype (f & g) x = f (g x)\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/16311Suggest -XExistentialQuantification for 'forall' in data declarations2019-07-07T18:00:34ZVladislav ZavialovSuggest -XExistentialQuantification for 'forall' in data declarations[D5180](https://phabricator.haskell.org/D5180) introduced a slight regression to the error messages. In this code
```hs
data T = forall a. MkT a
```
GHC used to complain
```
rnfail053.hs:5:10:
Not a data constructor: ‘forall’
...[D5180](https://phabricator.haskell.org/D5180) introduced a slight regression to the error messages. In this code
```hs
data T = forall a. MkT a
```
GHC used to complain
```
rnfail053.hs:5:10:
Not a data constructor: ‘forall’
Perhaps you intended to use ExistentialQuantification
```
but then the message has become
```
rnfail053.hs:5:18: error:
Illegal symbol '.' in type
Perhaps you intended to use RankNTypes or a similar language
extension to enable explicit-forall syntax: forall <tvs>. <type>
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------- |
| Version | 8.6.3 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Parser) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Suggest -XExistentialQuantification for 'forall' in data declarations","status":"New","operating_system":"","component":"Compiler (Parser)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"Phab:D5180 introduced a slight regression to the error messages. In this code\r\n\r\n{{{#!hs\r\ndata T = forall a. MkT a\r\n}}}\r\n\r\nGHC used to complain\r\n\r\n{{{\r\nrnfail053.hs:5:10:\r\n Not a data constructor: ‘forall’\r\n Perhaps you intended to use ExistentialQuantification\r\n}}}\r\n\r\nbut then the message has become\r\n\r\n{{{\r\nrnfail053.hs:5:18: error:\r\n Illegal symbol '.' in type\r\n Perhaps you intended to use RankNTypes or a similar language\r\n extension to enable explicit-forall syntax: forall <tvs>. <type>\r\n}}}\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/16195Program with trivial polymorphism leads to out of scope dictionary2019-07-07T18:01:00ZMatthew PickeringProgram with trivial polymorphism leads to out of scope dictionaryAlmost certainly due to c2455e647501c5a382861196b64df3dd05b620a2
A trivial program now causes a core lint error due to an out-of-scope dictionary.
```
module A where
foo :: Code (IO ())
foo = [|| return () ||]
```
```
module B where
...Almost certainly due to c2455e647501c5a382861196b64df3dd05b620a2
A trivial program now causes a core lint error due to an out-of-scope dictionary.
```
module A where
foo :: Code (IO ())
foo = [|| return () ||]
```
```
module B where
main :: IO ()
main = $$foo
```
```
*** Core Lint errors : in result of Desugar (before optimization) ***
<no location info>: warning:
In the expression: return @ IO $dMonad_a4od @ () ()
Out of scope: $dMonad_a4od :: Monad m_a4oc[tau:0]
[LclId]
*** Offending Program ***
Rec {
$trModule :: Module
[LclIdX]
$trModule = Module (TrNameS "main"#) (TrNameS "B"#)
main :: IO ()
[LclIdX]
main = return @ IO $dMonad_a4od @ () ()
end Rec }
*** End of Offense ***
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Program with trivial polymorphism leads to out of scope dictionary","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypedTemplateHaskell"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Almost certainly due to c2455e647501c5a382861196b64df3dd05b620a2\r\n\r\nA trivial program now causes a core lint error due to an out-of-scope dictionary. \r\n\r\n{{{\r\nmodule A where\r\n\r\nfoo :: Code (IO ())\r\nfoo = [|| return () ||]\r\n}}}\r\n\r\n{{{\r\nmodule B where\r\n\r\nmain :: IO ()\r\nmain = $$foo\r\n}}}\r\n\r\n{{{\r\n*** Core Lint errors : in result of Desugar (before optimization) ***\r\n<no location info>: warning:\r\n In the expression: return @ IO $dMonad_a4od @ () ()\r\n Out of scope: $dMonad_a4od :: Monad m_a4oc[tau:0]\r\n [LclId]\r\n*** Offending Program ***\r\nRec {\r\n$trModule :: Module\r\n[LclIdX]\r\n$trModule = Module (TrNameS \"main\"#) (TrNameS \"B\"#)\r\n\r\nmain :: IO ()\r\n[LclIdX]\r\nmain = return @ IO $dMonad_a4od @ () ()\r\nend Rec }\r\n\r\n*** End of Offense ***\r\n}}}\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1