GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:01:56Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/16033Rank-n typechecking regression between GHC 8.4 and 8.62019-07-07T18:01:56ZRyan ScottRank-n typechecking regression between GHC 8.4 and 8.6The following program typechecks on GHC 7.0.4 through 8.4.4:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Bug where
f :: (forall a. a -> forall b. b -> c) -> ()
f (_ :: forall...The following program typechecks on GHC 7.0.4 through 8.4.4:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Bug where
f :: (forall a. a -> forall b. b -> c) -> ()
f (_ :: forall a. a -> forall b. b -> c) = ()
```
However, it does not typecheck on GHC 8.6.3:
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:7:4: error:
• Couldn't match type ‘b0 -> c1’ with ‘forall b. b -> c’
Expected type: a -> forall b. b -> c
Actual type: a -> b0 -> c1
• When checking that the pattern signature:
forall a. a -> forall b. b -> c
fits the type of its context: forall a. a -> forall b. b -> c1
In the pattern: _ :: forall a. a -> forall b. b -> c
In an equation for ‘f’:
f (_ :: forall a. a -> forall b. b -> c) = ()
• Relevant bindings include
f :: (forall a. a -> forall b. b -> c1) -> () (bound at Bug.hs:7:1)
|
7 | f (_ :: forall a. a -> forall b. b -> c) = ()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/16032Compile speed regression2019-07-07T18:01:57Zlennart@augustsson.netCompile speed regressionGHC 8.6.3 seems to be about 10% slower than GHC 8.4.4 compiling a large input. The times goes from 22.25m to 24.5m.
Unfortunately, I cannot include the modules to reproduce it.
<details><summary>Trac metadata</summary>
| Trac field ...GHC 8.6.3 seems to be about 10% slower than GHC 8.4.4 compiling a large input. The times goes from 22.25m to 24.5m.
Unfortunately, I cannot include the modules to reproduce it.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Compile speed regression","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC 8.6.3 seems to be about 10% slower than GHC 8.4.4 compiling a large input. The times goes from 22.25m to 24.5m.\r\n\r\nUnfortunately, I cannot include the modules to reproduce it.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/16031Show instance for Data.Fixed does not show parentheses for negatives2019-07-07T18:01:57ZSteven KeuchelShow instance for Data.Fixed does not show parentheses for negativesWhen showing negative numbers most types emit parentheses in precedence level 11 because the result is not atomic:
```hs
GHCi, version 8.7.20181015: http://www.haskell.org/ghc/ :? for help
Prelude> show (Just (-1 :: Int))
"Just (-1)"
P...When showing negative numbers most types emit parentheses in precedence level 11 because the result is not atomic:
```hs
GHCi, version 8.7.20181015: http://www.haskell.org/ghc/ :? for help
Prelude> show (Just (-1 :: Int))
"Just (-1)"
Prelude> show (Just (-1 :: Float))
"Just (-1.0)"
```
However, the Show instance for Fixed does not
```hs
Prelude> :m Data.Fixed
Prelude Data.Fixed> show (Just (-1 :: Fixed E2))
"Just -1.00"
Prelude Data.Fixed>
```
I would expect it to, because of consistency and because the result "Just -1.00" is ill-typed when seen as an expression.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Show instance for Data.Fixed does not show parentheses for negatives","status":"New","operating_system":"","component":"libraries/base","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["Data.Fixed,","Show"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When showing negative numbers most types emit parentheses in precedence level 11 because the result is not atomic: \r\n\r\n{{{#!hs\r\nGHCi, version 8.7.20181015: http://www.haskell.org/ghc/ :? for help\r\nPrelude> show (Just (-1 :: Int))\r\n\"Just (-1)\"\r\nPrelude> show (Just (-1 :: Float))\r\n\"Just (-1.0)\"\r\n}}}\r\n\r\nHowever, the Show instance for Fixed does not\r\n\r\n{{{#!hs\r\nPrelude> :m Data.Fixed\r\nPrelude Data.Fixed> show (Just (-1 :: Fixed E2))\r\n\"Just -1.00\"\r\nPrelude Data.Fixed> \r\n}}}\r\n\r\nI would expect it to, because of consistency and because the result \"Just -1.00\" is ill-typed when seen as an expression.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1Sven TennieSven Tenniehttps://gitlab.haskell.org/ghc/ghc/-/issues/16030Poor pretty-printing of GADT constructors in GHCi2019-07-07T18:01:57ZRyan ScottPoor pretty-printing of GADT constructors in GHCiI recently loaded this file into GHCi:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Data.Proxy
data Foo1 (a :: k) where
MkFoo1a :: Proxy a -> Int -> Foo1 a
MkFoo1b :...I recently loaded this file into GHCi:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Data.Proxy
data Foo1 (a :: k) where
MkFoo1a :: Proxy a -> Int -> Foo1 a
MkFoo1b :: { a :: Proxy a, b :: Int } -> Foo1 a
data family Foo2 (a :: k)
data instance Foo2 (a :: k) where
MkFoo2a :: Proxy a -> Int -> Foo2 a
MkFoo2b :: { c :: Proxy a, d :: Int} -> Foo2 a
```
And when I queried these datatypes with `:info`, I saw this:
```
$ ~/Software/ghc/inplace/bin/ghc-stage2 --interactive Bug.hs -fprint-explicit-kinds
GHCi, version 8.7.20181129: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Ok, one module loaded.
λ> :i Foo1 Foo2
type role Foo1 nominal phantom
data Foo1 @k (a :: k) where
MkFoo1a :: forall k (a :: k). (Proxy @{k} a) -> Int -> Foo1 k a
MkFoo1b :: forall k (a :: k).
{a :: Proxy @{k} a, b :: Int} -> Foo1 k a
-- Defined at Bug.hs:8:1
data family Foo2 @k (a :: k) -- Defined at Bug.hs:12:1
data instance forall k (a :: k). Foo2 @k a where
MkFoo2a :: forall k (a :: k). (Proxy @{k} a) -> Int -> Foo2 @k a
MkFoo2b :: forall k (a :: k).
{c :: Proxy @{k} a, d :: Int} -> Foo2 @k a
-- Defined at Bug.hs:13:15
```
Yuck. A couple of icky things to note here:
- For some reason, the `Proxy @{k} a` field is needlessly parenthesized in `MkFoo1a` and `MkFoo2a`. This does //not// happen when record syntax is used, as demonstrated with `MkFoo1b` and `MkFoo2b`.
- Even more strangely, despite the fact that `k` is a specified argument, we're pretty-printing the return type of `MkFoo1{a,b}` as `Foo k a`, not `Foo @k a`. This problem doesn't appear to happen for data family instances, since `MkFoo2{a,b}` don't have this issue.
Patch incoming.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Poor pretty-printing of GADT constructors in GHCi","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I recently loaded this file into GHCi:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\nmodule Bug where\r\n\r\nimport Data.Proxy\r\n\r\ndata Foo1 (a :: k) where\r\n MkFoo1a :: Proxy a -> Int -> Foo1 a\r\n MkFoo1b :: { a :: Proxy a, b :: Int } -> Foo1 a\r\n\r\ndata family Foo2 (a :: k)\r\ndata instance Foo2 (a :: k) where\r\n MkFoo2a :: Proxy a -> Int -> Foo2 a\r\n MkFoo2b :: { c :: Proxy a, d :: Int} -> Foo2 a\r\n}}}\r\n\r\nAnd when I queried these datatypes with `:info`, I saw this:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghc-stage2 --interactive Bug.hs -fprint-explicit-kinds\r\nGHCi, version 8.7.20181129: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\nOk, one module loaded.\r\nλ> :i Foo1 Foo2\r\ntype role Foo1 nominal phantom\r\ndata Foo1 @k (a :: k) where\r\n MkFoo1a :: forall k (a :: k). (Proxy @{k} a) -> Int -> Foo1 k a\r\n MkFoo1b :: forall k (a :: k).\r\n {a :: Proxy @{k} a, b :: Int} -> Foo1 k a\r\n -- Defined at Bug.hs:8:1\r\ndata family Foo2 @k (a :: k) -- Defined at Bug.hs:12:1\r\ndata instance forall k (a :: k). Foo2 @k a where\r\n MkFoo2a :: forall k (a :: k). (Proxy @{k} a) -> Int -> Foo2 @k a\r\n MkFoo2b :: forall k (a :: k).\r\n {c :: Proxy @{k} a, d :: Int} -> Foo2 @k a\r\n -- Defined at Bug.hs:13:15\r\n}}}\r\n\r\nYuck. A couple of icky things to note here:\r\n\r\n* For some reason, the `Proxy @{k} a` field is needlessly parenthesized in `MkFoo1a` and `MkFoo2a`. This does //not// happen when record syntax is used, as demonstrated with `MkFoo1b` and `MkFoo2b`.\r\n* Even more strangely, despite the fact that `k` is a specified argument, we're pretty-printing the return type of `MkFoo1{a,b}` as `Foo k a`, not `Foo @k a`. This problem doesn't appear to happen for data family instances, since `MkFoo2{a,b}` don't have this issue.\r\n\r\nPatch incoming.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/16029Inadequate absence analysis2019-07-07T18:01:57ZSimon Peyton JonesInadequate absence analysisConsider
```
data S = MkS Int Int
g1 :: S -> Int -> Int
g1 (MkS x y) 0 = 0
g1 (MkS x y) n = g1 (MkS y x) (n-1)
```
With GHC 8.6 we get
```
$wg1 :: S -> GHC.Prim.Int# -> GHC.Prim.Int#
[Str=<S,1*H><S,1*U>]
$wg1 = \ (w_s2oH :: S)
...Consider
```
data S = MkS Int Int
g1 :: S -> Int -> Int
g1 (MkS x y) 0 = 0
g1 (MkS x y) n = g1 (MkS y x) (n-1)
```
With GHC 8.6 we get
```
$wg1 :: S -> GHC.Prim.Int# -> GHC.Prim.Int#
[Str=<S,1*H><S,1*U>]
$wg1 = \ (w_s2oH :: S)
(ww_s2oL :: GHC.Prim.Int#) ->
case w_s2oH of { MkS x_s2pz y_s2pA ->
case ww_s2oL of ds_X2nb {
__DEFAULT ->
Foo.$wg1 (Foo.MkS y_s2pA x_s2pz) (GHC.Prim.-# ds_X2nb 1#);
0# -> 0# }}
g1 :: S -> Int -> Int
[Str=<S,1*H><S(S),1*U(1*U)>m]
g1 = \ (w_s2oH :: S) (w1_s2oI :: Int) ->
case w_s2oH of w2_X2pG { MkS ipv_s2p2 ipv1_s2p3 ->
case w1_s2oI of { GHC.Types.I# ww1_s2oL ->
case Foo.$wg1 w2_X2pG ww1_s2oL of ww2_s2oP { __DEFAULT ->
GHC.Types.I# ww2_s2oP }}}
```
What terrible code! We evaluate the S argument in the wrapper,
and box and unbox it every time around the loop, even though it is never ultimately used.
Here's what happens if the arguments are banged:
```
data T = MkT !Int !Int
g2 :: T -> Int -> Int
g2 (MkT x y) 0 = 0
g2 (MkT x y) n = g2 (MkT y x) (n-1)
```
We get
```
$wg2 GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int#
[Str=<L,1*U><L,1*U><S,1*U>]
Foo.$wg2 = \ (ww_s2ow :: GHC.Prim.Int#)
(ww1_s2ox :: GHC.Prim.Int#)
(ww2_s2oB :: GHC.Prim.Int#) ->
case ww2_s2oB of ds_X2n0 {
__DEFAULT -> Foo.$wg2 ww1_s2ox ww_s2ow (GHC.Prim.-# ds_X2n0 1#);
0# -> 0# }
g2 :: T -> Int -> Int
[Str=<S(SS),1*U(1*U,1*U)><S(S),1*U(1*U)>m ]
g2 = \ (w_s2os :: T) (w1_s2ot :: Int) ->
case w_s2os of { MkT ww1_s2ow ww2_s2ox ->
case w1_s2ot of { GHC.Types.I# ww4_s2oB ->
case Foo.$wg2 ww1_s2ow ww2_s2ox ww4_s2oB of ww5_s2oF {
__DEFAULT -> GHC.Types.I# ww5_s2oF }}}
```
Still terrible. We pass the two components around the loop before discarding them
at the end.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Inadequate absence analysis","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider\r\n{{{\r\ndata S = MkS Int Int\r\ng1 :: S -> Int -> Int\r\ng1 (MkS x y) 0 = 0\r\ng1 (MkS x y) n = g1 (MkS y x) (n-1)\r\n}}}\r\nWith GHC 8.6 we get\r\n{{{\r\n$wg1 :: S -> GHC.Prim.Int# -> GHC.Prim.Int#\r\n[Str=<S,1*H><S,1*U>]\r\n$wg1 = \\ (w_s2oH :: S)\r\n (ww_s2oL :: GHC.Prim.Int#) ->\r\n case w_s2oH of { MkS x_s2pz y_s2pA ->\r\n case ww_s2oL of ds_X2nb {\r\n __DEFAULT ->\r\n Foo.$wg1 (Foo.MkS y_s2pA x_s2pz) (GHC.Prim.-# ds_X2nb 1#);\r\n 0# -> 0# }}\r\n\r\ng1 :: S -> Int -> Int\r\n[Str=<S,1*H><S(S),1*U(1*U)>m]\r\ng1 = \\ (w_s2oH :: S) (w1_s2oI :: Int) ->\r\n case w_s2oH of w2_X2pG { MkS ipv_s2p2 ipv1_s2p3 ->\r\n case w1_s2oI of { GHC.Types.I# ww1_s2oL ->\r\n case Foo.$wg1 w2_X2pG ww1_s2oL of ww2_s2oP { __DEFAULT ->\r\n GHC.Types.I# ww2_s2oP }}}\r\n}}}\r\nWhat terrible code! We evaluate the S argument in the wrapper,\r\nand box and unbox it every time around the loop, even though it is never ultimately used.\r\n\r\nHere's what happens if the arguments are banged:\r\n{{{\r\ndata T = MkT !Int !Int\r\ng2 :: T -> Int -> Int\r\ng2 (MkT x y) 0 = 0\r\ng2 (MkT x y) n = g2 (MkT y x) (n-1)\r\n}}}\r\nWe get\r\n{{{\r\n$wg2 GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int#\r\n[Str=<L,1*U><L,1*U><S,1*U>]\r\nFoo.$wg2 = \\ (ww_s2ow :: GHC.Prim.Int#)\r\n (ww1_s2ox :: GHC.Prim.Int#)\r\n (ww2_s2oB :: GHC.Prim.Int#) ->\r\n case ww2_s2oB of ds_X2n0 {\r\n __DEFAULT -> Foo.$wg2 ww1_s2ox ww_s2ow (GHC.Prim.-# ds_X2n0 1#);\r\n 0# -> 0# }\r\n\r\ng2 :: T -> Int -> Int\r\n[Str=<S(SS),1*U(1*U,1*U)><S(S),1*U(1*U)>m ]\r\ng2 = \\ (w_s2os :: T) (w1_s2ot :: Int) ->\r\n case w_s2os of { MkT ww1_s2ow ww2_s2ox ->\r\n case w1_s2ot of { GHC.Types.I# ww4_s2oB ->\r\n case Foo.$wg2 ww1_s2ow ww2_s2ox ww4_s2oB of ww5_s2oF {\r\n __DEFAULT -> GHC.Types.I# ww5_s2oF }}}\r\n}}}\r\nStill terrible. We pass the two components around the loop before discarding them\r\nat the end.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3https://gitlab.haskell.org/ghc/ghc/-/issues/16028tyThingCoAxiom panics while building Agda2019-07-07T18:01:58ZIlias TsitsimpistyThingCoAxiom panics while building Agdaghc-8.4.4 panics while building Agda on armhf (https://buildd.debian.org/status/fetch.php?pkg=agda&arch=armhf&ver=2.5.4.1-3%2Bb1&stamp=1544132023&raw=0):
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.4 for arm-unknown-l...ghc-8.4.4 panics while building Agda on armhf (https://buildd.debian.org/status/fetch.php?pkg=agda&arch=armhf&ver=2.5.4.1-3%2Bb1&stamp=1544132023&raw=0):
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.4 for arm-unknown-linux):
tyThingCoAxiom
Identifier ‘fromDescListWithKey’
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/main/HscTypes.hs:2153:32 in ghc:HscTypes
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
The same version of Agda builds fine with ghc-8.4.3 on armhf (https://buildd.debian.org/status/fetch.php?pkg=agda&arch=armhf&ver=2.5.4.1-3&stamp=1540145469&raw=0).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"tyThingCoAxiom panics while building Agda","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.4","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"ghc-8.4.4 panics while building Agda on armhf (https://buildd.debian.org/status/fetch.php?pkg=agda&arch=armhf&ver=2.5.4.1-3%2Bb1&stamp=1544132023&raw=0):\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.4 for arm-unknown-linux):\r\n\ttyThingCoAxiom\r\n Identifier ‘fromDescListWithKey’\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/main/HscTypes.hs:2153:32 in ghc:HscTypes\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nThe same version of Agda builds fine with ghc-8.4.3 on armhf (https://buildd.debian.org/status/fetch.php?pkg=agda&arch=armhf&ver=2.5.4.1-3&stamp=1540145469&raw=0).","type_of_failure":"OtherFailure","blocking":[]} -->8.6.4https://gitlab.haskell.org/ghc/ghc/-/issues/16027Cannot use DefaultSignatures for TypeFamiles2019-07-07T18:01:58ZJohn EricsonCannot use DefaultSignatures for TypeFamilesI'm surprised there wasn't a ticket for this. Maybe I just couldn't find it.
In short, I want to do something like:
```
class Monad m => MyMonad m where
type AssociatedMonad m :: Type -> Type
default type AssociatedMonad m :: (...I'm surprised there wasn't a ticket for this. Maybe I just couldn't find it.
In short, I want to do something like:
```
class Monad m => MyMonad m where
type AssociatedMonad m :: Type -> Type
default type AssociatedMonad m :: (m ~ t m', MonadTrans t, MyMonad m') => Type -> Type
type AssociatedMonad (t m') = t (AssociatedMonad m')
fun :: Foo -> m ()
default fun :: (m ~ t m', MonadTrans t, MyMonad m') => Foo -> m ()
fun = lift . fun
```
The syntax is a bit weird, but I hope in the process of implementing constrained type families the syntax properly analogous to the term-level would shake itself out.
The use-case, like the normal method original, is to assist with monad transformer boilerplate. `MonadTrans` wouldn't be enough, but `MFunctor` from mmorph might be depending on the method using the associated type.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.6.2 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Cannot use DefaultSignatures for TypeFamiles","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"I'm surprised there wasn't a ticket for this. Maybe I just couldn't find it.\r\n\r\nIn short, I want to do something like:\r\n{{{\r\nclass Monad m => MyMonad m where\r\n type AssociatedMonad m :: Type -> Type\r\n default type AssociatedMonad m :: (m ~ t m', MonadTrans t, MyMonad m') => Type -> Type\r\n type AssociatedMonad (t m') = t (AssociatedMonad m')\r\n\r\n fun :: Foo -> m ()\r\n default fun :: (m ~ t m', MonadTrans t, MyMonad m') => Foo -> m ()\r\n fun = lift . fun\r\n}}}\r\n\r\nThe syntax is a bit weird, but I hope in the process of implementing constrained type families the syntax properly analogous to the term-level would shake itself out.\r\n\r\nThe use-case, like the normal method original, is to assist with monad transformer boilerplate. {{{MonadTrans}}} wouldn't be enough, but {{{MFunctor}}} from mmorph might be depending on the method using the associated type.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3https://gitlab.haskell.org/ghc/ghc/-/issues/16025Makefiles bundled with source distribution fail to build cross-compiler.2019-07-07T18:01:58ZvanessamchaleMakefiles bundled with source distribution fail to build cross-compiler.When trying to build a cross-compiler with GHC 8.6.3, I ran into the following:
```
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Re...When trying to build a cross-compiler with GHC 8.6.3, I ran into the following:
```
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)
libraries/ghc-prim/dist-install/build/GHC/CString.o: error adding symbols: File in wrong format
echo libraries/ghc-prim/dist-install/build/GHC/CString.o libraries/ghc-prim/dist-install/build/GHC/Classes.o libraries/ghc-prim/dist-install/build/GHC/Debug.o libraries/ghc-prim/dist-install/build/GHC/IntWord64.o libraries/ghc-prim/dist-install/build/GHC/Magic.o libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.o libraries/ghc-prim/dist-install/build/GHC/Tuple.o libraries/ghc-prim/dist-install/build/GHC/Types.o libraries/ghc-prim/dist-install/build/cbits/atomic.o libraries/ghc-prim/dist-install/build/cbits/bswap.o libraries/ghc-prim/dist-install/build/cbits/clz.o libraries/ghc-prim/dist-install/build/cbits/ctz.o libraries/ghc-prim/dist-install/build/cbits/debug.o libraries/ghc-prim/dist-install/build/cbits/longlong.o libraries/ghc-prim/dist-install/build/cbits/pdep.o libraries/ghc-prim/dist-install/build/cbits/pext.o libraries/ghc-prim/dist-install/build/cbits/popcnt.o libraries/ghc-prim/dist-install/build/cbits/word2float.o >> libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a.contents
libraries/ghc-prim/ghc.mk:4: recipe for target 'libraries/ghc-prim/dist-install/build/HSghc-prim-0.5.3.o' failed
make[1]: *** [libraries/ghc-prim/dist-install/build/HSghc-prim-0.5.3.o] Error 1
make[1]: *** Waiting for unfinished jobs....
"arm-linux-gnueabihf-ar" q libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a @libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a.contents
arm-linux-gnueabihf-ar: creating libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a
"rm" -f libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a.contents
Makefile:122: recipe for target 'all' failed
make: *** [all] Error 2
It seems that this was due to an error in mk/config.mk, viz.
LD_NO_GOLD = ld
LD = arm-linux-gnueabihf-ld.gold
NM = arm-linux-gnueabihf-nm
AR = arm-linux-gnueabihf-ar
OBJDUMP = arm-linux-gnueabihf-objdump
```
The variable `LD_NO_GOLD` should have the prefix `arm-linux-gnueabihf`. When I set `LD_NO_GOLD` to `arm-linux-gnueabihf-ld` manually, the build proceeds and works correctly.
Let me know if you need any additional information.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------------- |
| Version | 8.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Build System (make) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Makefiles bundled with source distribution fail to build cross-compiler.","status":"New","operating_system":"","component":"Build System (make)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When trying to build a cross-compiler with GHC 8.6.3, I ran into the following:\r\n\r\n{{{\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 40)\r\nlibraries/ghc-prim/dist-install/build/GHC/CString.o: error adding symbols: File in wrong format\r\necho libraries/ghc-prim/dist-install/build/GHC/CString.o libraries/ghc-prim/dist-install/build/GHC/Classes.o libraries/ghc-prim/dist-install/build/GHC/Debug.o libraries/ghc-prim/dist-install/build/GHC/IntWord64.o libraries/ghc-prim/dist-install/build/GHC/Magic.o libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.o libraries/ghc-prim/dist-install/build/GHC/Tuple.o libraries/ghc-prim/dist-install/build/GHC/Types.o libraries/ghc-prim/dist-install/build/cbits/atomic.o libraries/ghc-prim/dist-install/build/cbits/bswap.o libraries/ghc-prim/dist-install/build/cbits/clz.o libraries/ghc-prim/dist-install/build/cbits/ctz.o libraries/ghc-prim/dist-install/build/cbits/debug.o libraries/ghc-prim/dist-install/build/cbits/longlong.o libraries/ghc-prim/dist-install/build/cbits/pdep.o libraries/ghc-prim/dist-install/build/cbits/pext.o libraries/ghc-prim/dist-install/build/cbits/popcnt.o libraries/ghc-prim/dist-install/build/cbits/word2float.o >> libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a.contents\r\nlibraries/ghc-prim/ghc.mk:4: recipe for target 'libraries/ghc-prim/dist-install/build/HSghc-prim-0.5.3.o' failed\r\nmake[1]: *** [libraries/ghc-prim/dist-install/build/HSghc-prim-0.5.3.o] Error 1\r\nmake[1]: *** Waiting for unfinished jobs....\r\n\"arm-linux-gnueabihf-ar\" q libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a @libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a.contents\r\narm-linux-gnueabihf-ar: creating libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a\r\n\"rm\" -f libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3.a.contents \r\nMakefile:122: recipe for target 'all' failed\r\nmake: *** [all] Error 2\r\nIt seems that this was due to an error in mk/config.mk, viz.\r\nLD_NO_GOLD = ld\r\nLD = arm-linux-gnueabihf-ld.gold\r\nNM = arm-linux-gnueabihf-nm\r\nAR = arm-linux-gnueabihf-ar\r\nOBJDUMP = arm-linux-gnueabihf-objdump\r\n}}}\r\n\r\nThe variable {{{LD_NO_GOLD}}} should have the prefix {{{arm-linux-gnueabihf}}}. When I set {{{LD_NO_GOLD}}} to {{{arm-linux-gnueabihf-ld}}} manually, the build proceeds and works correctly.\r\n\r\nLet me know if you need any additional information.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/16024Kind Signatures on data instances2019-07-07T18:01:59ZAndrew MartinKind Signatures on data instancesThere's a comment in `compiler/typecheck/TcInstDcls.hs` that reads:
> The "header" is the part other than the data constructors themselves
> e.g. `data instance D [a] :: * -> * = ...`
> Here the "header" is the bit before the "=" sign...There's a comment in `compiler/typecheck/TcInstDcls.hs` that reads:
> The "header" is the part other than the data constructors themselves
> e.g. `data instance D [a] :: * -> * = ...`
> Here the "header" is the bit before the "=" sign
What's weird is that you cannot actually compile code that this example suggests is valid. Consider this:
```
{-# language TypeFamilies #-}
module BadSig where
data family Bar a :: *
data instance Bar Int :: * = Bool
```
It fails on GHC 8.6.2 with:
```
bad_sig.hs:6:28: error:
parse error on input ‘=’
Perhaps you need a 'let' in a 'do' block?
e.g. 'let x = 5' instead of 'x = 5'
|
6 | data instance Bar Int :: * = Bool
| ^
```
Oddly, GHC will accept the instance if the body is missing:
```
{-# language TypeFamilies #-}
module BadSig where
data family Bar a :: *
data instance Bar Int :: *
```
It is not clear to me whether or not this one should be accepted, but that is beside the point. The first example should certainly be accepted. It should also be accepted with `TYPE 'LiftedRep` instead of `*`, but it fails with the same parser error when given that kind signature as well.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Kind Signatures on data instances","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"There's a comment in `compiler/typecheck/TcInstDcls.hs` that reads:\r\n\r\n> The \"header\" is the part other than the data constructors themselves\r\n\r\n> e.g. `data instance D [a] :: * -> * = ...`\r\n\r\n> Here the \"header\" is the bit before the \"=\" sign\r\n\r\nWhat's weird is that you cannot actually compile code that this example suggests is valid. Consider this:\r\n\r\n{{{\r\n{-# language TypeFamilies #-}\r\n \r\nmodule BadSig where\r\n\r\ndata family Bar a :: *\r\ndata instance Bar Int :: * = Bool\r\n}}}\r\n\r\nIt fails on GHC 8.6.2 with:\r\n\r\n{{{\r\nbad_sig.hs:6:28: error:\r\n parse error on input ‘=’\r\n Perhaps you need a 'let' in a 'do' block?\r\n e.g. 'let x = 5' instead of 'x = 5'\r\n |\r\n6 | data instance Bar Int :: * = Bool\r\n | ^\r\n}}}\r\n\r\nOddly, GHC will accept the instance if the body is missing:\r\n\r\n{{{\r\n{-# language TypeFamilies #-}\r\n \r\nmodule BadSig where\r\n\r\ndata family Bar a :: *\r\ndata instance Bar Int :: *\r\n}}}\r\n\r\nIt is not clear to me whether or not this one should be accepted, but that is beside the point. The first example should certainly be accepted. It should also be accepted with `TYPE 'LiftedRep` instead of `*`, but it fails with the same parser error when given that kind signature as well.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3https://gitlab.haskell.org/ghc/ghc/-/issues/16021Hadrian: remove/refactor package specific hacks2019-07-07T18:01:59ZdavideHadrian: remove/refactor package specific hacksHadrian implements a number of package specific hacks (e.g. see #16020). Such hacks should be discussed in this ticket and ideally removed or refactored.
Hacks:
- libffi (#16020)
<details><summary>Trac metadata</summary>
| Trac field...Hadrian implements a number of package specific hacks (e.g. see #16020). Such hacks should be discussed in this ticket and ideally removed or refactored.
Hacks:
- libffi (#16020)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Hadrian: remove/refactor package specific hacks","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Hadrian implements a number of package specific hacks (e.g. see #16020). Such hacks should be discussed in this ticket and ideally removed or refactored.\r\n\r\nHacks:\r\n* libffi (#16020)","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3David EichmannDavid Eichmannhttps://gitlab.haskell.org/ghc/ghc/-/issues/16018Disabling core optimizations ignores code that would otherwise warn.2023-01-23T21:44:15ZdmjioDisabling core optimizations ignores code that would otherwise warn.Given the below code snippet,
```hs
module Main where
main :: IO ()
main = putStrLn "hey"
data StopLight
= Red
| Green
| Yellow
deriving (Show, Eq)
data Intersection
= Intersection
{ light :: {-# UNPACK #-} !StopLight
}...Given the below code snippet,
```hs
module Main where
main :: IO ()
main = putStrLn "hey"
data StopLight
= Red
| Green
| Yellow
deriving (Show, Eq)
data Intersection
= Intersection
{ light :: {-# UNPACK #-} !StopLight
} deriving (Show, Eq)
```
The above code will warn with optimizations enabled (`ghc -Wall -O2 Main.hs`), message below:
```
Main.hs:13:5: warning:
• Ignoring unusable UNPACK pragma
on the first argument of ‘Intersection’
• In the definition of data constructor ‘Intersection’
In the data type declaration for ‘Intersection’
|
13 | = Intersection
```
Without optimizations, no warnings are emitted `ghc -Wall -O0 Main.hs`.
The desired behavior should be a warning emitted in both cases.8.6.2https://gitlab.haskell.org/ghc/ghc/-/issues/16014Avoid unnecessary code duplication from String Literals.2022-11-22T03:33:52ZAndreas KlebingerAvoid unnecessary code duplication from String Literals.When we compile a function like this:
```
foo :: Int -> String
foo 1 = "1_String"
foo 2 = "2_String"
foo 3 = "3_String"
foo 4 = "4_String"
foo 5 = "5_String"
foo _ = "unknown_string"
```
We get a few things.
Obviously there are the ac...When we compile a function like this:
```
foo :: Int -> String
foo 1 = "1_String"
foo 2 = "2_String"
foo 3 = "3_String"
foo 4 = "4_String"
foo 5 = "5_String"
foo _ = "unknown_string"
```
We get a few things.
Obviously there are the actual strings:
```
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
Foo.foo10 :: GHC.Prim.Addr#
Foo.foo10 = "1_String"#
```
There is no way around these so that's fine.
Then we end up with a function to unpack the actual string.
```
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
Foo.foo9 :: [Char]
[GblId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=True,
WorkFree=False, Expandable=True, Guidance=IF_ARGS [] 20 0}]
Foo.foo9 = GHC.CString.unpackCString# Foo.foo10
```
We want to have a closure for each of these. Otherwise we end up constructing a new string each time, which would be a waste. So on the surface this is fine.
However we end up with one of these for each string.
Looking at the Cmm/Asm the functions are not THAT small.
```
[Foo.foo9_entry() // [R1]
{ info_tbls: [(c2hj,
label: Foo.foo9_info
rep: HeapRep static { Thunk }
srt: Nothing)]
stack_info: arg_space: 8 updfr_space: Just 8
}
{offset
c2hj: // global
if ((Sp + -16) < SpLim) (likely: False) goto c2hk; else goto c2hl;
c2hk: // global
R1 = R1;
call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8;
c2hl: // global
(_c2hg::I64) = call "ccall" arg hints: [PtrHint,
PtrHint] result hints: [PtrHint] newCAF(BaseReg, R1);
if (_c2hg::I64 == 0) goto c2hi; else goto c2hh;
c2hi: // global
call (I64[R1])() args: 8, res: 0, upd: 8;
c2hh: // global
I64[Sp - 16] = stg_bh_upd_frame_info;
I64[Sp - 8] = _c2hg::I64;
R2 = Foo.foo10_bytes;
Sp = Sp - 16;
call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24;
}
}
```
In actual code size (HEAD/-O2) the code + info table is about 100Byte.
To give an idea in my current ghc-stage2 I have 12,409 calls to unpackCString, and I assume 99% of them are from actual strings. So that comes out to about one megabyte. Out of a binary size of 84MB, so surprisingly significant actually!
## Now what can we do about this!
I think the right way to go here is to define a `unpackString` function which does the actual work.
Then we jump into that from a small per-string wrapper.
So we would end up with code like:
```
[Foo.foo9_entry() // [R1]
c2hj:
// R1 = Closure pointer
R2 = Foo.foo10_bytes;
call (unpackString)(R1,R2) args: 8, res: 0, upd: 8;
}
```
Which should be well under 50 bytes. It does cause an extra indirection when unpacking the String, but if the performance of that matters using String is likely the wrong choice to begin with.
How to actually get GHC to generate code like that I'm not sure yet.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Avoid unnecessary code duplication from String Literals.","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"When we compile a function like this:\r\n\r\n{{{\r\nfoo :: Int -> String\r\nfoo 1 = \"1_String\"\r\nfoo 2 = \"2_String\"\r\nfoo 3 = \"3_String\"\r\nfoo 4 = \"4_String\"\r\nfoo 5 = \"5_String\"\r\nfoo _ = \"unknown_string\"\r\n}}}\r\n\r\nWe get a few things.\r\n\r\nObviously there are the actual strings:\r\n{{{\r\n-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}\r\nFoo.foo10 :: GHC.Prim.Addr#\r\nFoo.foo10 = \"1_String\"#\r\n}}}\r\nThere is no way around these so that's fine.\r\n\r\nThen we end up with a function to unpack the actual string.\r\n{{{\r\n-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}\r\nFoo.foo9 :: [Char]\r\n[GblId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=True,\r\n WorkFree=False, Expandable=True, Guidance=IF_ARGS [] 20 0}]\r\nFoo.foo9 = GHC.CString.unpackCString# Foo.foo10\r\n}}}\r\nWe want to have a closure for each of these. Otherwise we end up constructing a new string each time, which would be a waste. So on the surface this is fine.\r\nHowever we end up with one of these for each string.\r\n\r\nLooking at the Cmm/Asm the functions are not THAT small.\r\n{{{\r\n[Foo.foo9_entry() // [R1]\r\n { info_tbls: [(c2hj,\r\n label: Foo.foo9_info\r\n rep: HeapRep static { Thunk }\r\n srt: Nothing)]\r\n stack_info: arg_space: 8 updfr_space: Just 8\r\n }\r\n {offset\r\n c2hj: // global\r\n if ((Sp + -16) < SpLim) (likely: False) goto c2hk; else goto c2hl;\r\n c2hk: // global\r\n R1 = R1;\r\n call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8;\r\n c2hl: // global\r\n (_c2hg::I64) = call \"ccall\" arg hints: [PtrHint,\r\n PtrHint] result hints: [PtrHint] newCAF(BaseReg, R1);\r\n if (_c2hg::I64 == 0) goto c2hi; else goto c2hh;\r\n c2hi: // global\r\n call (I64[R1])() args: 8, res: 0, upd: 8;\r\n c2hh: // global\r\n I64[Sp - 16] = stg_bh_upd_frame_info;\r\n I64[Sp - 8] = _c2hg::I64;\r\n R2 = Foo.foo10_bytes;\r\n Sp = Sp - 16;\r\n call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24;\r\n }\r\n }\r\n}}}\r\nIn actual code size (HEAD/-O2) the code + info table is about 100Byte.\r\n\r\nTo give an idea in my current ghc-stage2 I have 12,409 calls to unpackCString, and I assume 99% of them are from actual strings. So that comes out to about one megabyte. Out of a binary size of 84MB, so surprisingly significant actually!\r\n\r\n== Now what can we do about this!\r\n\r\nI think the right way to go here is to define a `unpackString` function which does the actual work.\r\nThen we jump into that from a small per-string wrapper.\r\n\r\nSo we would end up with code like:\r\n{{{\r\n[Foo.foo9_entry() // [R1]\r\n c2hj: \r\n // R1 = Closure pointer\r\n R2 = Foo.foo10_bytes;\r\n call (unpackString)(R1,R2) args: 8, res: 0, upd: 8;\r\n }\r\n}}}\r\n\r\nWhich should be well under 50 bytes. It does cause an extra indirection when unpacking the String, but if the performance of that matters using String is likely the wrong choice to begin with.\r\n\r\nHow to actually get GHC to generate code like that I'm not sure yet.\r\n\r\n\r\n\r\n\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->9.6.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/16013:kind! accepts unsaturated type aliases2019-07-07T18:02:01Zdmwit:kind! accepts unsaturated type aliasesHere's a ghci session:
```
> :set -XTypeFamilies -XPolyKinds
> type family Id (a :: k)
> type instance Id a = a
> type Foo x = Maybe
> :kind! Id Foo
Id Foo :: *
= Id Foo
```
I think the final `:kind!` query should throw an error instea...Here's a ghci session:
```
> :set -XTypeFamilies -XPolyKinds
> type family Id (a :: k)
> type instance Id a = a
> type Foo x = Maybe
> :kind! Id Foo
Id Foo :: *
= Id Foo
```
I think the final `:kind!` query should throw an error instead, complaining that `Foo` hasn't been given enough arguments. (But even if you disagree, and think it should be allowed, `*` is clearly not the right kind!)
Using a normal type alias in place of the type family for `Id` also allows the query incorrectly, though it does at least report a sensible kind.
Although I think it shouldn't matter, I have checked with `-ignore-dot-ghci` to make sure I haven't accidentally turned LiberalTypeSynonyms on.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":":kind! accepts unsaturated type aliases","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here's a ghci session:\r\n\r\n{{{\r\n> :set -XTypeFamilies -XPolyKinds\r\n> type family Id (a :: k)\r\n> type instance Id a = a\r\n> type Foo x = Maybe\r\n> :kind! Id Foo\r\nId Foo :: *\r\n= Id Foo\r\n}}}\r\n\r\nI think the final `:kind!` query should throw an error instead, complaining that `Foo` hasn't been given enough arguments. (But even if you disagree, and think it should be allowed, `*` is clearly not the right kind!)\r\n\r\nUsing a normal type alias in place of the type family for `Id` also allows the query incorrectly, though it does at least report a sensible kind.\r\n\r\nAlthough I think it shouldn't matter, I have checked with `-ignore-dot-ghci` to make sure I haven't accidentally turned LiberalTypeSynonyms on.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/16012set/getAllocationCounter is broken in GHCi2020-07-21T15:28:13ZAndreas Klebingerset/getAllocationCounter is broken in GHCiIt doesn't seem obvious why it shouldn't work in GHCi, hence the report.
```
Prelude System.Mem> getAllocationCounter
9223372036854757447
Prelude System.Mem> setAllocationCounter 0
()
Prelude System.Mem> getAllocationCounter
92233720368...It doesn't seem obvious why it shouldn't work in GHCi, hence the report.
```
Prelude System.Mem> getAllocationCounter
9223372036854757447
Prelude System.Mem> setAllocationCounter 0
()
Prelude System.Mem> getAllocationCounter
9223372036854758855
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"set/getAllocationCounter is broken in GHCi","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"It doesn't seem obvious why it shouldn't work in GHCi, hence the report.\r\n\r\n{{{\r\nPrelude System.Mem> getAllocationCounter\r\n9223372036854757447\r\nPrelude System.Mem> setAllocationCounter 0\r\n()\r\nPrelude System.Mem> getAllocationCounter\r\n9223372036854758855\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->9.0.1Roland SennRoland Sennhttps://gitlab.haskell.org/ghc/ghc/-/issues/16011GHCi leaks memory even with -fno-it.2019-07-31T14:05:28ZAndreas KlebingerGHCi leaks memory even with -fno-it.GHCi leaks are not exactly new, but this one is especially easy to trigger/reproduce.
The memory allocated by f never gets freed.
```
PS E:\binary-perf> ..\ghc-8.6.1\bin\ghci.exe -fno-it
GHCi, version 8.6.1: http://www.haskell.org/ghc/...GHCi leaks are not exactly new, but this one is especially easy to trigger/reproduce.
The memory allocated by f never gets freed.
```
PS E:\binary-perf> ..\ghc-8.6.1\bin\ghci.exe -fno-it
GHCi, version 8.6.1: http://www.haskell.org/ghc/ :? for help
Prelude> f = [1 .. 20000000] :: [Int]
Prelude> length f
20000000
Prelude> f = [1 .. 20000001] :: [Int]
Prelude> length f
20000001
Prelude> f = [1 .. 20000002] :: [Int]
Prelude> length f
20000002
Prelude> f = [1 .. 20000000] :: [Int]
Prelude> length f
20000000
Prelude>
```
Or using head and even simpler:
```
PS E:\binary-perf> ..\ghc_commonAsm\inplace\bin\ghci.exe -fno-it
GHCi, version 8.7.20181207: http://www.haskell.org/ghc/ :? for help
Loaded package environment from E:\binary-perf\.ghc.environment.x86_64-mingw32-8.7.20181207
Prelude> f = replicate 2000000 False
Prelude> length f
2000000
Prelude> f = replicate 2000000 False
Prelude> length f
2000000
Prelude> f = replicate 2000000 False
Prelude> length f
2000000
Prelude> f = replicate 2000000 False
Prelude> length f
```
GHC just keeps using more and more memory when I repeat this.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHCi leaks memory even with -fno-it.","status":"New","operating_system":"","component":"GHCi","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHCi leaks are not exactly new, but this one is especially easy to trigger/reproduce.\r\n\r\nThe memory allocated by f never gets freed.\r\n{{{\r\nPS E:\\binary-perf> ..\\ghc-8.6.1\\bin\\ghci.exe -fno-it\r\nGHCi, version 8.6.1: http://www.haskell.org/ghc/ :? for help\r\nPrelude> f = [1 .. 20000000] :: [Int]\r\nPrelude> length f\r\n20000000\r\nPrelude> f = [1 .. 20000001] :: [Int]\r\nPrelude> length f\r\n20000001\r\nPrelude> f = [1 .. 20000002] :: [Int]\r\nPrelude> length f\r\n20000002\r\nPrelude> f = [1 .. 20000000] :: [Int]\r\nPrelude> length f\r\n20000000\r\nPrelude>\r\n}}}\r\n\r\nOr using head and even simpler:\r\n\r\n{{{\r\nPS E:\\binary-perf> ..\\ghc_commonAsm\\inplace\\bin\\ghci.exe -fno-it\r\nGHCi, version 8.7.20181207: http://www.haskell.org/ghc/ :? for help\r\nLoaded package environment from E:\\binary-perf\\.ghc.environment.x86_64-mingw32-8.7.20181207\r\nPrelude> f = replicate 2000000 False\r\nPrelude> length f\r\n2000000\r\nPrelude> f = replicate 2000000 False\r\nPrelude> length f\r\n2000000\r\nPrelude> f = replicate 2000000 False\r\nPrelude> length f\r\n2000000\r\nPrelude> f = replicate 2000000 False\r\nPrelude> length f\r\n}}}\r\n\r\nGHC just keeps using more and more memory when I repeat this.\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3https://gitlab.haskell.org/ghc/ghc/-/issues/16009Deprecate `optional` from Text.ParserCombinators.ReadP2020-01-23T19:38:55ZdbaynardDeprecate `optional` from Text.ParserCombinators.ReadPIt seems there is some disagreement on what the type of `optional` should be, within `base`.
`Control.Applicative` defines it as
```haskell
optional :: Alternative f => f a -> f (Maybe a)
```
By contrast, `Text.ParserCombinators.ReadP...It seems there is some disagreement on what the type of `optional` should be, within `base`.
`Control.Applicative` defines it as
```haskell
optional :: Alternative f => f a -> f (Maybe a)
```
By contrast, `Text.ParserCombinators.ReadP` defines it as
```haskell
optional :: ReadP a -> ReadP ()
```
Worse, ReadP implements `Alternative`. So it entirely possible to specialise
```haskell
optional :: ReadP a -> ReadP (Maybe a).
```
In the broader Haskell ecosystem (and beyond) there is further confusion. The `Applicative` definition is used by `parsers`, `megaparsec` and purescript's `Data.Maybe`. The `ReadP` definition is used by `Parsec` and purescript's `Text.Parsing.StringParser`. `Cabal`, like `base` defines both.
I propose to begin to deprecate `ReadP.optional` ASAP, following suggestions in https://www.reddit.com/r/haskell/comments/8cqgds/inconsistent_optional_definitions/. Code which used the old form may still compile; otherwise `void` should be applied.
There have been some suggestions for new names for the `ReadP` definition, such as `optionally` or `optional_`. It may be worth exporting this function directly from `Control.Applicative`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.6.2 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Deprecate `optional` from Text.ParserCombinators.ReadP","status":"New","operating_system":"","component":"libraries/base","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":["Applicative,","Parsers,","ReadP"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"It seems there is some disagreement on what the type of `optional` should be, within `base`.\r\n\r\n`Control.Applicative` defines it as\r\n\r\n{{{#!haskell\r\noptional :: Alternative f => f a -> f (Maybe a)\r\n}}}\r\n\r\nBy contrast, `Text.ParserCombinators.ReadP` defines it as\r\n\r\n{{{#!haskell\r\noptional :: ReadP a -> ReadP ()\r\n}}}\r\n\r\nWorse, ReadP implements `Alternative`. So it entirely possible to specialise\r\n\r\n{{{#!haskell\r\noptional :: ReadP a -> ReadP (Maybe a).\r\n}}}\r\n\r\nIn the broader Haskell ecosystem (and beyond) there is further confusion. The `Applicative` definition is used by `parsers`, `megaparsec` and purescript's `Data.Maybe`. The `ReadP` definition is used by `Parsec` and purescript's `Text.Parsing.StringParser`. `Cabal`, like `base` defines both.\r\n\r\nI propose to begin to deprecate `ReadP.optional` ASAP, following suggestions in https://www.reddit.com/r/haskell/comments/8cqgds/inconsistent_optional_definitions/. Code which used the old form may still compile; otherwise `void` should be applied.\r\n\r\nThere have been some suggestions for new names for the `ReadP` definition, such as `optionally` or `optional_`. It may be worth exporting this function directly from `Control.Applicative`.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/16007Implement `-Os`2019-07-07T18:02:03ZSebastian GrafImplement `-Os`Popular C compilers like GCC or clang allow to optimise for binary size.
Since there are multiple ways in which GHC trades code size for faster programs, it might make sense to follow suit. This ticket is for tracking which optimisation...Popular C compilers like GCC or clang allow to optimise for binary size.
Since there are multiple ways in which GHC trades code size for faster programs, it might make sense to follow suit. This ticket is for tracking which optimisations/hacks in the compiler might be affected.
Feel free to add items to the following list:
- potentially huge impact due to specialisation, liberate case and inlining
- potential of -0.9% due to a second run of common block elimination (#14226)
- +0.1% increase in code size due to known calls instead of re-using generic apply thunks in #16005
- -0.1% due to `-fstg-lift-lams` #9476⊥https://gitlab.haskell.org/ghc/ghc/-/issues/16006Framework failures when validating2019-07-07T18:02:03ZÖmer Sinan AğacanFramework failures when validatingI just tried to validate and got this:
```
Framework failures:
. ./perf/should_run/all.T [] (name 'stats_num_field' is not defined)
```
Tree based on fb669f51b3f2cae79511ac3d1c43939d951b1f69.
<details><summary>Trac metadata</summa...I just tried to validate and got this:
```
Framework failures:
. ./perf/should_run/all.T [] (name 'stats_num_field' is not defined)
```
Tree based on fb669f51b3f2cae79511ac3d1c43939d951b1f69.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Test Suite |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Framework failures when validating","status":"New","operating_system":"","component":"Test Suite","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I just tried to validate and got this:\r\n\r\n{{{\r\nFramework failures:\r\n . ./perf/should_run/all.T [] (name 'stats_num_field' is not defined)\r\n}}}\r\n\r\nTree based on fb669f51b3f2cae79511ac3d1c43939d951b1f69.","type_of_failure":"OtherFailure","blocking":[]} -->8.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/16005Don't use a generic apply thunk for known calls2019-07-07T18:02:03ZSebastian GrafDon't use a generic apply thunk for known callsCurrently, an AP thunk like `sat = f a b c` will not have its own entry
point and info pointer and will instead reuse a generic apply thunk
like `stg_ap_4_upd`.
That's great from a code size perspective, but if `f` is a known
function, ...Currently, an AP thunk like `sat = f a b c` will not have its own entry
point and info pointer and will instead reuse a generic apply thunk
like `stg_ap_4_upd`.
That's great from a code size perspective, but if `f` is a known
function, a specialised entry point with a plain call can be much faster
than figuring out the arity and doing dynamic dispatch.
----
I prepared a patch over at [D5414](https://phabricator.haskell.org/D5414) that fixes this by checking if the arity of `f` is unknown (e.g. 0). If not, it will no longer delegate to a generic apply thunk and generate regular entry code and info tables instead.
No impact on allocations, but on counted instructions and code size. Significant changes to counted instructions:
<table><tr><td>cryptarithm1 </td>
<td> -2.5%</td></tr>
<tr><td>lcss </td>
<td> -2.3%</td></tr>
<tr><td>paraffins </td>
<td> -3.8%</td></tr>
<tr><td>wheel-sieve2 </td>
<td> -3.4%</td></tr>
<tr><td></td>
<td></td></tr>
<tr><td>Min </td>
<td> -3.8%</td></tr>
<tr><td>Max </td>
<td> +0.0%</td></tr>
<tr><td> Geometric Mean </td>
<td> -0.2%</td></tr></table>
And changes to binary size greater than 0.1% (all the other programs, basically):
<table><tr><td> Program </td>
<td>Size </td>
<td> Instrs</td></tr>
<tr><td> anna </td>
<td>+0.3% </td>
<td>-0.2%</td></tr>
<tr><td> expert </td>
<td>+0.2% </td>
<td>-0.0%</td></tr>
<tr><td> fluid </td>
<td>+0.2% </td>
<td>-0.1%</td></tr>
<tr><td> grep </td>
<td>+0.2% </td>
<td>-0.0%</td></tr>
<tr><td> infer </td>
<td>+0.2% </td>
<td>-0.4%</td></tr>
<tr><td> last-piece </td>
<td>+0.2% </td>
<td>-0.1%</td></tr>
<tr><td> lift </td>
<td>+0.2% </td>
<td>-0.0%</td></tr>
<tr><td> paraffins </td>
<td>+0.2% </td>
<td>-3.8%</td></tr>
<tr><td> prolog </td>
<td>+0.2% </td>
<td>-0.1%</td></tr>
<tr><td> scs </td>
<td>+0.3% </td>
<td>-0.0%</td></tr>
<tr><td> transform </td>
<td>+0.2% </td>
<td>-0.2%</td></tr>
<tr><td> veritas </td>
<td>+0.2% </td>
<td>+0.0%</td></tr>
<tr><td></td>
<td></td>
<td></td></tr>
<tr><td> Min </td>
<td>+0.1% </td>
<td>-3.8%</td></tr>
<tr><td> Max </td>
<td>+0.3% </td>
<td>+0.0%</td></tr>
<tr><td> Geometric Mean </td>
<td>+0.1% </td>
<td>-0.2%</td></tr></table>
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Don't use a generic apply thunk for known calls","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"Currently, an AP thunk like `sat = f a b c` will not have its own entry\r\npoint and info pointer and will instead reuse a generic apply thunk\r\nlike `stg_ap_4_upd`.\r\n\r\nThat's great from a code size perspective, but if `f` is a known\r\nfunction, a specialised entry point with a plain call can be much faster\r\nthan figuring out the arity and doing dynamic dispatch.\r\n\r\n----\r\n\r\nI prepared a patch over at Phab:D5414 that fixes this by checking if the arity of `f` is unknown (e.g. 0). If not, it will no longer delegate to a generic apply thunk and generate regular entry code and info tables instead.\r\n\r\nNo impact on allocations, but on counted instructions and code size. Significant changes to counted instructions:\r\n\r\n||cryptarithm1 || -2.5%||\r\n||lcss || -2.3%||\r\n||paraffins || -3.8%||\r\n||wheel-sieve2 || -3.4%||\r\n||||||\r\n||Min || -3.8%||\r\n||Max || +0.0%||\r\n|| Geometric Mean || -0.2%||\r\n\r\nAnd changes to binary size greater than 0.1% (all the other programs, basically):\r\n\r\n|| Program ||Size || Instrs||\r\n|| anna ||+0.3% ||-0.2%||\r\n|| expert ||+0.2% ||-0.0%||\r\n|| fluid ||+0.2% ||-0.1%||\r\n|| grep ||+0.2% ||-0.0%||\r\n|| infer ||+0.2% ||-0.4%||\r\n|| last-piece ||+0.2% ||-0.1%||\r\n|| lift ||+0.2% ||-0.0%||\r\n|| paraffins ||+0.2% ||-3.8%||\r\n|| prolog ||+0.2% ||-0.1%||\r\n|| scs ||+0.3% ||-0.0%||\r\n|| transform ||+0.2% ||-0.2%||\r\n|| veritas ||+0.2% ||+0.0%||\r\n||||||||\r\n|| Min ||+0.1% ||-3.8%||\r\n|| Max ||+0.3% ||+0.0%||\r\n|| Geometric Mean ||+0.1% ||-0.2%||","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/16004Vector performance regression in GHC 8.62019-07-07T18:02:04ZGuillaume BouchardVector performance regression in GHC 8.6Hello.
With the following code, I can observe a performance regression between ghc 8.4 and 8.6:
```haskell
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import qualified Data.Vector.Unboxed.Mutable as Vector
import qualified D...Hello.
With the following code, I can observe a performance regression between ghc 8.4 and 8.6:
```haskell
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import qualified Data.Vector.Unboxed.Mutable as Vector
import qualified Data.Vector.Unboxed as VectorU
import Data.Foldable (for_)
main :: IO ()
main = do
let n = 1000
let vUnmutable :: VectorU.Vector Double = VectorU.generate (n * n) (\i -> fromIntegral i)
v :: Vector.IOVector Double <- VectorU.unsafeThaw vUnmutable
for_ [0..(n - 1)] $ \k -> do
for_ [0..(n - 1)] $ \i -> do
for_ [0..(n - 1)] $ \j -> do
a <- Vector.unsafeRead v (i * n + k)
b <- Vector.unsafeRead v (k * n + j)
c <- Vector.unsafeRead v (i * n + j)
Vector.unsafeWrite v (i * n + j) (min (a + b) c)
```
Built with `-O2` and with / without `-fllvm`. I'm using `vector-0.12.0.1`. Here are the timing results:
GHC 8.2.2
> no llvm: 1.7s
> llvm: 1.0s
GHC 8.4.4
> no llvm: 1.6s
> llvm: 0.9s
GHC 8.6.2
> no llvm: 4.8s
> llvm: 4.3s
I'm using the following bash + nix script to gather theses timings:
```bash
nix-shell -p 'haskell.packages.ghc822.ghcWithPackages(p: [p.vector])' --run "ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp; time ./FloydBench"
nix-shell -p 'haskell.packages.ghc822.ghcWithPackages(p: [p.vector])' -p llvm_39 --run "ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp -fllvm; time ./FloydBench"
nix-shell -p 'haskell.packages.ghc844.ghcWithPackages(p: [p.vector])' --run "ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp; time ./FloydBench"
nix-shell -p 'haskell.packages.ghc844.ghcWithPackages(p: [p.vector])' -p llvm_5 --run "ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp -fllvm; time ./FloydBench"
nix-shell -p 'haskell.packages.ghc862.ghcWithPackages(p: [p.vector])' --run "ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp; time ./FloydBench"
nix-shell -p 'haskell.packages.ghc862.ghcWithPackages(p: [p.vector])' -p llvm_6 --run "ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp -fllvm; time ./FloydBench"
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Vector performance regression in GHC 8.6","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Hello.\r\n\r\nWith the following code, I can observe a performance regression between ghc 8.4 and 8.6:\r\n\r\n\r\n{{{#!haskell\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\nmodule Main where\r\nimport qualified Data.Vector.Unboxed.Mutable as Vector\r\nimport qualified Data.Vector.Unboxed as VectorU\r\n\r\nimport Data.Foldable (for_)\r\n\r\nmain :: IO ()\r\nmain = do\r\n let n = 1000\r\n\r\n let vUnmutable :: VectorU.Vector Double = VectorU.generate (n * n) (\\i -> fromIntegral i)\r\n v :: Vector.IOVector Double <- VectorU.unsafeThaw vUnmutable\r\n\r\n for_ [0..(n - 1)] $ \\k -> do\r\n for_ [0..(n - 1)] $ \\i -> do\r\n for_ [0..(n - 1)] $ \\j -> do\r\n a <- Vector.unsafeRead v (i * n + k)\r\n b <- Vector.unsafeRead v (k * n + j)\r\n c <- Vector.unsafeRead v (i * n + j)\r\n Vector.unsafeWrite v (i * n + j) (min (a + b) c)\r\n}}}\r\n\r\nBuilt with `-O2` and with / without `-fllvm`. I'm using `vector-0.12.0.1`. Here are the timing results:\r\n\r\nGHC 8.2.2\r\n no llvm: 1.7s\r\n llvm: 1.0s\r\nGHC 8.4.4\r\n no llvm: 1.6s\r\n llvm: 0.9s\r\nGHC 8.6.2\r\n no llvm: 4.8s\r\n llvm: 4.3s\r\n\r\nI'm using the following bash + nix script to gather theses timings:\r\n\r\n{{{#!bash\r\nnix-shell -p 'haskell.packages.ghc822.ghcWithPackages(p: [p.vector])' --run \"ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp; time ./FloydBench\"\r\nnix-shell -p 'haskell.packages.ghc822.ghcWithPackages(p: [p.vector])' -p llvm_39 --run \"ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp -fllvm; time ./FloydBench\"\r\nnix-shell -p 'haskell.packages.ghc844.ghcWithPackages(p: [p.vector])' --run \"ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp; time ./FloydBench\"\r\nnix-shell -p 'haskell.packages.ghc844.ghcWithPackages(p: [p.vector])' -p llvm_5 --run \"ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp -fllvm; time ./FloydBench\"\r\nnix-shell -p 'haskell.packages.ghc862.ghcWithPackages(p: [p.vector])' --run \"ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp; time ./FloydBench\"\r\nnix-shell -p 'haskell.packages.ghc862.ghcWithPackages(p: [p.vector])' -p llvm_6 --run \"ghc-pkg list | grep vector; ghc -O2 FloydBench.hs -Wall -fforce-recomp -fllvm; time ./FloydBench\"\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3