GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T19:12:20Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/1662mistranslation of arrow notation2019-07-07T19:12:20ZRoss Patersonr.paterson@city.ac.ukmistranslation of arrow notation(Split from #1333)
arrowrun004 has a core lint failure for all ways:
```
*** Core Lint Errors: in result of Desugar ***
<no location info>:
In the expression: >>>_aEC @ () @ () @ GHC.Base.Int
>>>_aEC is out of scope
*** Offendi...(Split from #1333)
arrowrun004 has a core lint failure for all ways:
```
*** Core Lint Errors: in result of Desugar ***
<no location info>:
In the expression: >>>_aEC @ () @ () @ GHC.Base.Int
>>>_aEC is out of scope
*** Offending Program ***
[...]
Main.expr :: Main.ExprParser () GHC.Base.Int
[]
Main.expr =
>>>_aEC
@ ()
@ ()
@ GHC.Base.Int
(arr_aEB
[...]
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.6.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | arrowrun004 |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"mistranslation of arrow notation","status":"New","operating_system":"Unknown","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.6.1","keywords":[],"differentials":[],"test_case":"arrowrun004","architecture":"Unknown","cc":[""],"type":"Bug","description":"(Split from #1333)\r\n\r\narrowrun004 has a core lint failure for all ways:\r\n{{{\r\n*** Core Lint Errors: in result of Desugar ***\r\n<no location info>:\r\n In the expression: >>>_aEC @ () @ () @ GHC.Base.Int\r\n >>>_aEC is out of scope\r\n*** Offending Program *** \r\n[...]\r\nMain.expr :: Main.ExprParser () GHC.Base.Int\r\n[]\r\nMain.expr =\r\n >>>_aEC\r\n @ ()\r\n @ ()\r\n @ GHC.Base.Int\r\n (arr_aEB\r\n[...]\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/1696Confusing type signature2019-07-07T19:12:07ZguestConfusing type signatureI was working with some buggy numerical code of mine, and I was having problems with some types involving exponentiation. My working hypothesis was that the problem involved using `(^)` with a numerical type I had defined - I had checked...I was working with some buggy numerical code of mine, and I was having problems with some types involving exponentiation. My working hypothesis was that the problem involved using `(^)` with a numerical type I had defined - I had checked `(^)`'s type through :t and saw:
```
(^) :: forall a b. (Integral b, Num a) => a -> b -> a
```
I immediately thought that I needed another type class declaration for my new type, and went haring off on that tangent for a long time. Eventually someone on \#haskell pointed out to me that the \*base\* could be Num, but the power to which it was being raised had to be Integral and that my problems stemmed from going foo\^(1/3), and that what I needed was more along the lines of foo\*\*(1/3).
My confusion stemmed from the variables - the forall declaration goes, in order, a-b, and the curried signature itself goes a-b as well, but the classes goes b-a! This apparently is for no particular reason, and so I think it'd be good if the signatures :t displayed could be a little more consistent and go a-b as well, so it'd be instead:
```
(^) :: forall a b. (Num a, Integral b) => a -> b -> a
```
A small thing, perhaps, but it did trip me up.https://gitlab.haskell.org/ghc/ghc/-/issues/1722Code using type synonym families requires workarounds to compile2019-07-07T19:12:01Ztomasz.zielonka@gmail.comCode using type synonym families requires workarounds to compileI am trying to use type synonym families to create GADTs that can be used interchangably as both typed and untyped ASTs for a small programming language. Here are the (cut down & simplified) definitions:
```
data Typed
data Untyped
typ...I am trying to use type synonym families to create GADTs that can be used interchangably as both typed and untyped ASTs for a small programming language. Here are the (cut down & simplified) definitions:
```
data Typed
data Untyped
type family TU a b :: *
type instance TU Typed b = b
type instance TU Untyped b = ()
-- A type witness type, use eg. for pattern-matching on types
data Type a where
TypeInt :: Type Int
TypeBool :: Type Bool
TypeString :: Type String
TypeList :: Type t -> Type [t]
data Expr :: * -> * -> * {- tu a -} where
Const :: Type a -> a -> Expr tu (TU tu a)
Var2 :: String -> TU tu (Type a) -> Expr tu (TU tu a)
```
It mostly works, which still amazes me, but there are some small glitches. For example in some cases I have to use **(TU Typed Bool)** instead of
**Bool**, even if they should be equal (**type instance TU Typed b = b**). In other cases I have to artificially restrict or generalize functions' type signatures. Or I have to put type signatures in patterns. The biggest problem is that it isn't obvious which workaround is needed in a given case. For some cases I don't have a satisfactory workaround yet.
Perhaps these problems simply reflect immaturity of type synonym family support in GHC, but, on the other hand, it may be some simple bug which could be fixed for GHC 6.8.
I've created a set of test files which I will attach to this ticket. Run check.sh to see how GHC handles the original (inteded) code and the workarounds. But first set the path to ghc in the script.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Code using type synonym families requires workarounds to compile","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"I am trying to use type synonym families to create GADTs that can be used interchangably as both typed and untyped ASTs for a small programming language. Here are the (cut down & simplified) definitions:\r\n\r\n{{{\r\ndata Typed\r\ndata Untyped\r\n\r\ntype family TU a b :: *\r\ntype instance TU Typed b = b\r\ntype instance TU Untyped b = ()\r\n\r\n-- A type witness type, use eg. for pattern-matching on types\r\ndata Type a where\r\n TypeInt :: Type Int\r\n TypeBool :: Type Bool\r\n TypeString :: Type String\r\n TypeList :: Type t -> Type [t]\r\n\r\ndata Expr :: * -> * -> * {- tu a -} where\r\n Const :: Type a -> a -> Expr tu (TU tu a)\r\n Var2 :: String -> TU tu (Type a) -> Expr tu (TU tu a)\r\n}}}\r\n\r\nIt mostly works, which still amazes me, but there are some small glitches. For example in some cases I have to use '''(TU Typed Bool)''' instead of\r\n'''Bool''', even if they should be equal ('''type instance TU Typed b = b'''). In other cases I have to artificially restrict or generalize functions' type signatures. Or I have to put type signatures in patterns. The biggest problem is that it isn't obvious which workaround is needed in a given case. For some cases I don't have a satisfactory workaround yet.\r\n\r\nPerhaps these problems simply reflect immaturity of type synonym family support in GHC, but, on the other hand, it may be some simple bug which could be fixed for GHC 6.8.\r\n\r\nI've created a set of test files which I will attach to this ticket. Run check.sh to see how GHC handles the original (inteded) code and the workarounds. But first set the path to ghc in the script.","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1723type unsafety with type family + GADT2019-07-07T19:12:00Zzunino@di.unipi.ittype unsafety with type family + GADTHere's *unsafeCoerce*:
```
type family Const a
type instance Const a = ()
data T a where T :: a -> T (Const a)
coerce :: forall a b . a -> b
coerce x = case T x :: T (Const b) of
T y -> y
```
Tested with GHC 6.9.20070918
...Here's *unsafeCoerce*:
```
type family Const a
type instance Const a = ()
data T a where T :: a -> T (Const a)
coerce :: forall a b . a -> b
coerce x = case T x :: T (Const b) of
T y -> y
```
Tested with GHC 6.9.20070918
Maybe, see also #345
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"type unsafety with type family + GADT","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"Here's ''unsafeCoerce'':\r\n{{{\r\ntype family Const a\r\ntype instance Const a = ()\r\n\r\ndata T a where T :: a -> T (Const a)\r\n\r\ncoerce :: forall a b . a -> b\r\ncoerce x = case T x :: T (Const b) of\r\n T y -> y\r\n}}}\r\nTested with GHC 6.9.20070918\r\n\r\nMaybe, see also #345","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1724Type family and GADT error2019-07-07T19:12:00ZChris KuklewiczType family and GADT errorThis bug was posted to glasgow-haskell-users\@haskell.org by Roberto Zunino, archived at http://www.haskell.org/pipermail/glasgow-haskell-users/2007-September/013149.html
I am copying the post with the bug into trac:
Here's unsafeCoerce...This bug was posted to glasgow-haskell-users\@haskell.org by Roberto Zunino, archived at http://www.haskell.org/pipermail/glasgow-haskell-users/2007-September/013149.html
I am copying the post with the bug into trac:
Here's unsafeCoerce:
> type family Const a
> type instance Const a = ()
>
> data T a where T :: a -\> T (Const a)
>
> coerce :: forall a b . a -\> b
> coerce x = case T x :: T (Const b) of
> T y -\> y
And this indeed "works"... Here's the result with the latest RC:
- TypeFam\> coerce () 2
\<interactive\>: internal error: stg_ap_v_ret
(GHC version 6.9.20070918 for x86_64_unknown_linux)
> Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Aborted
Regards,
Zun.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Type family and GADT error","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"This bug was posted to glasgow-haskell-users@haskell.org by Roberto Zunino, archived at http://www.haskell.org/pipermail/glasgow-haskell-users/2007-September/013149.html\r\nI am copying the post with the bug into trac:\r\n\r\nHere's unsafeCoerce:\r\n\r\n> type family Const a\r\n> type instance Const a = ()\r\n> \r\n> data T a where T :: a -> T (Const a)\r\n> \r\n> coerce :: forall a b . a -> b\r\n> coerce x = case T x :: T (Const b) of\r\n> T y -> y\r\n\r\nAnd this indeed \"works\"... Here's the result with the latest RC:\r\n\r\n*TypeFam> coerce () 2\r\n<interactive>: internal error: stg_ap_v_ret\r\n (GHC version 6.9.20070918 for x86_64_unknown_linux)\r\n Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\nAborted\r\n\r\nRegards,\r\nZun.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/1729panic on type family2019-07-07T19:11:58Zjpbernardypanic on type familyGhc panics on this module:
```
{-# LANGUAGE TypeFamilies #-}
type family Element c :: *
f :: Element x
f = undefined
------
ghc-6.8.0.20070921: panic! (the 'impossible' happened)
(GHC version 6.8.0.20070921 for i386-unknown-linux):...Ghc panics on this module:
```
{-# LANGUAGE TypeFamilies #-}
type family Element c :: *
f :: Element x
f = undefined
------
ghc-6.8.0.20070921: panic! (the 'impossible' happened)
(GHC version 6.8.0.20070921 for i386-unknown-linux):
check_tau_type main:Main.Element{tc r5C} x{tv a5F} [tv]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1749forall type gives "not polymorphic enough" error incorrectly2019-07-07T19:11:54Zguestforall type gives "not polymorphic enough" error incorrectly```
> type SFST s a b = a -> ST s b
> newtype SF a b = SF { runSF :: forall s. ST s (SFST s a b) }
```
When making this into an instance of Arrow, compose works beautifully:
```
> sfCompose :: SF b c -> SF c d -> SF b d
> sfCompose bc ...```
> type SFST s a b = a -> ST s b
> newtype SF a b = SF { runSF :: forall s. ST s (SFST s a b) }
```
When making this into an instance of Arrow, compose works beautifully:
```
> sfCompose :: SF b c -> SF c d -> SF b d
> sfCompose bc cd = SF sf where
> sf = do
> runBc <- runSF bc
> runCd <- runSF cd
> return $ \b -> runBc b >>= runCd
```
but pure gives an odd message:
```
> sfPure :: (b -> c) -> SF b c
> sfPure f = SF sf where
> sf = return $ \b -> return (f b)
```
```
frp_typebug.lhs:20:12:
Inferred type is less polymorphic than expected
Quantified type variable `s' is mentioned in the environment:
sf :: ST s (b -> ST s c) (bound at frp_typebug.lhs:21:5)
In the first argument of `SF', namely `sf'
In the expression: SF sf
In the definition of `sfPure':
sfPure f = SF sf
where
sf = return $ (\ b -> return (f b))
```
This can be worked around using scoped type variables:
```
> sfPure2 :: (b -> c) -> SF b c
> sfPure2 (f :: b -> c) = SF sf where
> sf :: forall s. ST s (SFST s b c)
> = return $ \b -> return (f b)
```
but it's ugly.https://gitlab.haskell.org/ghc/ghc/-/issues/1761Compiler panics on "phantom family"2019-07-07T19:11:51ZguestCompiler panics on "phantom family"Feeding the following innocent looking (well...) program into GHC causes the compiler to panic:
```
{-# OPTIONS_GHC -fglasgow-exts #-}
type family KUnit a :: *
type instance KUnit Int = ()
unit :: KUnit Int
unit = ()
```
The cr...Feeding the following innocent looking (well...) program into GHC causes the compiler to panic:
```
{-# OPTIONS_GHC -fglasgow-exts #-}
type family KUnit a :: *
type instance KUnit Int = ()
unit :: KUnit Int
unit = ()
```
The cry for help reads:
```
ghc-6.8.20071007: panic! (the 'impossible' happened)
(GHC version 6.9.20070923 for powerpc-apple-darwin):
check_tau_type main:Main.KUnit{tc rnu} base:GHC.Base.Int{(w) tc 3J}
```
Unsurprisingly, I've experienced the same behaviour with 6.9.20070923.
HTH,
> Stefan Holdermans
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------------------------- |
| Version | 6.8 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | abaars@iti.upv.es, stefan@cs.uu.nl |
| Operating system | Multiple |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Compiler panics on \"phantom family\"","status":"New","operating_system":"Multiple","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8","keywords":["familiy","phantom"],"differentials":[],"test_case":"","architecture":"Unknown","cc":["abaars@iti.upv.es","stefan@cs.uu.nl"],"type":"Bug","description":"Feeding the following innocent looking (well...) program into GHC causes the compiler to panic:\r\n\r\n{{{\r\n{-# OPTIONS_GHC -fglasgow-exts #-}\r\n\r\ntype family KUnit a :: *\r\ntype instance KUnit Int = ()\r\n\r\nunit :: KUnit Int\r\nunit = ()\r\n}}}\r\n\r\nThe cry for help reads:\r\n\r\n{{{\r\nghc-6.8.20071007: panic! (the 'impossible' happened)\r\n (GHC version 6.9.20070923 for powerpc-apple-darwin):\r\n check_tau_type main:Main.KUnit{tc rnu} base:GHC.Base.Int{(w) tc 3J}\r\n}}}\r\n\r\nUnsurprisingly, I've experienced the same behaviour with 6.9.20070923.\r\n\r\nHTH,\r\n\r\n Stefan Holdermans","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/1769Deriving Typeable for data families2019-07-07T19:11:48ZManuel M T ChakravartyDeriving Typeable for data familiesSee Simon's proposal in the attachment.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 ...See Simon's proposal in the attachment.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Deriving Typeable for data families","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"6.10 branch","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"chak"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Task","description":"See Simon's proposal in the attachment.","type_of_failure":"OtherFailure","blocking":[]} -->Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1772GHC doesn't like 'inline' type function applications2019-07-07T19:11:47ZjpbernardyGHC doesn't like 'inline' type function applications```
{-# LANGUAGE TypeFamilies #-}
import Prelude hiding (foldl, foldr, foldl1, foldr1, mapM_, sequence_,
elem, notElem, concat, concatMap, and, or, any, all,
sum, product, maximum, minimum)
import Data.Monoid
type family Element t
...```
{-# LANGUAGE TypeFamilies #-}
import Prelude hiding (foldl, foldr, foldl1, foldr1, mapM_, sequence_,
elem, notElem, concat, concatMap, and, or, any, all,
sum, product, maximum, minimum)
import Data.Monoid
type family Element t
class Foldable t where
foldMap :: Monoid m => (Element t -> m) -> t -> m
foldr :: (Element t -> b -> b) -> b -> t -> b
-- foldr :: Element t ~ a => (a -> b -> b) -> b -> t -> b
foldr f z t = appEndo (foldMap (Endo . f) t) z
```
GHC chokes on the above module. If the signature of foldr is replaced by the commented one, GHC is happy. It seems to me that the two expressions should be equivalent.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"GHC doesn't like 'inline' type function applications","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"6.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"{{{\r\n{-# LANGUAGE TypeFamilies #-}\r\n\r\nimport Prelude hiding (foldl, foldr, foldl1, foldr1, mapM_, sequence_,\r\n\t\telem, notElem, concat, concatMap, and, or, any, all,\r\n\t\tsum, product, maximum, minimum)\r\nimport Data.Monoid\r\n\r\ntype family Element t\r\n\r\nclass Foldable t where\r\n foldMap :: Monoid m => (Element t -> m) -> t -> m\r\n\r\n\tfoldr :: (Element t -> b -> b) -> b -> t -> b\r\n\t-- foldr :: Element t ~ a => (a -> b -> b) -> b -> t -> b\r\n\tfoldr f z t = appEndo (foldMap (Endo . f) t) z\r\n}}}\r\nGHC chokes on the above module. If the signature of foldr is replaced by the commented one, GHC is happy. It seems to me that the two expressions should be equivalent.","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1781Type equality class leads to non-termination2019-07-07T19:11:45ZManuel M T ChakravartyType equality class leads to non-terminationThis program sends the type checker to the land of no return:
```
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}
module ShouldCompile where
class E a b | a -> b, b -...This program sends the type checker to the land of no return:
```
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}
module ShouldCompile where
class E a b | a -> b, b -> a
instance E a a
plus :: (E a (Int -> Int)) => Int -> a
plus x y = x + y
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Type equality class leads to non-termination","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"This program sends the type checker to the land of no return:\r\n{{{\r\n{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}\r\n{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}\r\n\r\nmodule ShouldCompile where\r\n\r\nclass E a b | a -> b, b -> a\r\ninstance E a a\r\n\r\nplus :: (E a (Int -> Int)) => Int -> a\r\nplus x y = x + y\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/1783FD leads to non-termination of type checker2019-07-07T19:11:44ZManuel M T ChakravartyFD leads to non-termination of type checkerHere another program that causes the type checker to diverge:
```
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
{-# LANGUAGE PatternSignatures, ScopedTypeVariables, FlexibleContexts #-}
module ShouldCompile where
impo...Here another program that causes the type checker to diverge:
```
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
{-# LANGUAGE PatternSignatures, ScopedTypeVariables, FlexibleContexts #-}
module ShouldCompile where
import Prelude hiding (foldr, foldr1)
import Data.Maybe
class Elem a e | a -> e
class Foldable a where
foldr :: Elem a e => (e -> b -> b) -> b -> a -> b
-- foldr1 :: forall e. Elem a e => (e -> e -> e) -> a -> e -- WORKS!
foldr1 :: Elem a e => (e -> e -> e) -> a -> e
foldr1 f xs = fromMaybe (error "foldr1: empty structure")
(foldr mf Nothing xs)
where mf :: Elem a e => (e -> Maybe e -> Maybe e)
mf x Nothing = Just x
mf x (Just y) = Just (f x y)
```
This is the FD version of #1776. If we use lexically scoped type variables - i.e., the signature marked with "WORKS!" - everything is fine. However, we shouldn't have to use the scoped type variable as the FD rule should combine the `Elem a e` constraints in the two signatures to establish that the `e` in `foldr1`'s signature is the same as the `e` in `mf`'s signature.
In contrast to #1781, there doesn't seem to be an equality constraint involved in this example.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"FD leads to non-termination of type checker","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"Here another program that causes the type checker to diverge:\r\n{{{\r\n{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}\r\n{-# LANGUAGE PatternSignatures, ScopedTypeVariables, FlexibleContexts #-}\r\n\r\nmodule ShouldCompile where\r\n\r\nimport Prelude hiding (foldr, foldr1)\r\n\r\nimport Data.Maybe\r\n\r\nclass Elem a e | a -> e\r\n\r\nclass Foldable a where\r\n foldr :: Elem a e => (e -> b -> b) -> b -> a -> b\r\n\r\n-- foldr1 :: forall e. Elem a e => (e -> e -> e) -> a -> e -- WORKS!\r\n foldr1 :: Elem a e => (e -> e -> e) -> a -> e\r\n foldr1 f xs = fromMaybe (error \"foldr1: empty structure\")\r\n (foldr mf Nothing xs)\r\n where mf :: Elem a e => (e -> Maybe e -> Maybe e)\r\n mf x Nothing = Just x\r\n mf x (Just y) = Just (f x y)\r\n}}}\r\nThis is the FD version of #1776. If we use lexically scoped type variables - i.e., the signature marked with \"WORKS!\" - everything is fine. However, we shouldn't have to use the scoped type variable as the FD rule should combine the `Elem a e` constraints in the two signatures to establish that the `e` in `foldr1`'s signature is the same as the `e` in `mf`'s signature.\r\n\r\nIn contrast to #1781, there doesn't seem to be an equality constraint involved in this example.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/1804Panic: applyTypeToArgs with -O2019-07-07T19:11:39ZdonsPanic: applyTypeToArgs with -OMy HWN publishing program,
> http://www.galois.com/\~dons/publish.hs
elicits a panic from a ghc 6.8 snapshot from Sep 9, when compiled with -O:
```
$ ghc --make -O publish.hs -o publish -no-recomp
[1 of 1] Compiling Main ...My HWN publishing program,
> http://www.galois.com/\~dons/publish.hs
elicits a panic from a ghc 6.8 snapshot from Sep 9, when compiled with -O:
```
$ ghc --make -O publish.hs -o publish -no-recomp
[1 of 1] Compiling Main ( publish.hs, publish.o )
ghc-6.9.20070916: panic! (the 'impossible' happened)
(GHC version 6.9.20070916 for x86_64-unknown-openbsd):
applyTypeToArgs
unix-2.0:System.Posix.Signals.a37{v rjv} [gid]
(unix-2.0:System.Posix.Signals.a25{v rju} [gid]
`cast` (base:GHC.Prim.sym{(w) tc 34v}
(base:Foreign.C.Types.:CoCInt{tc rjt})
:: <pred>base:GHC.Int.Int32{tc 3V}
~
<nt>base:Foreign.C.Types.CInt{tc r9e}))
unix-2.0:System.Posix.Signals.Ignore{v rjs} [gid]
(base:Data.Maybe.Nothing{v r4U} [gid]
@ <nt>unix-2.0:System.Posix.Signals.SignalSet{tc rjr})
eta{v a3Uh} [lid]
(# base:GHC.Prim.State#{(w) tc 32q}
base:GHC.Prim.RealWorld{(w) tc 31E},
base:GHC.Base.(){(w) tc 40} #)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | dons@galois.com |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Panic: applyTypeToArgs with -O","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["dons@galois.com"],"type":"Bug","description":"My HWN publishing program,\r\n\r\n http://www.galois.com/~dons/publish.hs\r\n\r\nelicits a panic from a ghc 6.8 snapshot from Sep 9, when compiled with -O:\r\n\r\n{{{\r\n$ ghc --make -O publish.hs -o publish -no-recomp\r\n[1 of 1] Compiling Main ( publish.hs, publish.o )\r\nghc-6.9.20070916: panic! (the 'impossible' happened)\r\n (GHC version 6.9.20070916 for x86_64-unknown-openbsd):\r\n\tapplyTypeToArgs\r\n unix-2.0:System.Posix.Signals.a37{v rjv} [gid]\r\n (unix-2.0:System.Posix.Signals.a25{v rju} [gid]\r\n `cast` (base:GHC.Prim.sym{(w) tc 34v}\r\n\t\t (base:Foreign.C.Types.:CoCInt{tc rjt})\r\n\t :: <pred>base:GHC.Int.Int32{tc 3V}\r\n\t\t\t ~\r\n\t\t\t<nt>base:Foreign.C.Types.CInt{tc r9e}))\r\n unix-2.0:System.Posix.Signals.Ignore{v rjs} [gid]\r\n (base:Data.Maybe.Nothing{v r4U} [gid]\r\n\t @ <nt>unix-2.0:System.Posix.Signals.SignalSet{tc rjr})\r\n eta{v a3Uh} [lid]\r\n (# base:GHC.Prim.State#{(w) tc 32q}\r\n\t base:GHC.Prim.RealWorld{(w) tc 31E},\r\n base:GHC.Base.(){(w) tc 40} #)\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/1807type equality coercions not symmetric + order dependent2019-07-07T19:11:39Zguesttype equality coercions not symmetric + order dependentI'm not entirely sure this is a bug, but it seems pretty weird behaviour:
`a ~ b` cannot always be replaced by `b ~ a`
`a ~ b, c ~ d` cannot always be replaced by `c ~ d, a ~ b`
```
{-# LANGUAGE TypeFamilies, GADTs #-}
module Test whe...I'm not entirely sure this is a bug, but it seems pretty weird behaviour:
`a ~ b` cannot always be replaced by `b ~ a`
`a ~ b, c ~ d` cannot always be replaced by `c ~ d, a ~ b`
```
{-# LANGUAGE TypeFamilies, GADTs #-}
module Test where
data List n where
-- Works
--Cons :: (Maybe n ~ n') => List n -> List n'
--Cons :: (Maybe n ~ n', n' ~ Maybe n) => List n -> List n'
-- Fails
Cons :: (n' ~ Maybe n) => List n -> List n'
--Cons :: (n' ~ Maybe n, Maybe n ~ n') => List n -> List n'
class Snoc i where
snoc :: List i -> List (Maybe i)
instance Snoc i => Snoc (Maybe i) where
snoc (Cons xs) = Cons (snoc xs)
```
This module compiles fine with both 6.8.0.20071025 and 6.9.20071025 using one of the first two Constructors. With either of the last two constructors both versions say:
```
Could not deduce (Snoc n) from the context ()
arising from a use of `snoc' at Test.hs:17:27-33
Possible fix: add (Snoc n) to the context of the constructor `Cons'
In the first argument of `Cons', namely `(snoc xs)'
In the expression: Cons (snoc xs)
In the definition of `snoc': snoc (Cons xs) = Cons (snoc xs)
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | rturk@science.uva.nl |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"type equality coercions not symmetric + order dependent","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8","keywords":["coercions","constraints","equality","order","symmetry","type"],"differentials":[],"test_case":"","architecture":"Unknown","cc":["rturk@science.uva.nl"],"type":"Bug","description":"I'm not entirely sure this is a bug, but it seems pretty weird behaviour:\r\n\r\n`a ~ b` cannot always be replaced by `b ~ a`\r\n\r\n`a ~ b, c ~ d` cannot always be replaced by `c ~ d, a ~ b`\r\n\r\n{{{\r\n{-# LANGUAGE TypeFamilies, GADTs #-}\r\nmodule Test where\r\n\r\ndata List n where\r\n -- Works\r\n --Cons :: (Maybe n ~ n') => List n -> List n'\r\n --Cons :: (Maybe n ~ n', n' ~ Maybe n) => List n -> List n'\r\n\r\n -- Fails\r\n Cons :: (n' ~ Maybe n) => List n -> List n'\r\n --Cons :: (n' ~ Maybe n, Maybe n ~ n') => List n -> List n'\r\n\r\nclass Snoc i where\r\n snoc :: List i -> List (Maybe i)\r\n\r\ninstance Snoc i => Snoc (Maybe i) where\r\n snoc (Cons xs) = Cons (snoc xs)\r\n}}}\r\n\r\nThis module compiles fine with both 6.8.0.20071025 and 6.9.20071025 using one of the first two Constructors. With either of the last two constructors both versions say:\r\n\r\n{{{\r\n Could not deduce (Snoc n) from the context ()\r\n arising from a use of `snoc' at Test.hs:17:27-33\r\n Possible fix: add (Snoc n) to the context of the constructor `Cons'\r\n In the first argument of `Cons', namely `(snoc xs)'\r\n In the expression: Cons (snoc xs)\r\n In the definition of `snoc': snoc (Cons xs) = Cons (snoc xs)\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1815Occurs check error from equality constraint2019-07-07T19:11:37ZguestOccurs check error from equality constraintI was writing that manipulates witnesses for equality constraints,
and saw some occurs check errors for equations matching my constraints.
(This is with ghc-6.9.20071025).
```
Bug.hs:19:31:
Occurs check: cannot construct the infinit...I was writing that manipulates witnesses for equality constraints,
and saw some occurs check errors for equations matching my constraints.
(This is with ghc-6.9.20071025).
```
Bug.hs:19:31:
Occurs check: cannot construct the infinite type: n = Sum Z n
In the pattern: Refl
In a case alternative: Refl -> Refl
In the expression: case zerol n of Refl -> Refl
```
Here is the program producing that error:
```
{-# OPTIONS -fglasgow-exts #-}
module Bug where
data Z
data S a
type family Sum n m
type instance Sum n Z = n
type instance Sum n (S m) = S (Sum n m)
data Nat n where
NZ :: Nat Z
NS :: (S n ~ sn) => Nat n -> Nat sn
data EQ a b = forall q . (a ~ b) => Refl
zerol :: Nat n -> EQ n (Sum Z n)
zerol NZ = Refl
zerol (NS n) = case zerol n of Refl -> Refl
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Occurs check error from equality constraint","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I was writing that manipulates witnesses for equality constraints,\r\nand saw some occurs check errors for equations matching my constraints.\r\n(This is with ghc-6.9.20071025).\r\n\r\n{{{\r\nBug.hs:19:31:\r\n Occurs check: cannot construct the infinite type: n = Sum Z n\r\n In the pattern: Refl\r\n In a case alternative: Refl -> Refl\r\n In the expression: case zerol n of Refl -> Refl\r\n}}}\r\n\r\nHere is the program producing that error:\r\n\r\n{{{\r\n{-# OPTIONS -fglasgow-exts #-}\r\nmodule Bug where\r\n\r\ndata Z\r\ndata S a\r\n\r\ntype family Sum n m\r\ntype instance Sum n Z = n\r\ntype instance Sum n (S m) = S (Sum n m)\r\n\r\ndata Nat n where\r\n NZ :: Nat Z\r\n NS :: (S n ~ sn) => Nat n -> Nat sn\r\n\r\ndata EQ a b = forall q . (a ~ b) => Refl\r\n\r\nzerol :: Nat n -> EQ n (Sum Z n)\r\nzerol NZ = Refl\r\nzerol (NS n) = case zerol n of Refl -> Refl\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1823GADTs and scoped type variables don't work right2019-07-07T19:11:34ZSimon Peyton JonesGADTs and scoped type variables don't work rightIn this program, which is also in the testsuite as `gadt/scoped.hs`, all three definitions of g should work
```
{-# OPTIONS_GHC -XGADTs -XScopedTypeVariables -XPatternSignatures #-}
module GADT where
data C x y where
C :: a -> C ...In this program, which is also in the testsuite as `gadt/scoped.hs`, all three definitions of g should work
```
{-# OPTIONS_GHC -XGADTs -XScopedTypeVariables -XPatternSignatures #-}
module GADT where
data C x y where
C :: a -> C a a
data D x y where
D :: C b c -> D a c
------- All these should be ok
-- Rejected!
g1 :: forall x y . C x y -> ()
-- C (..) :: C x y
-- Inside match on C, x=y
g1 (C (p :: y)) = ()
-- OK!
g2 :: forall x y . C x y -> ()
-- C (..) :: C x y
-- Inside match on C, x=y
g2 (C (p :: x)) = ()
-- Rejected!
g3 :: forall x y . D x y -> ()
-- D (..) :: D x y
-- C (..) :: C sk y
-- sk = y
-- p :: sk
g3 (D (C (p :: y))) = ()
```
But they don't. The reason is that the "refinement" is applied to the environment only after checking an entire pattern; but the refinement is needed during checking the pattern if scoped type variables are to work right.
I don't propose to fix this, because it'll come out in the wash when we get rid of type refinements in favour of equality constraints.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ganesh@earth.li |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"GADTs and scoped type variables don't work right","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"6.10 branch","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"chak"},"version":"6.8.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":["ganesh@earth.li"],"type":"Bug","description":"In this program, which is also in the testsuite as `gadt/scoped.hs`, all three definitions of g should work\r\n{{{\r\n{-# OPTIONS_GHC -XGADTs -XScopedTypeVariables -XPatternSignatures #-}\r\n\r\nmodule GADT where\r\n\r\ndata C x y where\r\n C :: a -> C a a\r\n\r\ndata D x y where\r\n D :: C b c -> D a c\r\n\r\n------- All these should be ok\r\n\r\n-- Rejected!\r\ng1 :: forall x y . C x y -> ()\r\n-- C (..) :: C x y\r\n-- Inside match on C, x=y\r\ng1 (C (p :: y)) = ()\r\n\r\n-- OK!\r\ng2 :: forall x y . C x y -> ()\r\n-- C (..) :: C x y\r\n-- Inside match on C, x=y\r\ng2 (C (p :: x)) = ()\r\n\r\n-- Rejected!\r\ng3 :: forall x y . D x y -> ()\r\n-- D (..) :: D x y\r\n-- C (..) :: C sk y\r\n--\tsk = y\r\n-- p :: sk\r\ng3 (D (C (p :: y))) = ()\r\n}}}\r\nBut they don't. The reason is that the \"refinement\" is applied to the environment only after checking an entire pattern; but the refinement is needed during checking the pattern if scoped type variables are to work right.\r\n\r\nI don't propose to fix this, because it'll come out in the wash when we get rid of type refinements in favour of equality constraints. ","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1894Add a total order on type constructors2019-07-07T19:11:10ZguestAdd a total order on type constructorsSeveral proposals for ExtensibleRecords can be implemented as libraries if type constructors can be ordered globally.
This proposal is to add built-in types:
```
data LabelLT
data LabelEQ
data LabelGT
type family LabelCMP
```
such tha...Several proposals for ExtensibleRecords can be implemented as libraries if type constructors can be ordered globally.
This proposal is to add built-in types:
```
data LabelLT
data LabelEQ
data LabelGT
type family LabelCMP
```
such that, for any two datatypes
```
data N = N
data M = M
```
the instance `LabelCMP N M` takes one of the values `LabelLT, LabelEQ, LabelGT` depending on the lexicographic ordering on the fully-qualified names of `N` and `M`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.1 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Multiple |
| Architecture | Multiple |
</details>
<!-- {"blocked_by":[],"summary":"Add a total order on type constructors","status":"New","operating_system":"Multiple","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.1","keywords":[],"differentials":[],"test_case":"","architecture":"Multiple","cc":[""],"type":"FeatureRequest","description":"Several proposals for ExtensibleRecords can be implemented as libraries if type constructors can be ordered globally.\r\n\r\nThis proposal is to add built-in types:\r\n{{{\r\ndata LabelLT\r\ndata LabelEQ\r\ndata LabelGT\r\ntype family LabelCMP\r\n}}}\r\nsuch that, for any two datatypes\r\n{{{\r\ndata N = N\r\ndata M = M\r\n}}}\r\nthe instance {{{LabelCMP N M}}} takes one of the values {{{LabelLT, LabelEQ, LabelGT}}} depending on the lexicographic ordering on the fully-qualified names of {{{N}}} and {{{M}}}.\r\n\r\n\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/1897Ambiguous types and rejected type signatures2019-07-07T19:11:09ZguestAmbiguous types and rejected type signaturesThis ticket collects a bunch of examples where GHC
- Rejects a function with a type signature but, if the type signature is removed, accepts the function and infers precisely the type that was originally specified.
- Accepts type signat...This ticket collects a bunch of examples where GHC
- Rejects a function with a type signature but, if the type signature is removed, accepts the function and infers precisely the type that was originally specified.
- Accepts type signatures that are utterly ambiguous; that is, the function could never be called, or only in the presence of bizarre instance declarations.
- Rejects definitions that clearly have a unique typing.
Original example: the following programm does not compile:
```
{-# LANGUAGE TypeFamilies #-}
import Control.Monad
import Data.Maybe
class Bug s where
type Depend s
next :: s -> Depend s -> Maybe s
start :: s
isValid :: (Bug s) => [Depend s] -> Bool
isValid ds = isJust $ foldM next start ds
```
Error:
```
GHCi, version 6.9.20071105: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( GHC-Bug.hs, interpreted )
Bug.hs:13:39:
Couldn't match expected type `Depend a'
against inferred type `Depend s'
Expected type: [Depend a]
Inferred type: [Depend s]
In the third argument of `foldM', namely `ds'
In the second argument of `($)', namely `foldM next start ds'
Failed, modules loaded: none.
```
When one elides the type signature the program compiles yielding the offending signature:
```
Prelude> :r
[1 of 1] Compiling Main ( GHC-Bug.hs, interpreted )
Ok, modules loaded: Main.
*Main> :t isValid
isValid :: (Bug a) => [Depend a] -> Bool
```
Compiler version: 6.9.20071105
Best regards,
> Harald Holtmann (haskell\@zeuxis.de)7.2.1Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1900Type families with class constraints: type-checker loops2019-07-07T19:11:08Zh.holtmannType families with class constraints: type-checker loopsThe following program:
```
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
class (Eq (Depend s))=> Bug s where
type Depend s
trans :: Depend s -> Depend s
instance Bug Int where
type Depend Int = ()
trans = (+1)
check ::...The following program:
```
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
class (Eq (Depend s))=> Bug s where
type Depend s
trans :: Depend s -> Depend s
instance Bug Int where
type Depend Int = ()
trans = (+1)
check :: (Bug s) => Depend s -> Bool
check d = d == trans d
```
runs into a type-checker loop
```
GHC-Bug.hs:1:0:
Context reduction stack overflow; size = 20
Use -fcontext-stack=N to increase stack size to N
`ic :: {(Bug Int, Eq (Depend Int)) => Num ()}'
arising from the type signature for `trans' at GHC-Bug.hs:24:2-13
`ic :: {(Bug Int, Eq (Depend Int)) => Num ()}'
arising from the type signature for `trans' at GHC-Bug.hs:24:2-13
<snip>
```
Of course, this program should not compile, but the type-checker should not loop.
compiler: 6.9.20071105
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.9 |
| 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":"Type families with class constraints: type-checker loops","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program:\r\n{{{\r\n{-# LANGUAGE TypeFamilies, FlexibleContexts #-}\r\n\r\nclass (Eq (Depend s))=> Bug s where\r\n type Depend s \r\n trans :: Depend s -> Depend s\r\n \r\ninstance Bug Int where\r\n type Depend Int = ()\r\n trans = (+1)\r\n \r\ncheck :: (Bug s) => Depend s -> Bool\r\ncheck d = d == trans d\r\n}}}\r\nruns into a type-checker loop\r\n{{{\r\nGHC-Bug.hs:1:0:\r\n Context reduction stack overflow; size = 20\r\n Use -fcontext-stack=N to increase stack size to N\r\n `ic :: {(Bug Int, Eq (Depend Int)) => Num ()}'\r\n arising from the type signature for `trans' at GHC-Bug.hs:24:2-13\r\n `ic :: {(Bug Int, Eq (Depend Int)) => Num ()}'\r\n arising from the type signature for `trans' at GHC-Bug.hs:24:2-13\r\n <snip>\r\n}}}\r\n\r\nOf course, this program should not compile, but the type-checker should not loop.\r\n\r\ncompiler: 6.9.20071105","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1928Confusing type error message2022-03-07T06:48:02ZjosefConfusing type error messageThe following code (which is part of a bigger module) needs scoped type variables to compile.
```
run_state :: forall a s. State s a -> s -> (a,s)
run_state m s = observe_monad unit_op bind_op m where
unit_op v = (v,s)
bind...The following code (which is part of a bigger module) needs scoped type variables to compile.
```
run_state :: forall a s. State s a -> s -> (a,s)
run_state m s = observe_monad unit_op bind_op m where
unit_op v = (v,s)
bind_op :: BindOp (StateE s) a (a,s)
bind_op Get k = run_state (k s) s
bind_op (Put s1) k = run_state (k ()) s1
```
However, forgetting to turn on scoped type variables will give a very confusing error message:
```
Unimo.hs:56:36:
Couldn't match expected type `s1' against inferred type `s'
`s1' is a rigid type variable bound by
the type signature for `bind_op' at Unimo.hs:55:28
`s' is a rigid type variable bound by
the type signature for `run_state' at Unimo.hs:52:22
In the first argument of `k', namely `s'
In the first argument of `run_state', namely `(k s)'
In the expression: run_state (k s) s
```
Line 52 is the type signature of run_state and line 55 is the type signature of bind_op. The error message talks about a type variable \`s1' which isn't mentioned anywhere. I guess the reason for this is that we have name collision and this is ghc's way of trying to tell the two variables apart. I don't think it works that well though. But I'm afraid I don't have any suggestion on how to make it better.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Confusing type error message","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"The following code (which is part of a bigger module) needs scoped type variables to compile.\r\n\r\n{{{\r\nrun_state :: forall a s. State s a -> s -> (a,s)\r\nrun_state m s = observe_monad unit_op bind_op m where\r\n unit_op v = (v,s)\r\n bind_op :: BindOp (StateE s) a (a,s)\r\n bind_op Get k = run_state (k s) s\r\n bind_op (Put s1) k = run_state (k ()) s1\r\n}}}\r\nHowever, forgetting to turn on scoped type variables will give a very confusing error message:\r\n{{{\r\nUnimo.hs:56:36:\r\n Couldn't match expected type `s1' against inferred type `s'\r\n `s1' is a rigid type variable bound by\r\n the type signature for `bind_op' at Unimo.hs:55:28\r\n `s' is a rigid type variable bound by\r\n the type signature for `run_state' at Unimo.hs:52:22\r\n In the first argument of `k', namely `s'\r\n In the first argument of `run_state', namely `(k s)'\r\n In the expression: run_state (k s) s\r\n}}}\r\nLine 52 is the type signature of run_state and line 55 is the type signature of bind_op. The error message talks about a type variable `s1' which isn't mentioned anywhere. I guess the reason for this is that we have name collision and this is ghc's way of trying to tell the two variables apart. I don't think it works that well though. But I'm afraid I don't have any suggestion on how to make it better.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/1968data family + GADT: not implemented yet2019-07-07T19:10:50ZRemidata family + GADT: not implemented yetMy very first attempt at playing with data type families + GADTs went wrong, using 6.9.20071209:
```
{-# LANGUAGE TypeFamilies, GADTs #-}
data family HiThere a :: *
data instance HiThere () where
HiThere :: HiThere ()
```
```
GHC...My very first attempt at playing with data type families + GADTs went wrong, using 6.9.20071209:
```
{-# LANGUAGE TypeFamilies, GADTs #-}
data family HiThere a :: *
data instance HiThere () where
HiThere :: HiThere ()
```
```
GHCi, version 6.9.20071209: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( bar.hs, interpreted )
*** Exception: typecheck/TcTyClsDecls.lhs:(878,4)-(884,42): Non-exhaustive patterns in function choose_univs
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | rturk@science.uva.nl |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"data family + GADT = Non-exhaustive patterns in function choose_univs","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":["GADT","choose_univs","data","family","type"],"differentials":[],"test_case":"","architecture":"Unknown","cc":["rturk@science.uva.nl"],"type":"Bug","description":"My very first attempt at playing with data type families + GADTs went wrong, using 6.9.20071209:\r\n\r\n{{{\r\n{-# LANGUAGE TypeFamilies, GADTs #-}\r\n\r\ndata family HiThere a :: *\r\n\r\ndata instance HiThere () where\r\n HiThere :: HiThere ()\r\n}}}\r\n\r\n{{{\r\nGHCi, version 6.9.20071209: http://www.haskell.org/ghc/ :? for help\r\nLoading package base ... linking ... done.\r\n[1 of 1] Compiling Main ( bar.hs, interpreted )\r\n*** Exception: typecheck/TcTyClsDecls.lhs:(878,4)-(884,42): Non-exhaustive patterns in function choose_univs\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/1991Improve GADT type inference2019-07-07T19:10:45ZguestImprove GADT type inferenceIt'd be nice if programs like the following didn't require type annotations:
```
data PromptR (r :: * -> *) (a :: *) where
NewRef :: a -> PromptR r (r a)
Fetch :: r a -> PromptR r a
Set :: r a -> a -> PromptR r ()
-- prIO :: P...It'd be nice if programs like the following didn't require type annotations:
```
data PromptR (r :: * -> *) (a :: *) where
NewRef :: a -> PromptR r (r a)
Fetch :: r a -> PromptR r a
Set :: r a -> a -> PromptR r ()
-- prIO :: PromptR IORef a -> IO a
prIO (NewRef a) = newIORef a
prIO (Fetch r) = readIORef r
prIO (Set r v) = writeIORef r v
```
I get the following cryptic error message:
```
prompt.lhs:193:7:
Couldn't match kind `?' against `* -> *'
When matching the kinds of `t :: ?' and `t1 :: * -> *'
Expected type: t1
Inferred type: t
In the pattern: NewRef a
```
It seems to me you shouldn't need a type annotation here:
```
prIO (NewRef a) = newIORef a
therefore:
prIO :: x -> y
x ~ PromptR r z
in this case only:
z ~ (r a), a :: a (from GADT argument)
newIORef :: b -> IO (IORef b)
a ~ b
y ~ IO (IORef a) | r ~ IORef, y ~ IO (r a)
prIO (Fetch r) = readIORef r
in this case only:
r :: r z (from GADT argument)
readIORef :: IORef b -> IO b
r ~ IORef
b ~ z
y ~ IO z
attempt to unify with above case, and we get
x ~ PromptR r z
y ~ IO z
r ~ IORef
prIO :: PromptR IORef z -> IO z
is the least specific possibility that matches both cases.
```
Interestingly, if I include only the second case, the type is inferred successfully; if I include the second and third cases, the type is inferred incorrectly as `PromptR IORef () -> IO ()`
P.S. I only tested this on GHC6.6.1; apologies if this already works in 6.8.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.6.1 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ryani.spam@gmail.com |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Improve GADT type inference","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":["ryani.spam@gmail.com"],"type":"FeatureRequest","description":"It'd be nice if programs like the following didn't require type annotations:\r\n\r\n{{{\r\ndata PromptR (r :: * -> *) (a :: *) where\r\n NewRef :: a -> PromptR r (r a)\r\n Fetch :: r a -> PromptR r a\r\n Set :: r a -> a -> PromptR r ()\r\n\r\n-- prIO :: PromptR IORef a -> IO a\r\nprIO (NewRef a) = newIORef a\r\nprIO (Fetch r) = readIORef r\r\nprIO (Set r v) = writeIORef r v\r\n}}}\r\n\r\nI get the following cryptic error message:\r\n{{{\r\nprompt.lhs:193:7:\r\n Couldn't match kind `?' against `* -> *'\r\n When matching the kinds of `t :: ?' and `t1 :: * -> *'\r\n Expected type: t1\r\n Inferred type: t\r\n In the pattern: NewRef a\r\n}}}\r\n\r\nIt seems to me you shouldn't need a type annotation here:\r\n{{{\r\nprIO (NewRef a) = newIORef a\r\ntherefore:\r\n prIO :: x -> y\r\n x ~ PromptR r z\r\n\r\nin this case only:\r\n z ~ (r a), a :: a (from GADT argument)\r\n newIORef :: b -> IO (IORef b)\r\n a ~ b\r\n y ~ IO (IORef a) | r ~ IORef, y ~ IO (r a)\r\n\r\nprIO (Fetch r) = readIORef r\r\nin this case only:\r\n r :: r z (from GADT argument)\r\n readIORef :: IORef b -> IO b\r\n r ~ IORef\r\n b ~ z\r\n y ~ IO z\r\n\r\nattempt to unify with above case, and we get\r\n x ~ PromptR r z\r\n y ~ IO z\r\n r ~ IORef\r\n prIO :: PromptR IORef z -> IO z\r\nis the least specific possibility that matches both cases.\r\n}}}\r\n\r\nInterestingly, if I include only the second case, the type is inferred successfully; if I include the second and third cases, the type is inferred incorrectly as {{{PromptR IORef () -> IO ()}}}\r\n\r\nP.S. I only tested this on GHC6.6.1; apologies if this already works in 6.8.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2004Pattern matching against GADTs without -XGADTs has odd behavior.2019-07-07T19:10:41ZguestPattern matching against GADTs without -XGADTs has odd behavior.I'm getting a weird error message declaring a function in GHCi, but the same function declared in the source file works.
Repro case:
```
{-# LANGUAGE GADTs #-}
module Bug where
data Witness a b c where
Z :: Witness a as (a,as)
P...I'm getting a weird error message declaring a function in GHCi, but the same function declared in the source file works.
Repro case:
```
{-# LANGUAGE GADTs #-}
module Bug where
data Witness a b c where
Z :: Witness a as (a,as)
P :: Witness a as xs -> Witness a (b,as) (b,xs)
data Expr a vars where
Lam :: String -> Expr a (b,vars) -> Expr (b -> a) vars
Ap :: Expr (b -> a) vars -> Expr b vars -> Expr a vars
subst :: Witness a vs vsa -> Expr a vs -> Expr b vsa -> Expr b vs
subst = undefined
subAp :: Expr a vs -> Expr a vs
subAp (Ap (Lam _ e) v) = subst Z v e
```
This compiles fine. But in GHCi:
```
> let { subAp2 :: Expr a vs -> Expr a vs ; subAp2 (Ap (Lam _ e) v) = subst Z v e }
<interactive>:1:79:
Couldn't match expected type `a1' against inferred type `a2'
`a1' is a rigid type variable bound by
the type signature for `subAp2' at <interactive>:1:21
`a2' is a rigid type variable bound by
the constructor `Lam' at <interactive>:1:54
Expected type: Expr a1 (Decl b vs)
Inferred type: Expr a2 (Decl b1 vs)
In the third argument of `subst', namely `e'
In the expression: subst Z v e
```
Interestingly, if I do `:set -XGADTs` followed by that declaration, it works.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Pattern matching against GADTs without -XGADTs has odd behavior.","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"I'm getting a weird error message declaring a function in GHCi, but the same function declared in the source file works.\r\n\r\nRepro case:\r\n\r\n{{{\r\n{-# LANGUAGE GADTs #-}\r\nmodule Bug where\r\n\r\ndata Witness a b c where\r\n Z :: Witness a as (a,as)\r\n P :: Witness a as xs -> Witness a (b,as) (b,xs)\r\n\r\ndata Expr a vars where\r\n Lam :: String -> Expr a (b,vars) -> Expr (b -> a) vars\r\n Ap :: Expr (b -> a) vars -> Expr b vars -> Expr a vars\r\n\r\nsubst :: Witness a vs vsa -> Expr a vs -> Expr b vsa -> Expr b vs\r\nsubst = undefined\r\n\r\nsubAp :: Expr a vs -> Expr a vs\r\nsubAp (Ap (Lam _ e) v) = subst Z v e\r\n}}}\r\n\r\nThis compiles fine. But in GHCi:\r\n{{{\r\n> let { subAp2 :: Expr a vs -> Expr a vs ; subAp2 (Ap (Lam _ e) v) = subst Z v e }\r\n\r\n<interactive>:1:79:\r\n Couldn't match expected type `a1' against inferred type `a2'\r\n `a1' is a rigid type variable bound by\r\n the type signature for `subAp2' at <interactive>:1:21\r\n `a2' is a rigid type variable bound by\r\n the constructor `Lam' at <interactive>:1:54\r\n Expected type: Expr a1 (Decl b vs)\r\n Inferred type: Expr a2 (Decl b1 vs)\r\n In the third argument of `subst', namely `e'\r\n In the expression: subst Z v e\r\n}}}\r\n\r\nInterestingly, if I do {{{:set -XGADTs}}} followed by that declaration, it works.","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchIan Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/2037Inner type declaration causes GHC panic2019-07-07T19:10:30ZbasvandijkInner type declaration causes GHC panicI get a GHC panic when compiling the attached module.
Sorry for the big module but I wasn't able to isolate this to a single simple function.
If I comment the *inner* type of 'unify' on line 112 the module compiles just fine. So it pro...I get a GHC panic when compiling the attached module.
Sorry for the big module but I wasn't able to isolate this to a single simple function.
If I comment the *inner* type of 'unify' on line 112 the module compiles just fine. So it probably has to do with [lexically-scoped type variables](http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Inner type declaration causes GHC panic","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I get a GHC panic when compiling the attached module.\r\n\r\nSorry for the big module but I wasn't able to isolate this to a single simple function.\r\n\r\nIf I comment the ''inner'' type of 'unify' on line 112 the module compiles just fine. So it probably has to do with [http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables lexically-scoped type variables].","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2040GADT regression2019-07-07T19:10:29ZguestGADT regressionThe following compiles fine in 6.8.1 but does not in later versions of GHC.
I'm not sure if this is related to #1823, since there type classes are not involved.
A workaround is included below.
```
{-# OPTIONS_GHC -Wall -fglasgow-exts ...The following compiles fine in 6.8.1 but does not in later versions of GHC.
I'm not sure if this is related to #1823, since there type classes are not involved.
A workaround is included below.
```
{-# OPTIONS_GHC -Wall -fglasgow-exts #-}
module Bug where
data Teq a b where Teq :: Teq a a
class C a b where proof :: Teq a b
data S a = S a
data W b where
-- This would make every version of GHC happy
-- W :: (C a c , c ~ S b) => W a -> W c
W :: C a (S b) => W a -> W (S b)
foo :: W (S ()) -> W (S ()) -> ()
foo (W (_ :: W a1)) (W (_ :: W a2)) =
case proof :: Teq a1 (S ()) of
Teq -> ()
foo2 :: W (S ()) -> W (S ()) -> ()
foo2 (W (_ :: W a1)) (W (_ :: W a2)) =
case proof :: Teq a1 (S ()) of
Teq -> case proof :: Teq a2 (S ()) of
Teq -> ()
```
Results:
1. 8.1 : OK
1. 8.2 : foo OK, foo2 FAIL
```
Bug.hs:23:16:
Could not deduce (C a1 (S ())) from the context ()
arising from a use of `proof' at Bug.hs:23:16-20
```
1. 9.20080108 : FAIL
```
Bug.hs:16:7:
Could not deduce (C a (S ()))
from the context (S () ~ S b1, C a1 (S b1))
arising from a use of `proof' at Bug.hs:16:7-11
Bug.hs:21:7:
Could not deduce (C a (S ()))
from the context (S () ~ S b1, C a1 (S b1))
arising from a use of `proof' at Bug.hs:21:7-11
Bug.hs:22:16:
Could not deduce (C a1 (S ())) from the context (S () ~ a)
arising from a use of `proof' at Bug.hs:22:16-20
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | zunino@di.unipi.it |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"GADT regression","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":["gadt"],"differentials":[],"test_case":"","architecture":"Unknown","cc":["zunino@di.unipi.it"],"type":"Bug","description":"The following compiles fine in 6.8.1 but does not in later versions of GHC.\r\n\r\nI'm not sure if this is related to #1823, since there type classes are not involved.\r\n\r\nA workaround is included below.\r\n\r\n{{{\r\n{-# OPTIONS_GHC -Wall -fglasgow-exts #-}\r\nmodule Bug where\r\n\r\ndata Teq a b where Teq :: Teq a a\r\n\r\nclass C a b where proof :: Teq a b\r\n\r\ndata S a = S a\r\n\r\ndata W b where\r\n -- This would make every version of GHC happy\r\n -- W :: (C a c , c ~ S b) => W a -> W c\r\n W :: C a (S b) => W a -> W (S b)\r\n\r\nfoo :: W (S ()) -> W (S ()) -> ()\r\nfoo (W (_ :: W a1)) (W (_ :: W a2)) =\r\n case proof :: Teq a1 (S ()) of\r\n Teq -> ()\r\n\r\nfoo2 :: W (S ()) -> W (S ()) -> ()\r\nfoo2 (W (_ :: W a1)) (W (_ :: W a2)) =\r\n case proof :: Teq a1 (S ()) of\r\n Teq -> case proof :: Teq a2 (S ()) of\r\n Teq -> ()\r\n}}}\r\n\r\nResults:\r\n\r\n6.8.1 : OK\r\n\r\n6.8.2 : foo OK, foo2 FAIL\r\n{{{\r\nBug.hs:23:16:\r\n Could not deduce (C a1 (S ())) from the context ()\r\n arising from a use of `proof' at Bug.hs:23:16-20\r\n}}}\r\n6.9.20080108 : FAIL\r\n{{{\r\nBug.hs:16:7:\r\n Could not deduce (C a (S ()))\r\n from the context (S () ~ S b1, C a1 (S b1))\r\n arising from a use of `proof' at Bug.hs:16:7-11\r\nBug.hs:21:7:\r\n Could not deduce (C a (S ()))\r\n from the context (S () ~ S b1, C a1 (S b1))\r\n arising from a use of `proof' at Bug.hs:21:7-11\r\nBug.hs:22:16:\r\n Could not deduce (C a1 (S ())) from the context (S () ~ a)\r\n arising from a use of `proof' at Bug.hs:22:16-20\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2079GHC 6.8.* doesn't recognize type variables2019-07-07T19:10:18Zdaniel.is.fischerGHC 6.8.* doesn't recognize type variablesThe module
```
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{- # LANGUAGE FlexibleInstances # -}
module Leandro where
data Abb a b = Branch a b (Abb a b) (Abb a b) | Leaf
data ListAssoc a b = Node a b...The module
```
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{- # LANGUAGE FlexibleInstances # -}
module Leandro where
data Abb a b = Branch a b (Abb a b) (Abb a b) | Leaf
data ListAssoc a b = Node a b (ListAssoc a b) | Empty
class Container c a b |c -> a, c -> b where
empty :: c
add :: c -> a -> b -> c
search :: c -> a -> Maybe b
del :: c -> a -> c
toListPair :: c -> [(a,b)]
instance (Ord a) => Container (Abb a b) a b where
empty = Leaf
add Leaf x y = Branch x y Leaf Leaf
add arb@(Branch ni nd ri rd) x y
|x == ni = arb
|x > ni = Branch ni nd ri (add rd x y)
|otherwise = Branch ni nd (add ri x y) rd
search Leaf x = Nothing
search (Branch ni nd ri rd) x
|x == ni = Just nd
|x > ni = search rd x
|x < ni = search ri x
```
triggers the following error in ghci (6.8.1 and 6.8.2):
```
dafis@linux:~/Documents/haskell/move> ghci Leandro
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Leandro ( Leandro.hs, interpreted )
Leandro.hs:17:0:
Illegal instance declaration for `Container (Abb a b) a b'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are distinct type *variables*
Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `Container (Abb a b) a b'
Failed, modules loaded: none.
```
To the best of my knowledge, a and b in 'instance Container (Abb a b) a b where' are distinct type variables and neither hugs nor ghci-6.6.1 complain. Converting the third line to a language pragma makes the code acceptable to 6.8.\*.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.8.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":"GHC 6.8.* doesn't recognize type variables","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The module\r\n{{{\r\n{-# LANGUAGE MultiParamTypeClasses #-}\r\n{-# LANGUAGE FunctionalDependencies #-}\r\n{- # LANGUAGE FlexibleInstances # -}\r\nmodule Leandro where\r\n\r\ndata Abb a b = Branch a b (Abb a b) (Abb a b) | Leaf\r\n\r\ndata ListAssoc a b = Node a b (ListAssoc a b) | Empty\r\n\r\nclass Container c a b |c -> a, c -> b where\r\n empty :: c\r\n add :: c -> a -> b -> c\r\n search :: c -> a -> Maybe b\r\n del :: c -> a -> c\r\n toListPair :: c -> [(a,b)]\r\n\r\ninstance (Ord a) => Container (Abb a b) a b where\r\n empty = Leaf\r\n add Leaf x y = Branch x y Leaf Leaf\r\n add arb@(Branch ni nd ri rd) x y\r\n |x == ni = arb\r\n |x > ni = Branch ni nd ri (add rd x y)\r\n |otherwise = Branch ni nd (add ri x y) rd\r\n search Leaf x = Nothing\r\n search (Branch ni nd ri rd) x\r\n |x == ni = Just nd\r\n |x > ni = search rd x\r\n |x < ni = search ri x\r\n}}}\r\ntriggers the following error in ghci (6.8.1 and 6.8.2):\r\n{{{\r\ndafis@linux:~/Documents/haskell/move> ghci Leandro\r\nGHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help\r\nLoading package base ... linking ... done.\r\n[1 of 1] Compiling Leandro ( Leandro.hs, interpreted )\r\n\r\nLeandro.hs:17:0:\r\n Illegal instance declaration for `Container (Abb a b) a b'\r\n (All instance types must be of the form (T a1 ... an)\r\n where a1 ... an are distinct type *variables*\r\n Use -XFlexibleInstances if you want to disable this.)\r\n In the instance declaration for `Container (Abb a b) a b'\r\nFailed, modules loaded: none.\r\n}}}\r\nTo the best of my knowledge, a and b in 'instance Container (Abb a b) a b where' are distinct type variables and neither hugs nor ghci-6.6.1 complain. Converting the third line to a language pragma makes the code acceptable to 6.8.*.","type_of_failure":"OtherFailure","blocking":[]} -->6.8.3Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/2102Typeclass membership doesn't bring coercion superclass requirements into scope2019-07-07T19:10:12ZryaniTypeclass membership doesn't bring coercion superclass requirements into scope```
-- This works:
class C1 a where c1 :: a -> Int
class C1 a => C2 a where c2 :: a -> Int
test :: C2 a => a -> Int
test a = c1 a + c2 a
-- This doesn't work:
class (a ~ b) => E a b
cast :: E a b => a -> b
cast a = a
{- error:
tyfam.hs...```
-- This works:
class C1 a where c1 :: a -> Int
class C1 a => C2 a where c2 :: a -> Int
test :: C2 a => a -> Int
test a = c1 a + c2 a
-- This doesn't work:
class (a ~ b) => E a b
cast :: E a b => a -> b
cast a = a
{- error:
tyfam.hs:36:9:
Couldn't match expected type `b' against inferred type `a'
`b' is a rigid type variable bound by
the type signature for `cast' at tyfam.hs:35:14
`a' is a rigid type variable bound by
the type signature for `cast' at tyfam.hs:35:12
In the expression: a
In the definition of `cast': cast a = a
-}
```
I would expect that the requirement of membership in `E a b` would bring `(a ~ b)` into scope and allow `cast` to typecheck.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Typeclass membership doesn't bring coercion superclass requirements into scope","status":"New","operating_system":"Unknown","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"{{{\r\n-- This works:\r\nclass C1 a where c1 :: a -> Int\r\nclass C1 a => C2 a where c2 :: a -> Int\r\ntest :: C2 a => a -> Int\r\ntest a = c1 a + c2 a\r\n\r\n-- This doesn't work:\r\nclass (a ~ b) => E a b\r\ncast :: E a b => a -> b\r\ncast a = a\r\n\r\n{- error:\r\ntyfam.hs:36:9:\r\n Couldn't match expected type `b' against inferred type `a'\r\n `b' is a rigid type variable bound by\r\n the type signature for `cast' at tyfam.hs:35:14\r\n `a' is a rigid type variable bound by\r\n the type signature for `cast' at tyfam.hs:35:12\r\n In the expression: a\r\n In the definition of `cast': cast a = a\r\n -}\r\n}}}\r\n\r\nI would expect that the requirement of membership in {{{E a b}}} would bring {{{(a ~ b)}}} into scope and allow {{{cast}}} to typecheck.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.2.1Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2112Bad error message for malformed GADTs2019-07-07T19:10:08Zchevalier@alum.wellesley.eduBad error message for malformed GADTsCompiling the following code:
```
data Foo a where
Bar :: a -> a
```
results in the following error message:
```
$ ghc-6.8.1 gadt.hs -XGADTs
gadt.hs:5:3:
Malformed constructor result type: a
In the result type of a data co...Compiling the following code:
```
data Foo a where
Bar :: a -> a
```
results in the following error message:
```
$ ghc-6.8.1 gadt.hs -XGADTs
gadt.hs:5:3:
Malformed constructor result type: a
In the result type of a data constructor: a
In the data type declaration for `Foo'
$
```
It would be nice if the error message mentioned the name of the offending data constructor (`Bar` in this case) -- since there might be more than one.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Bad error message for malformed GADTs","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"Compiling the following code:\r\n\r\n{{{\r\ndata Foo a where\r\n Bar :: a -> a\r\n}}}\r\n\r\nresults in the following error message:\r\n{{{\r\n$ ghc-6.8.1 gadt.hs -XGADTs\r\n\r\ngadt.hs:5:3:\r\n Malformed constructor result type: a\r\n In the result type of a data constructor: a\r\n In the data type declaration for `Foo'\r\n$ \r\n}}}\r\n\r\nIt would be nice if the error message mentioned the name of the offending data constructor ({{{Bar}}} in this case) -- since there might be more than one.","type_of_failure":"OtherFailure","blocking":[]} -->Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/2114Bad error message for omitting -XExistentialQuantification flag2019-07-07T19:10:08Zchevalier@alum.wellesley.eduBad error message for omitting -XExistentialQuantification flagIf I compile this program:
```
module Foo where
data T = forall a . MkT a
```
with:
```
ghc-6.8.1 extest.hs -c
```
I get the error:
```
extest.hs:3:9: Not a constructor: `forall'
```
I think it would be a better error message to ...If I compile this program:
```
module Foo where
data T = forall a . MkT a
```
with:
```
ghc-6.8.1 extest.hs -c
```
I get the error:
```
extest.hs:3:9: Not a constructor: `forall'
```
I think it would be a better error message to suggest passing in the -XExistentialQuantification flag.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Bad error message for omitting -XExistentialQuantification flag","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"If I compile this program:\r\n{{{\r\nmodule Foo where\r\n\r\ndata T = forall a . MkT a\r\n}}}\r\nwith:\r\n{{{\r\nghc-6.8.1 extest.hs -c\r\n}}}\r\n\r\nI get the error:\r\n{{{\r\nextest.hs:3:9: Not a constructor: `forall'\r\n}}}\r\n\r\nI think it would be a better error message to suggest passing in the -XExistentialQuantification flag.","type_of_failure":"OtherFailure","blocking":[]} -->Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/2126Misleading error message for newtype with no constructors2019-07-07T19:10:04Zchevalier@alum.wellesley.eduMisleading error message for newtype with no constructorsFurther adventures in error message pedantry! If I compile this module:
```
module Foo where
newtype X
```
I get:
```
$ ghc -c Foo.hs
Foo.hs:3:0:
`X' has no constructors (-XEmptyDataDecls permits this)
In the newtype declara...Further adventures in error message pedantry! If I compile this module:
```
module Foo where
newtype X
```
I get:
```
$ ghc -c Foo.hs
Foo.hs:3:0:
`X' has no constructors (-XEmptyDataDecls permits this)
In the newtype declaration for `X'
```
Naively, I do what it suggests:
```
$ ghc -c Foo.hs -XEmptyDataDecls
Foo.hs:3:0:
A newtype must have exactly one constructor, but `X' has none
In the newtype declaration for `X'
```
It would be better to just print the second error message even when the user doesn't pass `-XEmptyDataDecls`, and not lead them down a maze of twisty little passages...
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Misleading error message for newtype with no constructors","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"Further adventures in error message pedantry! If I compile this module:\r\n{{{\r\nmodule Foo where\r\n\r\nnewtype X\r\n}}}\r\nI get:\r\n{{{\r\n$ ghc -c Foo.hs\r\n\r\nFoo.hs:3:0:\r\n `X' has no constructors (-XEmptyDataDecls permits this)\r\n In the newtype declaration for `X'\r\n}}}\r\nNaively, I do what it suggests:\r\n{{{\r\n$ ghc -c Foo.hs -XEmptyDataDecls\r\n\r\nFoo.hs:3:0:\r\n A newtype must have exactly one constructor, but `X' has none\r\n In the newtype declaration for `X'\r\n}}}\r\n\r\nIt would be better to just print the second error message even when the user doesn't pass {{{-XEmptyDataDecls}}}, and not lead them down a maze of twisty little passages...","type_of_failure":"OtherFailure","blocking":[]} -->Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/2141Internal error on invalid record update2019-07-07T19:10:01Zrl@cse.unsw.edu.auInternal error on invalid record updateA silly function:
```
foo :: () -> ()
foo x = x { foo = 1 }
```
1. 8.2 says:
```
GHC internal error: `foo' is not in scope
In the expression: x {foo = 1}
In the definition of `foo': foo x = x {foo = 1}
```
HEAD's message is a bit mor...A silly function:
```
foo :: () -> ()
foo x = x { foo = 1 }
```
1. 8.2 says:
```
GHC internal error: `foo' is not in scope
In the expression: x {foo = 1}
In the definition of `foo': foo x = x {foo = 1}
```
HEAD's message is a bit more illuminating:
```
GHC internal error: `foo' is not in scope during type checking, but it passed the renamer
tcg_type_env of environment: []
In the expression: x {foo = 1}
In the definition of `foo': foo x = x {foo = 1}
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Internal error on invalid record update","status":"New","operating_system":"Unknown","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"A silly function:\r\n\r\n{{{\r\nfoo :: () -> ()\r\nfoo x = x { foo = 1 }\r\n}}}\r\n\r\n6.8.2 says:\r\n\r\n{{{\r\nGHC internal error: `foo' is not in scope\r\nIn the expression: x {foo = 1}\r\nIn the definition of `foo': foo x = x {foo = 1}\r\n}}}\r\n\r\nHEAD's message is a bit more illuminating:\r\n\r\n{{{\r\nGHC internal error: `foo' is not in scope during type checking, but it passed the renamer\r\ntcg_type_env of environment: []\r\nIn the expression: x {foo = 1}\r\nIn the definition of `foo': foo x = x {foo = 1}\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchIan Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/2146Decomposition rule for equalities is too weak in case of higher-kinded type f...2019-07-07T19:10:00ZManuel M T ChakravartyDecomposition rule for equalities is too weak in case of higher-kinded type families```
foo :: (F Int a ~ F Int [a]) => a -> [a]
foo = undefined
```
gives us
```
Occurs check: cannot construct the infinite type: a = [a]
```
but
```
foo :: (F Int a ~ F Bool [a]) => a -> [a]
foo = undefined
```
doesn't - although...```
foo :: (F Int a ~ F Int [a]) => a -> [a]
foo = undefined
```
gives us
```
Occurs check: cannot construct the infinite type: a = [a]
```
but
```
foo :: (F Int a ~ F Bool [a]) => a -> [a]
foo = undefined
```
doesn't - although both should lead to the same error.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Multiple |
| Architecture | Multiple |
</details>
<!-- {"blocked_by":[],"summary":"Decomposition rule for equalities is too weak in case of higher-kinded type families","status":"New","operating_system":"Multiple","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"chak"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Multiple","cc":[""],"type":"Bug","description":"{{{\r\nfoo :: (F Int a ~ F Int [a]) => a -> [a]\r\nfoo = undefined\r\n}}}\r\ngives us\r\n{{{\r\n Occurs check: cannot construct the infinite type: a = [a]\r\n}}}\r\nbut\r\n{{{\r\nfoo :: (F Int a ~ F Bool [a]) => a -> [a]\r\nfoo = undefined\r\n}}}\r\ndoesn't - although both should lead to the same error.","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2157Equality Constraints with Type Families2019-07-07T19:09:56ZhpachecoEquality Constraints with Type FamiliesFor the implementation of fixpoint recursive definitions for a datatype I have defined the family:
```
type family F a :: * -> *
type FList a x = Either () (a,x)
type instance F [a] = FList a
type instance F Int = Either One
```
for wh...For the implementation of fixpoint recursive definitions for a datatype I have defined the family:
```
type family F a :: * -> *
type FList a x = Either () (a,x)
type instance F [a] = FList a
type instance F Int = Either One
```
for which we can define functor instances
```
instance (Functor (F [a])) where
fmap _ (Left _) = Left ()
fmap f (Right (a,x)) = Right (a,f x)
...
```
However, in the definition of recursive patterns over these representation, I need some coercions to hold such as
```
F d c ~ F a (c,a)
```
but in the current implementation they are evaluated as
```
F d ~ F a /\ c ~(c,a)
```
what does not express the semantics of "fully parameterized equality" that I was expecting
You can find a pratical example in ([my conversions at the haskell-cafe mailing list](http://groups.google.com/group/fa.haskell/browse_thread/thread/6ea21dcade9e632f/01148521c33ac29a))
In order to avoid this, the family could be redefined as
```
type family F a x :: *
type instance F [a] x = Either() (a,x)
type instance F Int x = Either One x
```
but this would mean that I cannot define instances for Functor (F a) because not enough parameters passed to F.
PS. This might sound more as a feature request than a bug, so sorry if I misplaced this information. I am willing to work on this subject to help supporting my test case.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Equality Constraints with Type Families","status":"New","operating_system":"Unknown","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"For the implementation of fixpoint recursive definitions for a datatype I have defined the family:\r\n\r\n\r\n{{{\r\ntype family F a :: * -> *\r\ntype FList a x = Either () (a,x)\r\ntype instance F [a] = FList a\r\ntype instance F Int = Either One\r\n}}}\r\n\r\n\r\nfor which we can define functor instances\r\n\r\n\r\n{{{\r\ninstance (Functor (F [a])) where\r\n fmap _ (Left _) = Left ()\r\n fmap f (Right (a,x)) = Right (a,f x)\r\n...\r\n}}}\r\n\r\n\r\nHowever, in the definition of recursive patterns over these representation, I need some coercions to hold such as\r\n\r\n\r\n{{{\r\nF d c ~ F a (c,a)\r\n}}}\r\n\r\n\r\nbut in the current implementation they are evaluated as\r\n\r\n\r\n{{{\r\nF d ~ F a /\\ c ~(c,a)\r\n}}}\r\n\r\nwhat does not express the semantics of \"fully parameterized equality\" that I was expecting\r\n\r\nYou can find a pratical example in ([http://groups.google.com/group/fa.haskell/browse_thread/thread/6ea21dcade9e632f/01148521c33ac29a my conversions at the haskell-cafe mailing list])\r\n\r\nIn order to avoid this, the family could be redefined as\r\n\r\n\r\n{{{\r\ntype family F a x :: *\r\ntype instance F [a] x = Either() (a,x)\r\ntype instance F Int x = Either One x\r\n}}}\r\n\r\n\r\nbut this would mean that I cannot define instances for Functor (F a) because not enough parameters passed to F.\r\n\r\nPS. This might sound more as a feature request than a bug, so sorry if I misplaced this information. I am willing to work on this subject to help supporting my test case.","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2165Type checker for Type families2019-07-07T19:09:54ZhpachecoType checker for Type familiesFor a type family and a class definition:
type family F a x :: \*
class FunctorF x where
fmapF :: d -\> (a -\> b) -\> F x a -\> F x b
Curiously if I have
```
fff a = fmapF a id
```
it compiles correctly. But if I infer the type sig...For a type family and a class definition:
type family F a x :: \*
class FunctorF x where
fmapF :: d -\> (a -\> b) -\> F x a -\> F x b
Curiously if I have
```
fff a = fmapF a id
```
it compiles correctly. But if I infer the type signature of fff I get
```
fff :: forall d x. (FunctorF d) => d -> F d x -> F d x
```
On the other side, a similar problem as before arises when
```
fff :: forall d x. (FunctorF d) => d -> F d x -> F d x
fff a = fmapF a id
```
This follows up from http://hackage.haskell.org/trac/ghc/ticket/2157
On Tue, Mar 18, 2008 at 7:03 PM, Ryan Ingram \<ryani.spam\@gmail.com\> wrote:
Interestingly, this works when you also give a type signature to "id":
```
fff :: forall d x. (FunctorF d) => d -> F d x -> F d x
fff a = fmapF a (id :: x -> x)
```
compiles for me (ghc6.8.2). There's probably a bug in the type
checker; inference is working with no type signatures, but checking
fails.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Type checker for Type families","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"For a type family and a class definition:\r\n\r\ntype family F a x :: *\r\n\r\nclass FunctorF x where\r\n\tfmapF :: d -> (a -> b) -> F x a -> F x b\r\n\r\nCuriously if I have\r\n\r\n\r\n{{{\r\nfff a = fmapF a id\r\n}}}\r\n\r\n\r\nit compiles correctly. But if I infer the type signature of fff I get\r\n\r\n{{{\r\n\r\nfff :: forall d x. (FunctorF d) => d -> F d x -> F d x\r\n}}}\r\n\r\n\r\nOn the other side, a similar problem as before arises when\r\n\r\n\r\n{{{\r\nfff :: forall d x. (FunctorF d) => d -> F d x -> F d x\r\nfff a = fmapF a id\r\n}}}\r\n\r\nThis follows up from http://hackage.haskell.org/trac/ghc/ticket/2157\r\n\r\nOn Tue, Mar 18, 2008 at 7:03 PM, Ryan Ingram <ryani.spam@gmail.com> wrote:\r\nInterestingly, this works when you also give a type signature to \"id\":\r\n\r\n{{{\r\n\r\nfff :: forall d x. (FunctorF d) => d -> F d x -> F d x\r\nfff a = fmapF a (id :: x -> x)\r\n}}}\r\n\r\n\r\ncompiles for me (ghc6.8.2). There's probably a bug in the type\r\nchecker; inference is working with no type signatures, but checking\r\nfails.","type_of_failure":"OtherFailure","blocking":[]} -->Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2182GHC sessions (--make, --interactive, GHC API) erroneously retain instances2022-04-29T16:54:26Zclaus.reinke@talk21.comGHC sessions (--make, --interactive, GHC API) erroneously retain instancesThe EPS (external-package state) is only ever increased, never decreased between compilation of different modules in a single batch compilation or GHCi session.
Example 1 (GHCi):
```
ezyang@sabre:~/Dev/labs/ezyangest$ ghci
GHCi, versio...The EPS (external-package state) is only ever increased, never decreased between compilation of different modules in a single batch compilation or GHCi session.
Example 1 (GHCi):
```
ezyang@sabre:~/Dev/labs/ezyangest$ ghci
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> (\x -> x)
<interactive>:2:1:
No instance for (Show (t0 -> t0)) arising from a use of `print'
Possible fix: add an instance declaration for (Show (t0 -> t0))
In a stmt of an interactive GHCi command: print it
Prelude> :m +Text.Show.Functions
Prelude Text.Show.Functions> (\x -> x)
<function>
Prelude Text.Show.Functions> :m -Text.Show.Functions
Prelude> :r
Ok, modules loaded: none.
Prelude> (\x -> x)
<function>
```
Example 2 (make):
```
ezyang@sabre:~/Dev/labs/ezyangest$ cat A.hs
module A where
import Text.Show.Functions
ezyang@sabre:~/Dev/labs/ezyangest$ cat B.hs
module B where
y = show (\x -> x)
ezyang@sabre:~/Dev/labs/ezyangest$ ghc --make B.hs A.hs
[1 of 2] Compiling A ( A.hs, A.o )
[2 of 2] Compiling B ( B.hs, B.o )
ezyang@sabre:~/Dev/labs/ezyangest$ ghc --make A.hs B.hs -fforce-recomp
[1 of 2] Compiling B ( B.hs, B.o )
B.hs:2:5:
No instance for (Show (t0 -> t0)) arising from a use of `show'
Possible fix: add an instance declaration for (Show (t0 -> t0))
In the expression: show (\ x -> x)
In an equation for `y': y = show (\ x -> x)
```7.10.1Edward Z. YangEdward Z. Yanghttps://gitlab.haskell.org/ghc/ghc/-/issues/2202type error causes type checker stack overflow2019-07-07T19:09:44Zchiraltype error causes type checker stack overflowThe following code causes
```
*** Exception: stack overflow
```
during type checking. I've tried to whittle the
test case down, this may not be minimal.
The `(Ord a)` instances and
the unused `vertexID` member of the datatype
seem to b...The following code causes
```
*** Exception: stack overflow
```
during type checking. I've tried to whittle the
test case down, this may not be minimal.
The `(Ord a)` instances and
the unused `vertexID` member of the datatype
seem to be necessary, otherwise the infinite type
is correctly caught. Does not occur under 6.6.1
```
module GHCBug(
MeshVertex(..)
) where
data (Ord a) => MeshVertex a b = MeshVertex {
vertexID :: a,
vertexChildren :: [a]
} deriving (Show)
split :: (Ord a) =>
a ->
[MeshVertex a b] ->
[MeshVertex a b]
split a m = let
av = head m
newVTs = preSplit a m
av' = av { vertexChildren = newVTs }
newMVs = av' : m
newMesh = newMVs
in newMesh
preSplit :: (Ord a) =>
a ->
[MeshVertex a b] ->
[MeshVertex a b]
preSplit a m = preSplit a $ split a m
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | MacOS X |
| Architecture | x86 |
</details>
<!-- {"blocked_by":[],"summary":"type error causes type checker stack overflow","status":"New","operating_system":"MacOS X","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"x86","cc":[""],"type":"Bug","description":"The following code causes\r\n{{{\r\n*** Exception: stack overflow\r\n}}}\r\nduring type checking. I've tried to whittle the\r\ntest case down, this may not be minimal. \r\nThe {{{(Ord a)}}} instances and\r\nthe unused {{{vertexID}}} member of the datatype\r\nseem to be necessary, otherwise the infinite type\r\nis correctly caught. Does not occur under 6.6.1\r\n\r\n{{{\r\nmodule GHCBug(\r\n MeshVertex(..)\r\n ) where\r\n\r\ndata (Ord a) => MeshVertex a b = MeshVertex {\r\n vertexID :: a,\r\n vertexChildren :: [a]\r\n } deriving (Show)\r\n\r\nsplit :: (Ord a) =>\r\n a ->\r\n [MeshVertex a b] ->\r\n [MeshVertex a b]\r\nsplit a m = let\r\n av = head m\r\n newVTs = preSplit a m\r\n av' = av { vertexChildren = newVTs }\r\n newMVs = av' : m\r\n newMesh = newMVs\r\n in newMesh\r\n\r\npreSplit :: (Ord a) =>\r\n a ->\r\n [MeshVertex a b] ->\r\n [MeshVertex a b]\r\npreSplit a m = preSplit a $ split a m\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2203TFs in class instances heads2019-07-07T19:09:44ZManuel M T ChakravartyTFs in class instances headsGanesh posted the following example on haskell-cafe:
```
{-# LANGUAGE ScopedTypeVariables, TypeFamilies, FlexibleInstances #-}
module Test1a where
class Foo a where
type TheFoo a
foo :: TheFoo a -> a
foo' :: a -> Int
class B...Ganesh posted the following example on haskell-cafe:
```
{-# LANGUAGE ScopedTypeVariables, TypeFamilies, FlexibleInstances #-}
module Test1a where
class Foo a where
type TheFoo a
foo :: TheFoo a -> a
foo' :: a -> Int
class Bar b where
bar :: b -> Int
instance Foo a => Bar (Either a (TheFoo a)) where
bar (Left a) = foo' a
bar (Right b) = foo' (foo b :: a)
instance Foo Int where
type TheFoo Int = Int
foo = id
foo' = id
val :: Either Int Int
val = Left 5
res :: Int
res = bar val
```
It fails to type check as the type of `bar` cannot be inferred. However, GHC should reject the instance due to the TF in the head despite `FlexibleInstances`.
Moreover, the corrected code
```
{-# LANGUAGE ScopedTypeVariables, TypeFamilies, UndecidableInstances #-}
module Test1a where
class Foo a where
type TheFoo a
foo :: TheFoo a -> a
foo' :: a -> Int
class Bar b where
bar :: b -> Int
instance (b ~ TheFoo a, Foo a) => Bar (Either a b) where
bar (Left a) = foo' a
bar (Right b) = foo' (foo b :: a)
instance Foo Int where
type TheFoo Int = Int
foo = id
foo' = id
val :: Either Int Int
val = Left 5
res :: Int
res = bar val
```
requires `UndecidableInstances`, although it shouldn't.
We should be able to allow equalities of the form `tv ~ F tv1 .. tvn` with tv and tvi being distinct type variables without requiring `UndecidableInstances`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ganesh@earth.li |
| Operating system | Multiple |
| Architecture | Multiple |
</details>
<!-- {"blocked_by":[],"summary":"TFs in class instances heads","status":"New","operating_system":"Multiple","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"chak"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Multiple","cc":["ganesh@earth.li"],"type":"Bug","description":"Ganesh posted the following example on haskell-cafe:\r\n{{{\r\n{-# LANGUAGE ScopedTypeVariables, TypeFamilies, FlexibleInstances #-}\r\n\r\nmodule Test1a where\r\n\r\nclass Foo a where\r\n type TheFoo a\r\n foo :: TheFoo a -> a\r\n foo' :: a -> Int\r\n\r\nclass Bar b where\r\n bar :: b -> Int\r\n\r\ninstance Foo a => Bar (Either a (TheFoo a)) where\r\n bar (Left a) = foo' a\r\n bar (Right b) = foo' (foo b :: a)\r\n\r\ninstance Foo Int where\r\n type TheFoo Int = Int\r\n foo = id\r\n foo' = id\r\n\r\nval :: Either Int Int\r\nval = Left 5\r\n\r\nres :: Int\r\nres = bar val\r\n}}}\r\nIt fails to type check as the type of `bar` cannot be inferred. However, GHC should reject the instance due to the TF in the head despite `FlexibleInstances`.\r\n\r\nMoreover, the corrected code\r\n{{{\r\n{-# LANGUAGE ScopedTypeVariables, TypeFamilies, UndecidableInstances #-}\r\n\r\nmodule Test1a where\r\n\r\nclass Foo a where\r\n type TheFoo a\r\n foo :: TheFoo a -> a\r\n foo' :: a -> Int\r\n\r\nclass Bar b where\r\n bar :: b -> Int\r\n\r\ninstance (b ~ TheFoo a, Foo a) => Bar (Either a b) where\r\n bar (Left a) = foo' a\r\n bar (Right b) = foo' (foo b :: a)\r\n\r\ninstance Foo Int where\r\n type TheFoo Int = Int\r\n foo = id\r\n foo' = id\r\n\r\nval :: Either Int Int\r\nval = Left 5\r\n\r\nres :: Int\r\nres = bar val\r\n}}}\r\nrequires `UndecidableInstances`, although it shouldn't.\r\n\r\nWe should be able to allow equalities of the form `tv ~ F tv1 .. tvn` with tv and tvi being distinct type variables without requiring `UndecidableInstances`.","type_of_failure":"OtherFailure","blocking":[]} -->6.12 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2216Better error message for unboxed types with no -fglasgow-exts flag2019-07-07T19:09:40Zchevalier@alum.wellesley.eduBetter error message for unboxed types with no -fglasgow-exts flagIf I compile:
```
module Foo where
import GHC.Exts
foo = I# 42#
```
with `ghc -c`, I get:
```
Overloaded.hs:6:0: parse error (possibly incorrect indentation)
```
A better message would suggest using `-fglasgow-exts` (or something.)...If I compile:
```
module Foo where
import GHC.Exts
foo = I# 42#
```
with `ghc -c`, I get:
```
Overloaded.hs:6:0: parse error (possibly incorrect indentation)
```
A better message would suggest using `-fglasgow-exts` (or something.)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Bad error message for unboxed types with no -fglasgow-exts flag","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"If I compile:\r\n{{{\r\nmodule Foo where\r\n\r\nimport GHC.Exts\r\n\r\nfoo = I# 42#\r\n}}}\r\nwith {{{ghc -c}}}, I get: \r\n{{{\r\nOverloaded.hs:6:0: parse error (possibly incorrect indentation)\r\n}}}\r\n\r\nA better message would suggest using {{{-fglasgow-exts}}} (or something.)","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2219GADT match fails to refine type variable2019-07-07T19:09:40ZdolioGADT match fails to refine type variableThe following code is accepted by the type checker in 6.8.2, but is rejected by a HEAD build, 6.9.20080411:
```
{-# LANGUAGE TypeFamilies, GADTs, EmptyDataDecls, TypeOperators #-}
data Zero
data Succ a
data FZ
data FS fn
data Fin n f...The following code is accepted by the type checker in 6.8.2, but is rejected by a HEAD build, 6.9.20080411:
```
{-# LANGUAGE TypeFamilies, GADTs, EmptyDataDecls, TypeOperators #-}
data Zero
data Succ a
data FZ
data FS fn
data Fin n fn where
FZ :: Fin (Succ n) FZ
FS :: Fin n fn -> Fin (Succ n) (FS fn)
data Nil
data a ::: b
type family Lookup ts fn :: *
type instance Lookup (t ::: ts) FZ = t
type instance Lookup (t ::: ts) (FS fn) = Lookup ts fn
data Tuple n ts where
Nil :: Tuple Zero Nil
(:::) :: t -> Tuple n ts -> Tuple (Succ n) (t ::: ts)
proj :: Fin n fn -> Tuple n ts -> Lookup ts fn
proj FZ (v ::: _) = v
proj (FS fn) (_ ::: vs) = proj fn vs
```
The error in question is:
```
Bug.hs:25:16:
Occurs check: cannot construct the infinite type:
t = Lookup (t ::: ts) fn
In the pattern: v ::: _
In the definition of `proj': proj FZ (v ::: _) = v
```
Which seems to indicate that the pattern match against `FZ` in the first case is failing to refine the type variable `fn` to `FZ`. Reversing the order of the cases yields the same error, so either the match against FS is working correctly, or the type checker thinks that it can solve `Lookup (t ::: ts) fn ~ Lookup ts fn`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GADT match fails to refine type variable","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":["family","gadt","type"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code is accepted by the type checker in 6.8.2, but is rejected by a HEAD build, 6.9.20080411:\r\n\r\n{{{\r\n{-# LANGUAGE TypeFamilies, GADTs, EmptyDataDecls, TypeOperators #-}\r\n\r\ndata Zero\r\ndata Succ a\r\n\r\ndata FZ\r\ndata FS fn\r\n\r\ndata Fin n fn where\r\n FZ :: Fin (Succ n) FZ\r\n FS :: Fin n fn -> Fin (Succ n) (FS fn)\r\n\r\ndata Nil\r\ndata a ::: b\r\n\r\ntype family Lookup ts fn :: *\r\ntype instance Lookup (t ::: ts) FZ = t\r\ntype instance Lookup (t ::: ts) (FS fn) = Lookup ts fn\r\n\r\ndata Tuple n ts where\r\n Nil :: Tuple Zero Nil\r\n (:::) :: t -> Tuple n ts -> Tuple (Succ n) (t ::: ts)\r\n\r\nproj :: Fin n fn -> Tuple n ts -> Lookup ts fn\r\nproj FZ (v ::: _) = v\r\nproj (FS fn) (_ ::: vs) = proj fn vs\r\n}}}\r\n\r\nThe error in question is:\r\n\r\n{{{\r\nBug.hs:25:16:\r\n Occurs check: cannot construct the infinite type:\r\n t = Lookup (t ::: ts) fn\r\n In the pattern: v ::: _\r\n In the definition of `proj': proj FZ (v ::: _) = v\r\n}}}\r\n\r\nWhich seems to indicate that the pattern match against {{{FZ}}} in the first case is failing to refine the type variable {{{fn}}} to {{{FZ}}}. Reversing the order of the cases yields the same error, so either the match against FS is working correctly, or the type checker thinks that it can solve {{{Lookup (t ::: ts) fn ~ Lookup ts fn}}}.","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2231ASSERT failed! file typecheck/TcMType.lhs line 442 t_a7Fa{tv} [tau]2019-07-07T19:09:37ZguestASSERT failed! file typecheck/TcMType.lhs line 442 t_a7Fa{tv} [tau]As discussed this afternoon on \#ghc.
From the attached tarball, unpack, cd sessions2, ghci Control/Concurrent/Session/Queens.hs, main
What should happen is that it prints "False". However, for me it consistently segfaults. GDB reveals...As discussed this afternoon on \#ghc.
From the attached tarball, unpack, cd sessions2, ghci Control/Concurrent/Session/Queens.hs, main
What should happen is that it prints "False". However, for me it consistently segfaults. GDB reveals things like:
```
*Control.Concurrent.Session.Queens> main
Loading package mtl-1.1.0.0 ... linking ... done.
Loading package array-0.1.0.0 ... linking ... done.
Loading package containers-0.1.0.1 ... linking ... done.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x41001950 (LWP 26393)]
0x00002b76022eae6b in memcpy () from /lib/libc.so.6
(gdb) bt
#0 0x00002b76022eae6b in memcpy () from /lib/libc.so.6
#1 0x000000000167f7b9 in schedule (initialCapability=<value optimized out>, task=0x1b9d100) at Schedule.c:2847
#2 0x000000000167f94f in workerStart (task=0x1b9d100) at Schedule.c:2528
#3 0x00002b760205e017 in start_thread () from /lib/libpthread.so.0
#4 0x00002b76023385bd in clone () from /lib/libc.so.6
#5 0x0000000000000000 in ?? ()
```
For some people, the first time you run main, it doesn't segfault but also doesn't print anything. Then the second time you run main, it will segfault then.
Compiling with ghc does result in the right (non-segfaulting) behaviour, both with -threaded and without.
For me, this is with 6.8.2, but Igloo confirmed that it segfaults HEAD too.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Linux |
| Architecture | x86_64 (amd64) |
</details>
<!-- {"blocked_by":[],"summary":"GHC RTS Segfault","status":"New","operating_system":"Linux","component":"Runtime System","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"x86_64 (amd64)","cc":[""],"type":"Bug","description":"As discussed this afternoon on #ghc.\r\n\r\nFrom the attached tarball, unpack, cd sessions2, ghci Control/Concurrent/Session/Queens.hs, main\r\n\r\nWhat should happen is that it prints \"False\". However, for me it consistently segfaults. GDB reveals things like:\r\n\r\n{{{\r\n*Control.Concurrent.Session.Queens> main\r\nLoading package mtl-1.1.0.0 ... linking ... done.\r\nLoading package array-0.1.0.0 ... linking ... done.\r\nLoading package containers-0.1.0.1 ... linking ... done.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault.\r\n[Switching to Thread 0x41001950 (LWP 26393)]\r\n0x00002b76022eae6b in memcpy () from /lib/libc.so.6\r\n(gdb) bt\r\n#0 0x00002b76022eae6b in memcpy () from /lib/libc.so.6\r\n#1 0x000000000167f7b9 in schedule (initialCapability=<value optimized out>, task=0x1b9d100) at Schedule.c:2847\r\n#2 0x000000000167f94f in workerStart (task=0x1b9d100) at Schedule.c:2528\r\n#3 0x00002b760205e017 in start_thread () from /lib/libpthread.so.0\r\n#4 0x00002b76023385bd in clone () from /lib/libc.so.6\r\n#5 0x0000000000000000 in ?? ()\r\n}}}\r\n\r\nFor some people, the first time you run main, it doesn't segfault but also doesn't print anything. Then the second time you run main, it will segfault then.\r\n\r\nCompiling with ghc does result in the right (non-segfaulting) behaviour, both with -threaded and without.\r\n\r\nFor me, this is with 6.8.2, but Igloo confirmed that it segfaults HEAD too.","type_of_failure":"OtherFailure","blocking":[]} -->6.10 branchSimon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/2239lack of improvement/reduction with TFs2019-07-07T19:09:36Zclaus.reinke@talk21.comlack of improvement/reduction with TFs```
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
data A = A
data B = B
class C a where c :: a -> Stri...```
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
data A = A
data B = B
class C a where c :: a -> String
instance C Bool where c _ = "Bool"
instance C Char where c _ = "Char"
-- via TFs
type family TF a
type instance TF A = Char
type instance TF B = Bool
tf :: forall a b. (b ~ TF a,C b) => a -> String
tf a = c (undefined:: b)
-- via FDs
class FD a b | a -> b
instance FD A Char
instance FD B Bool
fd :: forall a b. (FD a b,C b) => a -> String
fd a = c (undefined:: b)
```
for some reason, the TF version doesn't work as well as the FD version:
```
*Main> fd A
"Char"
*Main> fd B
"Bool"
*Main> tf A
<interactive>:1:0:
No instance for (C (TF A))
arising from a use of `tf' at <interactive>:1:0-3
Possible fix: add an instance declaration for (C (TF A))
In the expression: tf A
In the definition of `it': it = tf A
*Main> :t undefined :: (b~TF A)=>b
undefined :: (b~TF A)=>b :: TF A
*Main> :t undefined :: (FD A b)=>b
undefined :: (FD A b)=>b :: Char
```
this is with `GHCi, version 6.9.20080217`.
the result of the TF is "known", even if not used:
```
*Main> :t undefined :: (b~TF A,b~Char)=>b
undefined :: (b~TF A,b~Char)=>b :: TF A
*Main> :t undefined :: (b~TF A,b~Bool)=>b
<interactive>:1:0:
Couldn't match expected type `Bool' against inferred type `Char'
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"lack of improvement/reduction with TFs","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":["FD","TF","vs"],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"{{{\r\n{-# LANGUAGE MultiParamTypeClasses #-}\r\n{-# LANGUAGE FunctionalDependencies #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE FlexibleContexts #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\ndata A = A\r\ndata B = B\r\n\r\nclass C a where c :: a -> String\r\ninstance C Bool where c _ = \"Bool\"\r\ninstance C Char where c _ = \"Char\"\r\n\r\n-- via TFs\r\ntype family TF a\r\ntype instance TF A = Char\r\ntype instance TF B = Bool\r\n\r\ntf :: forall a b. (b ~ TF a,C b) => a -> String\r\ntf a = c (undefined:: b) \r\n\r\n-- via FDs\r\nclass FD a b | a -> b\r\ninstance FD A Char\r\ninstance FD B Bool\r\n\r\nfd :: forall a b. (FD a b,C b) => a -> String\r\nfd a = c (undefined:: b) \r\n}}}\r\nfor some reason, the TF version doesn't work as well as the FD version:\r\n{{{\r\n*Main> fd A\r\n\"Char\"\r\n*Main> fd B\r\n\"Bool\"\r\n*Main> tf A\r\n\r\n<interactive>:1:0:\r\n No instance for (C (TF A))\r\n arising from a use of `tf' at <interactive>:1:0-3\r\n Possible fix: add an instance declaration for (C (TF A))\r\n In the expression: tf A\r\n In the definition of `it': it = tf A\r\n*Main> :t undefined :: (b~TF A)=>b\r\nundefined :: (b~TF A)=>b :: TF A\r\n*Main> :t undefined :: (FD A b)=>b\r\nundefined :: (FD A b)=>b :: Char\r\n}}}\r\nthis is with `GHCi, version 6.9.20080217`.\r\n\r\nthe result of the TF is \"known\", even if not used:\r\n{{{\r\n*Main> :t undefined :: (b~TF A,b~Char)=>b\r\nundefined :: (b~TF A,b~Char)=>b :: TF A\r\n*Main> :t undefined :: (b~TF A,b~Bool)=>b\r\n\r\n<interactive>:1:0:\r\n Couldn't match expected type `Bool' against inferred type `Char'\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/2247GHC accepts FD violations, unless the conflicing instances are used2019-07-07T19:09:33Zclaus.reinke@talk21.comGHC accepts FD violations, unless the conflicing instances are usedconsider
```
class FD a b | a -> b
instance CFD a b => FD a b
class {- FD a b => -} CFD a b
instance CFD Bool Char
instance CFD Bool Bool
f :: CFD Bool Bool => Bool
f = True
g :: CFD Bool Char => Bool
g = False
f' :: FD Bool Bool =>...consider
```
class FD a b | a -> b
instance CFD a b => FD a b
class {- FD a b => -} CFD a b
instance CFD Bool Char
instance CFD Bool Bool
f :: CFD Bool Bool => Bool
f = True
g :: CFD Bool Char => Bool
g = False
f' :: FD Bool Bool => Bool
f' = True
g' :: FD Bool Char => Bool
g' = False
```
the class instance for `FD` is odd, because there is no guarantee that instances of `CFD` comply to the FD (and Hugs rejects that instance, unless the superclass constraint for `CFD` is uncommented). as it stands, this code specifies two FD-conflicting instances of class `FD`, but they are implied, not explicit.
GHCi accepts this code, and only complains if the two conflicting instances are used, explicitly, in the same expression:
```
*Main> f
True
*Main> g
False
*Main> (f,g)
(True,False)
*Main> f'
True
*Main> g'
False
*Main> (f',g')
<interactive>:1:0:
Couldn't match expected type `Bool' against inferred type `Char'
When using functional dependencies to combine
FD Bool Char, arising from a use of `g'' at <interactive>:1:4-5
FD Bool Bool, arising from a use of `f'' at <interactive>:1:1-2
When generalising the type(s) for `it'
*Main> do {let {x=f} ;let {y=g} ; return (x,y) }
(True,False)
*Main> do {let {x=f'} ;let {y=g'} ; return (x,y) }
<interactive>:1:0:
Couldn't match expected type `Char' against inferred type `Bool'
When using functional dependencies to combine
FD Bool Bool, arising from a use of `f'' at <interactive>:1:11-12
FD Bool Char, arising from a use of `g'' at <interactive>:1:23-24
When generalising the type(s) for `it'
*Main> let x=f'
*Main> let y=g'
*Main> (x,y)
(True,False)
```
so we can have FD-conflicting instances in the same code, even use them in the same GHCi session, as long as they don't meet in the same line..
for further details and questions, see this message:
[some questions about type improvement, FDs vs TFs, and Hugs vs GHCi](http://www.haskell.org/pipermail/haskell-cafe/2008-April/042219.html)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"GHC accepts FD violations, unless the conflicing instances are used","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":["FD","TF","vs"],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"consider\r\n{{{\r\nclass FD a b | a -> b\r\ninstance CFD a b => FD a b\r\n\r\nclass {- FD a b => -} CFD a b\r\ninstance CFD Bool Char\r\ninstance CFD Bool Bool\r\n\r\nf :: CFD Bool Bool => Bool\r\nf = True\r\n\r\ng :: CFD Bool Char => Bool\r\ng = False\r\n\r\nf' :: FD Bool Bool => Bool\r\nf' = True\r\n\r\ng' :: FD Bool Char => Bool\r\ng' = False\r\n}}}\r\nthe class instance for `FD` is odd, because there is no guarantee that instances of `CFD` comply to the FD (and Hugs rejects that instance, unless the superclass constraint for `CFD` is uncommented). as it stands, this code specifies two FD-conflicting instances of class `FD`, but they are implied, not explicit.\r\n\r\nGHCi accepts this code, and only complains if the two conflicting instances are used, explicitly, in the same expression:\r\n{{{\r\n*Main> f\r\nTrue\r\n*Main> g\r\nFalse\r\n*Main> (f,g)\r\n(True,False)\r\n*Main> f'\r\nTrue\r\n*Main> g'\r\nFalse\r\n*Main> (f',g')\r\n\r\n<interactive>:1:0:\r\n Couldn't match expected type `Bool' against inferred type `Char'\r\n When using functional dependencies to combine\r\n FD Bool Char, arising from a use of `g'' at <interactive>:1:4-5\r\n FD Bool Bool, arising from a use of `f'' at <interactive>:1:1-2\r\n When generalising the type(s) for `it'\r\n*Main> do {let {x=f} ;let {y=g} ; return (x,y) }\r\n(True,False)\r\n*Main> do {let {x=f'} ;let {y=g'} ; return (x,y) }\r\n\r\n<interactive>:1:0:\r\n Couldn't match expected type `Char' against inferred type `Bool'\r\n When using functional dependencies to combine\r\n FD Bool Bool, arising from a use of `f'' at <interactive>:1:11-12\r\n FD Bool Char, arising from a use of `g'' at <interactive>:1:23-24\r\n When generalising the type(s) for `it'\r\n*Main> let x=f'\r\n*Main> let y=g'\r\n*Main> (x,y)\r\n(True,False)\r\n}}}\r\nso we can have FD-conflicting instances in the same code, even use them in the same GHCi session, as long as they don't meet in the same line..\r\n\r\nfor further details and questions, see this message:\r\n[http://www.haskell.org/pipermail/haskell-cafe/2008-April/042219.html some questions about type improvement, FDs vs TFs, and Hugs vs GHCi]","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2275Poor indication of type error location2019-07-07T19:09:23ZguestPoor indication of type error locationUsing {-\# OPTIONS_GHC -XArrows -fno-monomorphism-restriction \#-}, and Yampa
Starting from line 32, my program contains:
```
fireworkSF :: Point2 GL.GLdouble -> Point2 GL.GLdouble -> Object
fireworkSF p0 pFinal = proc _ -> do
rec
...Using {-\# OPTIONS_GHC -XArrows -fno-monomorphism-restriction \#-}, and Yampa
Starting from line 32, my program contains:
```
fireworkSF :: Point2 GL.GLdouble -> Point2 GL.GLdouble -> Object
fireworkSF p0 pFinal = proc _ -> do
rec
position <- (p0 .+^) ^<< integral -< v0
let shouldExplode = position == pFinal
let killReq = if shouldExplode then Event () else noEvent
let spawnReq = if shouldExplode
then Event (Explode pFinal)
else noEvent
returnA -< ObjectOutput {oState = FireworkState position
,oKillReq = killReq
,oSpawnReq = spawnReq}
where
v0 = (pFinal ^-^ p0) ^/ 2
```
The type error reports:
```
Firework.hs:32:0:
Couldn't match expected type `Point2 GL.GLdouble'
against inferred type `Vector2 GL.GLdouble'
When using functional dependencies to combine
AffineSpace (Point2 a) (Vector2 a) a,
arising from the instance declaration at <no location info>
AffineSpace (Point2 GL.GLdouble) (Point2 GL.GLdouble) a,
arising from a use of `.+^' at Firework.hs:34:16-23
When generalising the type(s) for `fireworkSF'
```
Indicating that the bug is something to do with line 34. The actual bug is that the last line of the paste should read:
```
v0 = (pFinal .-. p0) ^/ 2
```6.10 branchhttps://gitlab.haskell.org/ghc/ghc/-/issues/2357Implement the Haskell' proposal for polymorphic pattern bindings2019-07-07T19:08:58ZSimon MarlowImplement the Haskell' proposal for polymorphic pattern bindingsAfter discussion on the Haskell' mailing list, it was decided that Haskell' will keep polymorphic pattern bindings, with static semantics defined by a translation.
[http://hackage.haskell.org/trac/haskell-prime/wiki/SpecifyPatternBindin...After discussion on the Haskell' mailing list, it was decided that Haskell' will keep polymorphic pattern bindings, with static semantics defined by a translation.
[http://hackage.haskell.org/trac/haskell-prime/wiki/SpecifyPatternBindingSemantics](http://hackage.haskell.org/trac/haskell-prime/wiki/SpecifyPatternBindingSemantics)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Implement the Haskell' proposal for polymorphic pattern bindings","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"6.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Task","description":"After discussion on the Haskell' mailing list, it was decided that Haskell' will keep polymorphic pattern bindings, with static semantics defined by a translation.\r\n\r\n[http://hackage.haskell.org/trac/haskell-prime/wiki/SpecifyPatternBindingSemantics]\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/2414GHCi / GHC segfault : type checker problem2019-07-07T19:08:41ZdonsGHCi / GHC segfault : type checker problem```
Prelude> Data.List.unfoldr Just (1,1)
[1,zsh: segmentation fault ghci -v0
```
Spotted in \#haskell, ghc-6.8.2
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------...```
Prelude> Data.List.unfoldr Just (1,1)
[1,zsh: segmentation fault ghci -v0
```
Spotted in \#haskell, ghc-6.8.2
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"GHCi segfault","status":"New","operating_system":"Unknown","component":"GHCi","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"{{{\r\nPrelude> Data.List.unfoldr Just (1,1)\r\n[1,zsh: segmentation fault ghci -v0\r\n\r\n}}}\r\n\r\nSpotted in #haskell, ghc-6.8.2","type_of_failure":"OtherFailure","blocking":[]} -->6.8 branchhttps://gitlab.haskell.org/ghc/ghc/-/issues/2418desugaring type function application to constraint makes bug disappear2019-07-07T19:08:40Zclaus.reinke@talk21.comdesugaring type function application to constraint makes bug disappearWhen considering type functions, I find it helpful to desugar their applications into additional constraints (`tf a` becomes `tf a~tfa=>tfa`). But consider this example from a recent [haskell-cafe thread](http://www.haskell.org/pipermail...When considering type functions, I find it helpful to desugar their applications into additional constraints (`tf a` becomes `tf a~tfa=>tfa`). But consider this example from a recent [haskell-cafe thread](http://www.haskell.org/pipermail/haskell-cafe/2008-July/044911.html):
```
{-# OPTIONS_GHC -fglasgow-exts #-}
class Blah f a where blah :: a -> T f f a
class A f where type T f :: (* -> *) -> * -> *
-- wrapper :: forall a f tf . (Blah f a,T f~tf) => a -> tf f a
wrapper :: forall a f . (Blah f a) => a -> T f f a
wrapper x = blah x
```
for which `GHCi, version 6.9.20080514` yields:
```
C:\Documents and Settings\cr3\Desktop\TF.hs:8:12:
Could not deduce (Blah f a) from the context (Blah f1 a)
arising from a use of `blah'
at C:\Documents and Settings\cr3\Desktop\TF.hs:8:12-17
Possible fix:
add (Blah f a) to the context of the type signature for `wrapper'
In the expression: blah x
In the definition of `wrapper': wrapper x = blah x
C:\Documents and Settings\cr3\Desktop\TF.hs:8:12:
Couldn't match expected type `T f1 f1 a'
against inferred type `T f f a'
In the expression: blah x
In the definition of `wrapper': wrapper x = blah x
Failed, modules loaded: none.
```
Switching to the desugared version of the `wrapper` signature makes the error go away, so the "desugared" and original version are not equivalent in the current implementation of type families! See also [http://www.haskell.org/pipermail/haskell-cafe/2008-July/044914.html](http://www.haskell.org/pipermail/haskell-cafe/2008-July/044914.html).
For added fun, GHCi reports the sugared type when using the desugared one:
```
*Main> :t wrapper
wrapper :: (Blah f a) => a -> T f f a
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"desugaring type function application to constraint makes bug disappear","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":["families","type"],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"When considering type functions, I find it helpful to desugar their applications into additional constraints (`tf a` becomes `tf a~tfa=>tfa`). But consider this example from a recent [http://www.haskell.org/pipermail/haskell-cafe/2008-July/044911.html haskell-cafe thread]:\r\n{{{\r\n{-# OPTIONS_GHC -fglasgow-exts #-}\r\n\r\nclass Blah f a where blah :: a -> T f f a\r\nclass A f where type T f :: (* -> *) -> * -> *\r\n\r\n-- wrapper :: forall a f tf . (Blah f a,T f~tf) => a -> tf f a\r\nwrapper :: forall a f . (Blah f a) => a -> T f f a\r\nwrapper x = blah x\r\n}}}\r\nfor which `GHCi, version 6.9.20080514` yields:\r\n{{{\r\nC:\\Documents and Settings\\cr3\\Desktop\\TF.hs:8:12:\r\n Could not deduce (Blah f a) from the context (Blah f1 a)\r\n arising from a use of `blah'\r\n at C:\\Documents and Settings\\cr3\\Desktop\\TF.hs:8:12-17\r\n Possible fix:\r\n add (Blah f a) to the context of the type signature for `wrapper'\r\n In the expression: blah x\r\n In the definition of `wrapper': wrapper x = blah x\r\n\r\nC:\\Documents and Settings\\cr3\\Desktop\\TF.hs:8:12:\r\n Couldn't match expected type `T f1 f1 a'\r\n against inferred type `T f f a'\r\n In the expression: blah x\r\n In the definition of `wrapper': wrapper x = blah x\r\nFailed, modules loaded: none.\r\n}}}\r\nSwitching to the desugared version of the `wrapper` signature makes the error go away, so the \"desugared\" and original version are not equivalent in the current implementation of type families! See also [http://www.haskell.org/pipermail/haskell-cafe/2008-July/044914.html].\r\n\r\nFor added fun, GHCi reports the sugared type when using the desugared one:\r\n{{{\r\n*Main> :t wrapper\r\nwrapper :: (Blah f a) => a -> T f f a\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/2432type family panic: Coercion.splitCoercionKindOf2019-07-07T19:08:36Zclaus.reinke@talk21.comtype family panic: Coercion.splitCoercionKindOfas seen in #2146\##2432, confirmed with `GHCi, version 6.9.20080709`
```
{-# LANGUAGE TypeFamilies #-}
type family F a :: * -> *
foo3 :: (F Int ~ fi, F Bool ~ fb, fi a ~ fb a) => a
foo3 = undefined
```
```
ghc.exe: panic! (the 'imposs...as seen in #2146\##2432, confirmed with `GHCi, version 6.9.20080709`
```
{-# LANGUAGE TypeFamilies #-}
type family F a :: * -> *
foo3 :: (F Int ~ fi, F Bool ~ fb, fi a ~ fb a) => a
foo3 = undefined
```
```
ghc.exe: panic! (the 'impossible' happened)
(GHC version 6.9.20080709 for i386-unknown-mingw32):
Coercion.splitCoercionKindOf
ghc-prim:GHC.Prim.left{(w) tc 34B} $co${tc a7j} [tv]
<pred>fi{tv a6W} [sk] ~ fb{tv a6X} [sk]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"type family panic: Coercion.splitCoercionKindOf","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"as seen in #2146#comment:5, confirmed with `GHCi, version 6.9.20080709`\r\n{{{\r\n{-# LANGUAGE TypeFamilies #-}\r\ntype family F a :: * -> *\r\n\r\nfoo3 :: (F Int ~ fi, F Bool ~ fb, fi a ~ fb a) => a\r\nfoo3 = undefined\r\n}}}\r\n\r\n{{{\r\nghc.exe: panic! (the 'impossible' happened)\r\n (GHC version 6.9.20080709 for i386-unknown-mingw32):\r\n Coercion.splitCoercionKindOf\r\n ghc-prim:GHC.Prim.left{(w) tc 34B} $co${tc a7j} [tv]\r\n <pred>fi{tv a6W} [sk] ~ fb{tv a6X} [sk]\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2448Type equality constraint not propagated to superclass2019-07-07T19:08:31ZconalType equality constraint not propagated to superclassThe code:
```
{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
-- Demonstrates a bug in propagating type equality constraints
class VectorSpace v where
type Scalar v :: *
class VectorSpace v => InnerSpace v
instance...The code:
```
{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
-- Demonstrates a bug in propagating type equality constraints
class VectorSpace v where
type Scalar v :: *
class VectorSpace v => InnerSpace v
instance (VectorSpace u,VectorSpace v, Scalar u ~ Scalar v) => VectorSpace (u,v) where
type Scalar (u,v) = Scalar u
instance (InnerSpace u,InnerSpace v, Scalar u ~ Scalar v) => InnerSpace (u,v)
```
In ghc 6.9.20080622, the last line yields
```
Data\TypeEqBug.hs:20:0:
Couldn't match expected type `Scalar v'
against inferred type `Scalar u'
When checking the super-classes of an instance declaration
In the instance declaration for `InnerSpace (u, v)'
```
I'd expect the type equality constraint in the `InnerSpace` instance to get propagated to the parent class.
By the way, without the `UndecidableInstances` above, we get:
```
Constraint is no smaller than the instance head
in the constraint: Scalar u ~ Scalar v
(Use -XUndecidableInstances to permit this)
In the instance declaration for `VectorSpace (u, v)'
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | --------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | conal@conal.net |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Type equality constraint not propagated to superclass","status":"New","operating_system":"Unknown","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":["constraints","equality","families,","type"],"differentials":[],"test_case":"","architecture":"Unknown","cc":["conal@conal.net"],"type":"Bug","description":"The code:\r\n\r\n\r\n{{{\r\n {-# LANGUAGE TypeFamilies, UndecidableInstances #-}\r\n\r\n -- Demonstrates a bug in propagating type equality constraints\r\n\r\n class VectorSpace v where\r\n type Scalar v :: *\r\n\r\n class VectorSpace v => InnerSpace v\r\n\r\n instance (VectorSpace u,VectorSpace v, Scalar u ~ Scalar v) => VectorSpace (u,v) where\r\n type Scalar (u,v) = Scalar u\r\n\r\n instance (InnerSpace u,InnerSpace v, Scalar u ~ Scalar v) => InnerSpace (u,v)\r\n}}}\r\n\r\nIn ghc 6.9.20080622, the last line yields\r\n\r\n{{{\r\n Data\\TypeEqBug.hs:20:0:\r\n Couldn't match expected type `Scalar v'\r\n against inferred type `Scalar u'\r\n When checking the super-classes of an instance declaration\r\n In the instance declaration for `InnerSpace (u, v)'\r\n}}}\r\n\r\nI'd expect the type equality constraint in the {{{InnerSpace}}} instance to get propagated to the parent class.\r\n\r\nBy the way, without the {{{UndecidableInstances}}} above, we get:\r\n\r\n{{{\r\n Constraint is no smaller than the instance head\r\n in the constraint: Scalar u ~ Scalar v\r\n (Use -XUndecidableInstances to permit this)\r\n In the instance declaration for `VectorSpace (u, v)'\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2452Add a flag to disable the implicit qualified import of every available module...2019-07-07T19:08:30ZDaniel GorĆnAdd a flag to disable the implicit qualified import of every available module in interactive modeIn interactive mode every available module is implicitly imported qualified. While this is very convenient when working with GHCi, it can be a little annoying in other contexts.
For instance, in a lambdabot-like application, one would l...In interactive mode every available module is implicitly imported qualified. While this is very convenient when working with GHCi, it can be a little annoying in other contexts.
For instance, in a lambdabot-like application, one would like to rely on the type of a given expression to decide if it is side-effect free and, thus, safe to execute. However, because every module in the `base` package is imported qualified one has to do a manual check to filter out cases like:
```
ghc -e 'System.IO.Unsafe.unsafePerformIO (evilStuff >> return "i'm an innocent string")'
```
Another example would be a GHC-API based refactoring tool that wants to check if a refactored expression typechecks before modifying the code. If every module is imported qualified, the tool might get many false positives.
The proposal is to keep the current behaviour as the default but to add a `-fno-implicit-import-qualified` flag to disable it when needed. The following should fail to execute:
```
ghc -fno-implicit-import-qualified -e 'System.IO.Unsafe.unsafePerformIO (evilStuff >> return "i'm an innocent string")'
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Add a flag to disable the implicit qualified import of every available module in interactive mode","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"FeatureRequest","description":"In interactive mode every available module is implicitly imported qualified. While this is very convenient when working with GHCi, it can be a little annoying in other contexts.\r\n\r\nFor instance, in a lambdabot-like application, one would like to rely on the type of a given expression to decide if it is side-effect free and, thus, safe to execute. However, because every module in the `base` package is imported qualified one has to do a manual check to filter out cases like:\r\n\r\n{{{\r\nghc -e 'System.IO.Unsafe.unsafePerformIO (evilStuff >> return \"i'm an innocent string\")'\r\n}}}\r\n\r\nAnother example would be a GHC-API based refactoring tool that wants to check if a refactored expression typechecks before modifying the code. If every module is imported qualified, the tool might get many false positives.\r\n\r\nThe proposal is to keep the current behaviour as the default but to add a `-fno-implicit-import-qualified` flag to disable it when needed. The following should fail to execute:\r\n\r\n{{{\r\nghc -fno-implicit-import-qualified -e 'System.IO.Unsafe.unsafePerformIO (evilStuff >> return \"i'm an innocent string\")'\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1Simon MarlowSimon Marlowhttps://gitlab.haskell.org/ghc/ghc/-/issues/2478Assertion failure in type checker2019-07-07T19:08:23ZSimon Peyton JonesAssertion failure in type checkerDoaitse reports:
It appears we ran into a bug which has been reported before. We ran
into it in a desperate attempt to follow some suggestions made by
referees to simplify our library for transformations of typed abstract
syntax . Unfort...Doaitse reports:
It appears we ran into a bug which has been reported before. We ran
into it in a desperate attempt to follow some suggestions made by
referees to simplify our library for transformations of typed abstract
syntax . Unfortunately the paper was rejected, but we decided to try
once more. The program fragment is probably erroneous, and we know how
to repair it by taking away a context constraint and putting in some
kind annotations, but we thought it would be good to report it anyway.
```
loeki:Desktop doaitse$ ghci Bug.hs
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( Bug.hs, interpreted )
Var/Type length mismatch:
[]
[env2{tv aul} [tau]]
Ok, modules loaded: Main.
```
Code is
```
data Ref a env where
Zero :: Ref a (a,env')
Suc :: Ref a env' -> Ref a (x,env')
newtype T e s
= T {unT :: forall x . Ref x e -> Ref x s}
class Extendable state t where
extend :: t a s -> state t s env -> state t s (a,env)
data Extendable st t => Trafo st t a b =
Trafo ( forall env1 s. a s -> st t s env1 -> TrafoE st t a b env1 s )
data Extendable st t => TrafoE st t a b env1 s =
forall env2 . TrafoE
(T env2 s -> (b s, T env1 s , st t s env2))
newSRef :: (Extendable env t) => Trafo env t (t a) (Ref a)
newSRef
= Trafo
(\ta env ->
TrafoE
(\(T tr) ->
( tr Zero
, T (tr . Suc)
, extend ta env
)
)
)
```6.8 branchhttps://gitlab.haskell.org/ghc/ghc/-/issues/2516Panic in typechecker when checking rules2019-07-07T19:08:14ZjosefPanic in typechecker when checking rulesGHC will panic when given either of the following modules. The error messages are somewhat different for the two different rules.
```
module GHCBug1 where
foo :: (forall a . a -> f a) -> f Int
foo f = f undefined
{-# RULES
"bug1"
...GHC will panic when given either of the following modules. The error messages are somewhat different for the two different rules.
```
module GHCBug1 where
foo :: (forall a . a -> f a) -> f Int
foo f = f undefined
{-# RULES
"bug1"
forall (g :: a -> f a) .
head (foo g) = undefined
#-}
```
```
module GHCBug2 where
foo :: (forall a . a -> f a) -> f Int
foo f = f undefined
{-# RULES
"bug2"
forall (g :: forall a . a -> f a) .
head (foo g) = undefined
#-}
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Panic in typechecker when checking rules","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC will panic when given either of the following modules. The error messages are somewhat different for the two different rules.\r\n\r\n{{{\r\nmodule GHCBug1 where\r\n\r\nfoo :: (forall a . a -> f a) -> f Int\r\nfoo f = f undefined\r\n\r\n{-# RULES\r\n \"bug1\"\r\n forall (g :: a -> f a) .\r\n head (foo g) = undefined\r\n #-}\r\n}}}\r\n{{{\r\nmodule GHCBug2 where\r\n\r\nfoo :: (forall a . a -> f a) -> f Int\r\nfoo f = f undefined\r\n\r\n{-# RULES\r\n \"bug2\"\r\n forall (g :: forall a . a -> f a) .\r\n head (foo g) = undefined\r\n #-}\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2534Odd probable cause given by type checker2019-07-07T19:08:10Zred5_2@hotmail.comOdd probable cause given by type checkerIn the following code, a function has been applied to zero arguments, which the type checker suggests is too many.
```
Prelude> foldr (>>=) [] []
<interactive>:1:6:
Occurs check: cannot construct the infinite type: b = a -> b
P...In the following code, a function has been applied to zero arguments, which the type checker suggests is too many.
```
Prelude> foldr (>>=) [] []
<interactive>:1:6:
Occurs check: cannot construct the infinite type: b = a -> b
Probable cause: `>>=' is applied to too many arguments
In the first argument of `foldr', namely `(>>=)'
In the expression: foldr (>>=) [] []
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Odd probable cause given by type checker","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"In the following code, a function has been applied to zero arguments, which the type checker suggests is too many.\r\n\r\n{{{\r\nPrelude> foldr (>>=) [] []\r\n\r\n<interactive>:1:6:\r\n Occurs check: cannot construct the infinite type: b = a -> b\r\n Probable cause: `>>=' is applied to too many arguments\r\n In the first argument of `foldr', namely `(>>=)'\r\n In the expression: foldr (>>=) [] []\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->7.6.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/2536Flag for Making Type Signatures Mandatory2019-07-07T19:08:09ZguestFlag for Making Type Signatures MandatoryI propose to add a flag to GHC to only compile programs that have type signatures for the defining equations. The purpose of this is to satisfy the belt and braces notion of programming and to also aid in teaching Haskell as a programmin...I propose to add a flag to GHC to only compile programs that have type signatures for the defining equations. The purpose of this is to satisfy the belt and braces notion of programming and to also aid in teaching Haskell as a programming language.
Calling GHC with the following
ghc -ftypesignatures a.hs
will reject a.hs if any of its definitions do not have type signatures.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.3 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Flag for Making Type Signatures Mandatory","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.3","keywords":["signatures","type"],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"FeatureRequest","description":"I propose to add a flag to GHC to only compile programs that have type signatures for the defining equations. The purpose of this is to satisfy the belt and braces notion of programming and to also aid in teaching Haskell as a programming language. \r\n\r\nCalling GHC with the following\r\n\r\nghc -ftypesignatures a.hs\r\n\r\nwill reject a.hs if any of its definitions do not have type signatures.\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2538Better error message for missing Rank2Types (or RankNTypes) flag2019-07-07T19:08:09Zchevalier@alum.wellesley.eduBetter error message for missing Rank2Types (or RankNTypes) flagFor a rank-2 type signature when the `Rank2Types` language option isn't enabled, GHC gives:
```
Illegal polymorphic or qualified type: (Data a) => a -> RnM a
In the type signature for `rnVarsIn':
rnVarsIn :: ((Data a) => a...For a rank-2 type signature when the `Rank2Types` language option isn't enabled, GHC gives:
```
Illegal polymorphic or qualified type: (Data a) => a -> RnM a
In the type signature for `rnVarsIn':
rnVarsIn :: ((Data a) => a -> RnM a)
-> [Vdef] -> Exp -> S.Set Var -> RnM ([Vdef], Exp)
```
It would be good to suggest using `-XRank2Types` or `-XRankNTypes`. (Sorry if this is already fixed; I don't have a working HEAD to test it with.)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.2 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Better error message for missing Rank2Types (or RankNTypes) flag","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"FeatureRequest","description":"For a rank-2 type signature when the {{{Rank2Types}}} language option isn't enabled, GHC gives:\r\n{{{\r\n Illegal polymorphic or qualified type: (Data a) => a -> RnM a\r\n In the type signature for `rnVarsIn':\r\n rnVarsIn :: ((Data a) => a -> RnM a)\r\n -> [Vdef] -> Exp -> S.Set Var -> RnM ([Vdef], Exp)\r\n}}}\r\n\r\nIt would be good to suggest using {{{-XRank2Types}}} or {{{-XRankNTypes}}}. (Sorry if this is already fixed; I don't have a working HEAD to test it with.)","type_of_failure":"OtherFailure","blocking":[]} -->Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/2544Improve "Can't unify" error messages from type functions2019-07-07T19:08:07ZSimon Peyton JonesImprove "Can't unify" error messages from type functionsConsider this example from a Haskell Cafe thread:
```
data (:|:) a b = Inl a | Inr b
class Ix i where
type IxMap i :: * -> *
empty :: IxMap i [Int]
data BiApp a b c = BiApp (a c) (b c)
instance (Ix l, Ix r) => Ix (l :|: r) whe...Consider this example from a Haskell Cafe thread:
```
data (:|:) a b = Inl a | Inr b
class Ix i where
type IxMap i :: * -> *
empty :: IxMap i [Int]
data BiApp a b c = BiApp (a c) (b c)
instance (Ix l, Ix r) => Ix (l :|: r) where
type IxMap (l :|: r) = BiApp (IxMap l) (IxMap r)
empty = BiApp empty empty
```
This elicits the following confusing error message:
```
Couldn't match expected type `IxMap l'
against inferred type `IxMap i'
Expected type: IxMap (l :|: r) [Int]
Inferred type: BiApp (IxMap i) (IxMap i1) [Int]
In the expression: BiApp empty empty
In the definition of `empty': empty = BiApp empty empty
```
As Alexander Dunlap responds, the error message is correct, but I can't help feeling that we should try harder to give a better error message. Something like "Since `IxMap` is a type function, knowing that `IxMap l` = `IxMap i` does not require that `l` = `i`". Or something.
This ticket is just to make sure we don't forget. The thread is here http://www.haskell.org/pipermail/haskell-cafe/2008-August/046371.html
Simon
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Improve \"Can't unify\" error messages from type functions","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"6.12 branch","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.3","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"Consider this example from a Haskell Cafe thread:\r\n{{{\r\ndata (:|:) a b = Inl a | Inr b\r\n\r\nclass Ix i where\r\n type IxMap i :: * -> *\r\n empty :: IxMap i [Int]\r\n\r\ndata BiApp a b c = BiApp (a c) (b c)\r\n\r\ninstance (Ix l, Ix r) => Ix (l :|: r) where\r\n type IxMap (l :|: r) = BiApp (IxMap l) (IxMap r)\r\n empty = BiApp empty empty\r\n}}}\r\nThis elicits the following confusing error message:\r\n{{{\r\n Couldn't match expected type `IxMap l'\r\n against inferred type `IxMap i'\r\n Expected type: IxMap (l :|: r) [Int]\r\n Inferred type: BiApp (IxMap i) (IxMap i1) [Int]\r\n In the expression: BiApp empty empty\r\n In the definition of `empty': empty = BiApp empty empty\r\n}}}\r\nAs Alexander Dunlap responds, the error message is correct, but I can't help feeling that we should try harder to give a better error message. Something like \"Since `IxMap` is a type function, knowing that `IxMap l` = `IxMap i` does not require that `l` = `i`\". Or something. \r\n\r\nThis ticket is just to make sure we don't forget. The thread is here http://www.haskell.org/pipermail/haskell-cafe/2008-August/046371.html\r\n\r\nSimon\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.0.2https://gitlab.haskell.org/ghc/ghc/-/issues/2569Inferred type not accepted by compiler2019-07-07T19:07:53ZajdInferred type not accepted by compiler` ghc --version: The Glorious Glasgow Haskell Compilation System, version 6.9.20080825 `
A.hs:
```
{-# LANGUAGE TypeFamilies #-}
module A
where
data H a = A a | B a deriving Eq
class PL p
class PE a where
type P a :: *
instanc...` ghc --version: The Glorious Glasgow Haskell Compilation System, version 6.9.20080825 `
A.hs:
```
{-# LANGUAGE TypeFamilies #-}
module A
where
data H a = A a | B a deriving Eq
class PL p
class PE a where
type P a :: *
instance PE [a] where
type P [a] = H a
instance PL (H a)
foo :: PE a => [P a] -> [P a] -> (([P a], [P a]),([P a],[P a]))
foo pa pb = ((pa, pa), (pb, pb))
-- bar :: (PE a) => [P a] -> [P a] -> Either ([P a], [P a]) [P a]
bar pa pb
= let _ = foo pa pb
in case True of
True -> Right pa
False -> Left (pa, pb)
```
Load the above module into GHCi.
```
*A> :t bar
bar :: (PE a) => [P a] -> [P a] -> Either ([P a], [P a]) [P a]
```
However, if we uncomment bar's type signature (which is *exactly* the same as the one printed by GHCi), we get a type error:
```
[1 of 1] Compiling A ( A.hs, interpreted )
A.hs:23:16:
Couldn't match expected type `P a' against inferred type `P a1'
Expected type: [P a]
Inferred type: [P a1]
In the first argument of `foo', namely `pa'
In the expression: foo pa pb
Failed, modules loaded: none.
```
I'm not all that familiar with type families, but I'm pretty sure that when GHCi prints a type, we ought to be able to specify that type and the module ought to compile...
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Inferred type not accepted by compiler","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"{{{ ghc --version: The Glorious Glasgow Haskell Compilation System, version 6.9.20080825 }}}\r\n\r\nA.hs:\r\n{{{\r\n{-# LANGUAGE TypeFamilies #-}\r\n\r\nmodule A\r\n where\r\n\r\ndata H a = A a | B a deriving Eq\r\n\r\nclass PL p\r\n\r\nclass PE a where\r\n type P a :: *\r\n\r\ninstance PE [a] where\r\n type P [a] = H a\r\n\r\ninstance PL (H a)\r\n\r\nfoo :: PE a => [P a] -> [P a] -> (([P a], [P a]),([P a],[P a]))\r\nfoo pa pb = ((pa, pa), (pb, pb))\r\n\r\n-- bar :: (PE a) => [P a] -> [P a] -> Either ([P a], [P a]) [P a]\r\nbar pa pb\r\n = let _ = foo pa pb\r\n in case True of\r\n True -> Right pa\r\n False -> Left (pa, pb)\r\n}}}\r\n\r\nLoad the above module into GHCi.\r\n\r\n{{{\r\n*A> :t bar\r\nbar :: (PE a) => [P a] -> [P a] -> Either ([P a], [P a]) [P a]\r\n}}}\r\n\r\nHowever, if we uncomment bar's type signature (which is ''exactly'' the same as the one printed by GHCi), we get a type error:\r\n\r\n{{{\r\n[1 of 1] Compiling A ( A.hs, interpreted )\r\n\r\nA.hs:23:16:\r\n Couldn't match expected type `P a' against inferred type `P a1'\r\n Expected type: [P a]\r\n Inferred type: [P a1]\r\n In the first argument of `foo', namely `pa'\r\n In the expression: foo pa pb\r\nFailed, modules loaded: none.\r\n}}}\r\n\r\nI'm not all that familiar with type families, but I'm pretty sure that when GHCi prints a type, we ought to be able to specify that type and the module ought to compile...","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2572scoped type variables: bad error message, and wrong semantics?2019-07-07T19:07:52ZIan Lynagh <igloo@earth.li>scoped type variables: bad error message, and wrong semantics?With this module (a cut-down version of reify):
```
{-# OPTIONS -fglasgow-exts #-}
module Foo where
type GTypeFun = forall a . a -> ()
gmapType :: Int -> GTypeFun
gmapType _ (_ :: a) = undefined
```
GHC gives the rather perplexing e...With this module (a cut-down version of reify):
```
{-# OPTIONS -fglasgow-exts #-}
module Foo where
type GTypeFun = forall a . a -> ()
gmapType :: Int -> GTypeFun
gmapType _ (_ :: a) = undefined
```
GHC gives the rather perplexing error:
```
Foo.hs:8:12:
The scoped type variables `a' and `a'
are bound to the same type (variable)
Distinct scoped type variables must be distinct
In the pattern: _ :: a
In the definition of `gmapType': gmapType _ (_ :: a) = undefined
```
Having locations for the two `a`s would be useful.
This module gives the same error:
```
{-# OPTIONS -fglasgow-exts #-}
module Foo where
gmapType :: Int -> (forall a . a -> ())
gmapType _ (_ :: a) = undefined
```
GHC 6.8.2 accepts both modules.
I don't think that the forall in the type signature should bring `a` into scope for the body, as it doesn't bring it into scope for the type signature.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | reify |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"scoped type variables: bad error message, and wrong semantics?","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"6.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"reify","architecture":"Unknown","cc":[""],"type":"Bug","description":"With this module (a cut-down version of reify):\r\n{{{\r\n{-# OPTIONS -fglasgow-exts #-}\r\n\r\nmodule Foo where\r\n\r\ntype GTypeFun = forall a . a -> ()\r\n\r\ngmapType :: Int -> GTypeFun\r\ngmapType _ (_ :: a) = undefined\r\n}}}\r\nGHC gives the rather perplexing error:\r\n{{{\r\nFoo.hs:8:12:\r\n The scoped type variables `a' and `a'\r\n are bound to the same type (variable)\r\n Distinct scoped type variables must be distinct\r\n In the pattern: _ :: a\r\n In the definition of `gmapType': gmapType _ (_ :: a) = undefined\r\n}}}\r\nHaving locations for the two `a`s would be useful.\r\n\r\nThis module gives the same error:\r\n{{{\r\n{-# OPTIONS -fglasgow-exts #-}\r\n\r\nmodule Foo where\r\n\r\ngmapType :: Int -> (forall a . a -> ())\r\ngmapType _ (_ :: a) = undefined\r\n}}}\r\n\r\nGHC 6.8.2 accepts both modules.\r\n\r\nI don't think that the forall in the type signature should bring `a` into scope for the body, as it doesn't bring it into scope for the type signature.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/2573Illegal polymorphic or qualified type with generics2019-07-07T19:07:52ZIan Lynagh <igloo@earth.li>Illegal polymorphic or qualified type with genericsA cut-down tcrun007:
```
{-# LANGUAGE Generics, TypeOperators #-}
import Data.Generics
class Tag a where
nCons :: a -> Int
nCons {| a :*: b |} _ = 1
```
is failing with:
```
tcrun007.hs:5:0:
Illegal polymorphic or qualified ...A cut-down tcrun007:
```
{-# LANGUAGE Generics, TypeOperators #-}
import Data.Generics
class Tag a where
nCons :: a -> Int
nCons {| a :*: b |} _ = 1
```
is failing with:
```
tcrun007.hs:5:0:
Illegal polymorphic or qualified type: forall a b. a :*: b
In the type pattern of a generic definition:
forall a b. a :*: b
In the class declaration for `Tag'
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | tcrun007 |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Illegal polymorphic or qualified type with generics","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"6.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.3","keywords":[],"differentials":[],"test_case":"tcrun007","architecture":"Unknown","cc":[""],"type":"Bug","description":"A cut-down tcrun007:\r\n{{{\r\n{-# LANGUAGE Generics, TypeOperators #-}\r\n\r\nimport Data.Generics\r\n\r\nclass Tag a where\r\n nCons :: a -> Int\r\n nCons {| a :*: b |} _ = 1\r\n}}}\r\nis failing with:\r\n{{{\r\ntcrun007.hs:5:0:\r\n Illegal polymorphic or qualified type: forall a b. a :*: b\r\n In the type pattern of a generic definition:\r\n forall a b. a :*: b\r\n In the class declaration for `Tag'\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/2618Order is relevant when matching signature contexts of a mutually recursive group2019-07-07T19:07:40ZguestOrder is relevant when matching signature contexts of a mutually recursive groupThe Following code
```
f :: (Show a, Eq a) => a -> String
f x = show x `const` g x
g :: (Eq a,Show a) => a -> Bool
g x = x==x `const` f x
```
gives this error:
```
Couldn't match expected type `Eq a' against inferred type `Show a...The Following code
```
f :: (Show a, Eq a) => a -> String
f x = show x `const` g x
g :: (Eq a,Show a) => a -> Bool
g x = x==x `const` f x
```
gives this error:
```
Couldn't match expected type `Eq a' against inferred type `Show a1'
When matching the contexts of the signatures for
f :: forall a. (Show a, Eq a) => a -> String
g :: forall a. (Eq a, Show a) => a -> Bool
The signature contexts in a mutually recursive group should all be identical
When generalising the type(s) for f, g
Failed, modules loaded: none.
```
but it compiles fine if i swap Show and Eq in the context of either f or g.
The order of typeclass constraints usually doesn't matter so it's very surprising that it does here.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | sanzhiyan@gmail.com |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Order is relevant when matching signature contexts of a mutually recursive group","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.3","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":["sanzhiyan@gmail.com"],"type":"Bug","description":"The Following code\r\n{{{\r\nf :: (Show a, Eq a) => a -> String\r\nf x = show x `const` g x\r\n\r\ng :: (Eq a,Show a) => a -> Bool\r\ng x = x==x `const` f x\r\n}}}\r\ngives this error:\r\n{{{\r\n Couldn't match expected type `Eq a' against inferred type `Show a1'\r\n When matching the contexts of the signatures for\r\n f :: forall a. (Show a, Eq a) => a -> String\r\n g :: forall a. (Eq a, Show a) => a -> Bool\r\n The signature contexts in a mutually recursive group should all be identical\r\n When generalising the type(s) for f, g\r\nFailed, modules loaded: none.\r\n}}}\r\nbut it compiles fine if i swap Show and Eq in the context of either f or g.\r\nThe order of typeclass constraints usually doesn't matter so it's very surprising that it does here.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/2627GADT + Type family doesn't unify like I expect2019-07-07T19:07:37ZryaniGADT + Type family doesn't unify like I expectI'd expect this program to compile; the "given" equations in "conn" should add additional constraints to the types determined by the GADT. Instead it looks like (Dual a) is failing to unify with (R _ _), and the same for (Dual b) and (W ...I'd expect this program to compile; the "given" equations in "conn" should add additional constraints to the types determined by the GADT. Instead it looks like (Dual a) is failing to unify with (R _ _), and the same for (Dual b) and (W _ _).
```
{-# LANGUAGE GADTs, TypeFamilies, EmptyDataDecls #-}
module Dual where
data R a b
data W a b
data Z
type family Dual a
type instance Dual Z = Z
type instance Dual (R a b) = W a (Dual b)
type instance Dual (W a b) = R a (Dual b)
data Comm a where
Rd :: (a -> Comm b) -> Comm (R a b)
Wr :: a -> Comm b -> Comm (W a b)
Fin :: Int -> Comm Z
conn :: (Dual a ~ b, Dual b ~ a) => Comm a -> Comm b -> (Int, Int)
conn (Fin x) (Fin y) = (x,y)
conn (Rd k) (Wr a r) = conn (k a) r
conn (Wr a r) (Rd k) = conn r (k a)
```
Running off of GHC HEAD:
`The Glorious Glasgow Haskell Compilation System, version 6.11.20080925`
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"GADT + Type family doesn't unify like I expect","status":"New","operating_system":"Unknown","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"I'd expect this program to compile; the \"given\" equations in \"conn\" should add additional constraints to the types determined by the GADT. Instead it looks like (Dual a) is failing to unify with (R _ _), and the same for (Dual b) and (W _ _).\r\n\r\n{{{\r\n{-# LANGUAGE GADTs, TypeFamilies, EmptyDataDecls #-}\r\nmodule Dual where\r\n\r\ndata R a b\r\ndata W a b\r\ndata Z\r\n\r\ntype family Dual a\r\ntype instance Dual Z = Z\r\ntype instance Dual (R a b) = W a (Dual b)\r\ntype instance Dual (W a b) = R a (Dual b)\r\n\r\ndata Comm a where\r\n Rd :: (a -> Comm b) -> Comm (R a b)\r\n Wr :: a -> Comm b -> Comm (W a b)\r\n Fin :: Int -> Comm Z\r\n\r\nconn :: (Dual a ~ b, Dual b ~ a) => Comm a -> Comm b -> (Int, Int)\r\nconn (Fin x) (Fin y) = (x,y)\r\nconn (Rd k) (Wr a r) = conn (k a) r\r\nconn (Wr a r) (Rd k) = conn r (k a)\r\n}}}\r\n\r\nRunning off of GHC HEAD:\r\n{{{The Glorious Glasgow Haskell Compilation System, version 6.11.20080925}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2658Extreme memory usage (probably type functions)2019-07-07T19:07:28ZguestExtreme memory usage (probably type functions)This is with the ghc 6.10.1 rc:
http://darcs.haskell.org/ghc-STABLE-2008-09-19-ghc-corelibs-testsuite.tar.bz2, unpacked, then ./darcs-all --extra get and ./darcs-all pull -a
Then a perf build.
Then, wget http://hackage.haskell.org/pac...This is with the ghc 6.10.1 rc:
http://darcs.haskell.org/ghc-STABLE-2008-09-19-ghc-corelibs-testsuite.tar.bz2, unpacked, then ./darcs-all --extra get and ./darcs-all pull -a
Then a perf build.
Then, wget http://hackage.haskell.org/packages/archive/sessions/2008.7.18/sessions-2008.7.18.tar.gz, unpack and cd sessions-2008.7.18
ghci-6.8.3 Tests/Tests.hs. This takes 40 seconds to get to the prompt and uses about 700MB memory.
ghci-6.10.0.20081004 Tests/Tests.hs. This has not finished type checking yet (well over 5 mins now - it exhaused my 4GB RAM and is now eating its way through 16GB of swap). top reports it's currently using about 5GB memory.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Extreme memory usage","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This is with the ghc 6.10.1 rc:\r\n\r\nhttp://darcs.haskell.org/ghc-STABLE-2008-09-19-ghc-corelibs-testsuite.tar.bz2, unpacked, then ./darcs-all --extra get and ./darcs-all pull -a\r\n\r\nThen a perf build.\r\n\r\nThen, wget http://hackage.haskell.org/packages/archive/sessions/2008.7.18/sessions-2008.7.18.tar.gz, unpack and cd sessions-2008.7.18\r\n\r\nghci-6.8.3 Tests/Tests.hs. This takes 40 seconds to get to the prompt and uses about 700MB memory.\r\n\r\nghci-6.10.0.20081004 Tests/Tests.hs. This has not finished type checking yet (well over 5 mins now - it exhaused my 4GB RAM and is now eating its way through 16GB of swap). top reports it's currently using about 5GB memory.","type_of_failure":"OtherFailure","blocking":[]} -->6.12.1Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2677Detection of TF instance conflict depends on instance order2019-07-07T19:07:23ZreinerpDetection of TF instance conflict depends on instance orderWith 6.10 RC1, the following code compiles without complaint:
```
{-# OPTIONS -fglasgow-exts #-}
module OverlapTest where
type family A x
type instance A a = Bool
type instance A Int = Char
```
even though the overlapping instances "A...With 6.10 RC1, the following code compiles without complaint:
```
{-# OPTIONS -fglasgow-exts #-}
module OverlapTest where
type family A x
type instance A a = Bool
type instance A Int = Char
```
even though the overlapping instances "A a" and "A Int" conflict. Reordering the instances to
```
{-# OPTIONS -fglasgow-exts #-}
module OverlapTest where
type family A x
type instance A Int = Char
type instance A a = Bool
```
correctly doesn't compile, complaining about conflicting instances.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.9 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown/Multiple |
| Architecture | Unknown/Multiple |
</details>
<!-- {"blocked_by":[],"summary":"Detection of TF instance conflict depends on instance order","status":"New","operating_system":"Unknown/Multiple","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.9","keywords":["TF","conflict","instance"],"differentials":[],"test_case":"","architecture":"Unknown/Multiple","cc":[""],"type":"Bug","description":"With 6.10 RC1, the following code compiles without complaint:\r\n{{{\r\n{-# OPTIONS -fglasgow-exts #-}\r\nmodule OverlapTest where\r\n\r\ntype family A x\r\ntype instance A a = Bool\r\ntype instance A Int = Char\r\n}}}\r\neven though the overlapping instances \"A a\" and \"A Int\" conflict. Reordering the instances to\r\n{{{\r\n{-# OPTIONS -fglasgow-exts #-}\r\nmodule OverlapTest where\r\n\r\ntype family A x\r\ntype instance A Int = Char\r\ntype instance A a = Bool\r\n}}}\r\ncorrectly doesn't compile, complaining about conflicting instances.","type_of_failure":"OtherFailure","blocking":[]} -->6.12 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2680Type-checking performance regression2019-07-07T19:07:23ZIan Lynagh <igloo@earth.li>Type-checking performance regressionAttached is a module Def1, which defines a load of type synonyms and some values, and a module !ReExport1, which just re-exports Def1.
1. 10 is comparable to 6.8 when compiling Def1, but rather than taking a couple of seconds to compile...Attached is a module Def1, which defines a load of type synonyms and some values, and a module !ReExport1, which just re-exports Def1.
1. 10 is comparable to 6.8 when compiling Def1, but rather than taking a couple of seconds to compile !ReExport1 it takes about 3 minutes.
Def2/ReExport2 are the same, but only contain the type synonyms. The difference in this case is 1 second vs 30 seconds.
GHC 6.8.2:
```
$ rm *.o; rm *.hi
$ time $GHC -O -fforce-recomp -c Def1.hs
$GHC -O -fforce-recomp -c Def1.hs 36.00s user 0.82s system 100% cpu 36.717 total
$ time $GHC -O -fforce-recomp -c ReExport1.hs
$GHC -O -fforce-recomp -c ReExport1.hs 2.22s user 0.11s system 100% cpu 2.332 total
$ time $GHC -O -fforce-recomp -c Def2.hs
$GHC -O -fforce-recomp -c Def2.hs 7.20s user 0.14s system 99% cpu 7.340 total
$ time $GHC -O -fforce-recomp -c ReExport2.hs
$GHC -O -fforce-recomp -c ReExport2.hs 0.99s user 0.08s system 100% cpu 1.075 total
$ $GHC --version
The Glorious Glasgow Haskell Compilation System, version 6.8.2
```
1. 10 branch:
```
$ rm *.o; rm *.hi
$ time $GHC -O -fforce-recomp -c Def1.hs
$GHC -O -fforce-recomp -c Def1.hs 35.94s user 0.60s system 100% cpu 36.350 total
$ time $GHC -O -fforce-recomp -c ReExport1.hs
$GHC -O -fforce-recomp -c ReExport1.hs 169.35s user 0.28s system 99% cpu 2:49.67 total
$ time $GHC -O -fforce-recomp -c Def2.hs
$GHC -O -fforce-recomp -c Def2.hs 8.37s user 0.11s system 100% cpu 8.477 total
$ time $GHC -O -fforce-recomp -c ReExport2.hs
$GHC -O -fforce-recomp -c ReExport2.hs 29.11s user 0.10s system 99% cpu 29.258 total
$ $GHC --version
The Glorious Glasgow Haskell Compilation System, version 6.10.0.20081009
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.8.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Type-checking performance regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"6.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Attached is a module Def1, which defines a load of type synonyms and some values, and a module !ReExport1, which just re-exports Def1.\r\n\r\n6.10 is comparable to 6.8 when compiling Def1, but rather than taking a couple of seconds to compile !ReExport1 it takes about 3 minutes.\r\n\r\nDef2/ReExport2 are the same, but only contain the type synonyms. The difference in this case is 1 second vs 30 seconds.\r\n\r\nGHC 6.8.2:\r\n{{{\r\n$ rm *.o; rm *.hi\r\n$ time $GHC -O -fforce-recomp -c Def1.hs\r\n$GHC -O -fforce-recomp -c Def1.hs 36.00s user 0.82s system 100% cpu 36.717 total\r\n$ time $GHC -O -fforce-recomp -c ReExport1.hs\r\n$GHC -O -fforce-recomp -c ReExport1.hs 2.22s user 0.11s system 100% cpu 2.332 total\r\n$ time $GHC -O -fforce-recomp -c Def2.hs\r\n$GHC -O -fforce-recomp -c Def2.hs 7.20s user 0.14s system 99% cpu 7.340 total\r\n$ time $GHC -O -fforce-recomp -c ReExport2.hs\r\n$GHC -O -fforce-recomp -c ReExport2.hs 0.99s user 0.08s system 100% cpu 1.075 total\r\n$ $GHC --version\r\nThe Glorious Glasgow Haskell Compilation System, version 6.8.2\r\n}}}\r\n\r\n6.10 branch:\r\n{{{\r\n$ rm *.o; rm *.hi\r\n$ time $GHC -O -fforce-recomp -c Def1.hs\r\n$GHC -O -fforce-recomp -c Def1.hs 35.94s user 0.60s system 100% cpu 36.350 total\r\n$ time $GHC -O -fforce-recomp -c ReExport1.hs\r\n$GHC -O -fforce-recomp -c ReExport1.hs 169.35s user 0.28s system 99% cpu 2:49.67 total\r\n$ time $GHC -O -fforce-recomp -c Def2.hs\r\n$GHC -O -fforce-recomp -c Def2.hs 8.37s user 0.11s system 100% cpu 8.477 total\r\n$ time $GHC -O -fforce-recomp -c ReExport2.hs\r\n$GHC -O -fforce-recomp -c ReExport2.hs 29.11s user 0.10s system 99% cpu 29.258 total\r\n$ $GHC --version \r\nThe Glorious Glasgow Haskell Compilation System, version 6.10.0.20081009\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/2695bogus "syntactically distinct contexts" error2019-07-07T19:07:19Zconalbogus "syntactically distinct contexts" error```
{-# LANGUAGE TypeOperators, FlexibleContexts
, MultiParamTypeClasses, FunctionalDependencies
, TypeFamilies
-- , ScopedTypeVariables
#-}
-- The ScopedTypeVariables is there just as a bug work-around. Without:
--
-- Mut...```
{-# LANGUAGE TypeOperators, FlexibleContexts
, MultiParamTypeClasses, FunctionalDependencies
, TypeFamilies
-- , ScopedTypeVariables
#-}
-- The ScopedTypeVariables is there just as a bug work-around. Without:
--
-- Mutually dependent functions have syntactically distinct contexts
-- When matching the contexts of the signatures for
-- dZero :: forall b a s.
-- (AdditiveGroup b, HasBasis a s, HasTrie (Basis a)) =>
-- a :> b
-- pureD :: forall b a s.
-- (AdditiveGroup b, HasBasis a s, HasTrie (Basis a)) =>
-- b -> a :> b
-- The signature contexts in a mutually recursive group should all be identical
-- When generalising the type(s) for dZero, pureD
--
-- This bug was introduced between ghc 6.9.20080622 and 6.10.0.20081007.
{-# OPTIONS_GHC -fno-warn-missing-methods #-}
import Control.Applicative
class AdditiveGroup v where
zeroV :: v
(^+^) :: v -> v -> v
negateV :: v -> v
class AdditiveGroup v => VectorSpace v s | v -> s where
(*^) :: s -> v -> v
-- | Mapping from all elements of @a@ to the results of some function
class HasTrie a where
data (:->:) a :: * -> *
instance HasTrie a => Functor ((:->:) a)
instance HasTrie a => Applicative ((:->:) a)
class VectorSpace v s => HasBasis v s where
type Basis v :: *
-- | Linear map, represented a as a memo function from basis to values.
type u :-* v = Basis u :->: v
data a :> b = D { powVal :: b, derivative :: a :-* (a :> b) }
dZero :: (AdditiveGroup b, HasBasis a s, HasTrie (Basis a)) => a:>b
dZero = pureD zeroV
pureD :: (AdditiveGroup b, HasBasis a s, HasTrie (Basis a)) => b -> a:>b
pureD b = b `D` pure dZero
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | conal |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"bogus \"syntactically distinct contexts\" error","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["conal"],"type":"Bug","description":"{{{\r\n{-# LANGUAGE TypeOperators, FlexibleContexts\r\n , MultiParamTypeClasses, FunctionalDependencies\r\n , TypeFamilies\r\n -- , ScopedTypeVariables\r\n #-}\r\n\r\n-- The ScopedTypeVariables is there just as a bug work-around. Without:\r\n-- \r\n-- Mutually dependent functions have syntactically distinct contexts\r\n-- When matching the contexts of the signatures for\r\n-- dZero :: forall b a s.\r\n-- (AdditiveGroup b, HasBasis a s, HasTrie (Basis a)) =>\r\n-- a :> b\r\n-- pureD :: forall b a s.\r\n-- (AdditiveGroup b, HasBasis a s, HasTrie (Basis a)) =>\r\n-- b -> a :> b\r\n-- The signature contexts in a mutually recursive group should all be identical\r\n-- When generalising the type(s) for dZero, pureD\r\n-- \r\n-- This bug was introduced between ghc 6.9.20080622 and 6.10.0.20081007.\r\n\r\n{-# OPTIONS_GHC -fno-warn-missing-methods #-}\r\n\r\n\r\nimport Control.Applicative\r\n\r\nclass AdditiveGroup v where\r\n zeroV :: v\r\n (^+^) :: v -> v -> v\r\n negateV :: v -> v\r\n\r\nclass AdditiveGroup v => VectorSpace v s | v -> s where\r\n (*^) :: s -> v -> v\r\n\r\n\r\n-- | Mapping from all elements of @a@ to the results of some function\r\nclass HasTrie a where\r\n data (:->:) a :: * -> *\r\n\r\ninstance HasTrie a => Functor ((:->:) a)\r\n\r\ninstance HasTrie a => Applicative ((:->:) a)\r\n\r\nclass VectorSpace v s => HasBasis v s where\r\n type Basis v :: *\r\n\r\n-- | Linear map, represented a as a memo function from basis to values.\r\ntype u :-* v = Basis u :->: v\r\n\r\ndata a :> b = D { powVal :: b, derivative :: a :-* (a :> b) }\r\n\r\ndZero :: (AdditiveGroup b, HasBasis a s, HasTrie (Basis a)) => a:>b\r\ndZero = pureD zeroV\r\n\r\npureD :: (AdditiveGroup b, HasBasis a s, HasTrie (Basis a)) => b -> a:>b\r\npureD b = b `D` pure dZero\r\n\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2714No match in record selector Var.tcTyVarDetails2019-07-07T19:07:12ZmorrowNo match in record selector Var.tcTyVarDetailsSummary:
```
ghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)
*** Exception: No match in record selector Var.tcTyVarDetails
```
I stumbled across this while in ghci with flags:
```
:set -fglasgow-exts -O2 -fno-print-bind-result
...Summary:
```
ghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)
*** Exception: No match in record selector Var.tcTyVarDetails
```
I stumbled across this while in ghci with flags:
```
:set -fglasgow-exts -O2 -fno-print-bind-result
:set -XQuasiQuotes -XTemplateHaskell
```
Beginning with where I came across it and proceeding
in reverse chrono order wrt ghc versions:
```
[m@ganon feio]$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 6.10.0.20080927
ghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)
*** Exception: No match in record selector Var.tcTyVarDetails
```
```
[m@ganon feio]$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 6.9.20080504
ghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)
*** Exception: No match in record selector Var.tcTyVarDetails
```
```
[m@ganon feio]$ /usr/bin/ghc-6.8.2 -V
The Glorious Glasgow Haskell Compilation System, version 6.8.2
ghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)
<interactive>:1:0:
Couldn't match expected type `c'
against inferred type `f (f b -> b)'
`c' is a rigid type variable bound by
the polymorphic type `forall c. c -> a' at <interactive>:1:0
Probable cause: `fmap' is applied to too few arguments
<interactive>:1:0:
Couldn't match expected type `a' against inferred type `f b'
`a' is a rigid type variable bound by
the polymorphic type
`forall a b. ((a -> b) -> b) -> forall c. c -> a'
at <interactive>:1:0
Probable cause: `fmap' is applied to too few arguments
```
```
[m@ganon feio]$ /usr/bin/ghc-6.8.1 -V
The Glorious Glasgow Haskell Compilation System, version 6.8.1
ghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)
<interactive>:1:0:
Couldn't match expected type `c'
against inferred type `f (f b -> b)'
`c' is a rigid type variable bound by
the polymorphic type `forall c. c -> a' at <interactive>:1:0
Probable cause: `fmap' is applied to too few arguments
```
Aside from filing a bug rpt, I'm curious in general about what
change to whathaveyou, some way or another, had this as a side-effect.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | mjm2002@gmail.com |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"No match in record selector Var.tcTyVarDetails","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":["Var,","record","selector","tcTyVarDetails,"],"differentials":[],"test_case":"","architecture":"","cc":["mjm2002@gmail.com"],"type":"Bug","description":"Summary:\r\n\r\n{{{\r\nghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)\r\n*** Exception: No match in record selector Var.tcTyVarDetails\r\n}}}\r\n\r\nI stumbled across this while in ghci with flags:\r\n\r\n{{{\r\n:set -fglasgow-exts -O2 -fno-print-bind-result\r\n:set -XQuasiQuotes -XTemplateHaskell\r\n}}}\r\n\r\nBeginning with where I came across it and proceeding\r\nin reverse chrono order wrt ghc versions:\r\n\r\n{{{\r\n[m@ganon feio]$ ghc -V\r\nThe Glorious Glasgow Haskell Compilation System, version 6.10.0.20080927\r\n\r\nghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)\r\n*** Exception: No match in record selector Var.tcTyVarDetails\r\n}}}\r\n\r\n{{{\r\n[m@ganon feio]$ ghc -V\r\nThe Glorious Glasgow Haskell Compilation System, version 6.9.20080504\r\n\r\nghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)\r\n*** Exception: No match in record selector Var.tcTyVarDetails\r\n}}}\r\n\r\n\r\n{{{\r\n[m@ganon feio]$ /usr/bin/ghc-6.8.2 -V\r\nThe Glorious Glasgow Haskell Compilation System, version 6.8.2\r\n\r\nghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)\r\n\r\n<interactive>:1:0:\r\n Couldn't match expected type `c'\r\n against inferred type `f (f b -> b)'\r\n `c' is a rigid type variable bound by\r\n the polymorphic type `forall c. c -> a' at <interactive>:1:0\r\n Probable cause: `fmap' is applied to too few arguments\r\n\r\n<interactive>:1:0:\r\n Couldn't match expected type `a' against inferred type `f b'\r\n `a' is a rigid type variable bound by\r\n the polymorphic type\r\n `forall a b. ((a -> b) -> b) -> forall c. c -> a'\r\n at <interactive>:1:0\r\n Probable cause: `fmap' is applied to too few arguments\r\n}}}\r\n\r\n{{{\r\n[m@ganon feio]$ /usr/bin/ghc-6.8.1 -V\r\nThe Glorious Glasgow Haskell Compilation System, version 6.8.1\r\n\r\nghci> :t fmap :: ((a -> b) -> b) -> (forall c. c -> a)\r\n\r\n<interactive>:1:0:\r\n Couldn't match expected type `c'\r\n against inferred type `f (f b -> b)'\r\n `c' is a rigid type variable bound by\r\n the polymorphic type `forall c. c -> a' at <interactive>:1:0\r\n Probable cause: `fmap' is applied to too few arguments\r\n}}}\r\n\r\nAside from filing a bug rpt, I'm curious in general about what\r\nchange to whathaveyou, some way or another, had this as a side-effect.","type_of_failure":"OtherFailure","blocking":[]} -->6.10.1mergemergehttps://gitlab.haskell.org/ghc/ghc/-/issues/2715Equality constraint in superclass not supported2019-07-07T19:07:12ZrodpriceEquality constraint in superclass not supportedThe code in "bug.hs" causes a GHC panic; the nearly identical code in "unbug.hs" does not.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version ...The code in "bug.hs" causes a GHC panic; the nearly identical code in "unbug.hs" does not.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.10.1 |
| 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":"GHC panic","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The code in \"bug.hs\" causes a GHC panic; the nearly identical code in \"unbug.hs\" does not.","type_of_failure":"OtherFailure","blocking":[]} -->7.2.1Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2738Regression in type checking of sections in records2019-07-07T19:07:06ZdonsRegression in type checking of sections in recordsLooks like a GHC 6.10 regression.
The following code, from xmonad-contrib, fails with an error under 6.10, but not under other compilers,
```
[ 74 of 138] Compiling XMonad.Hooks.UrgencyHook ( XMonad/Hooks/UrgencyHook.hs, dist/build/XMo...Looks like a GHC 6.10 regression.
The following code, from xmonad-contrib, fails with an error under 6.10, but not under other compilers,
```
[ 74 of 138] Compiling XMonad.Hooks.UrgencyHook ( XMonad/Hooks/UrgencyHook.hs, dist/build/XMonad/Hooks/UrgencyHook.o )
XMonad/Hooks/UrgencyHook.hs:424:48:
The section `5 `seconds`' takes one argument,
but its type `Int' has none
In the `duration' field of a record
In the expression:
DzenUrgencyHook {duration = (5 `seconds`), args = []}
In the definition of `dzenUrgencyHook':
dzenUrgencyHook = DzenUrgencyHook
{duration = (5 `seconds`), args = []}
```
The relevant code is:
```
-- | Flashes when a window requests your attention and you can't see it.
-- Defaults to a duration of five seconds, and no extra args to dzen.
-- See 'DzenUrgencyHook'.
dzenUrgencyHook :: DzenUrgencyHook
dzenUrgencyHook = DzenUrgencyHook { duration = (5 `seconds`), args = [] }
```
Which looks harmless enough. In fact, rearranging the section let's it pass type checking:
```
dzenUrgencyHook = DzenUrgencyHook { duration = seconds 5, args = [] }
```
The relevant code can be found here: http://code.haskell.org/XMonadContrib/XMonad/Hooks/UrgencyHook.hs, line 424.
To reproduce, assuming ghc 6.10 is installed, and X11,
```
$ cd XMonadContrib
$ cabal install
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Regression in type checking of sections in records","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Looks like a GHC 6.10 regression.\r\n\r\nThe following code, from xmonad-contrib, fails with an error under 6.10, but not under other compilers,\r\n\r\n{{{\r\n[ 74 of 138] Compiling XMonad.Hooks.UrgencyHook ( XMonad/Hooks/UrgencyHook.hs, dist/build/XMonad/Hooks/UrgencyHook.o )\r\n\r\nXMonad/Hooks/UrgencyHook.hs:424:48:\r\n The section `5 `seconds`' takes one argument,\r\n but its type `Int' has none\r\n In the `duration' field of a record\r\n In the expression:\r\n DzenUrgencyHook {duration = (5 `seconds`), args = []}\r\n In the definition of `dzenUrgencyHook':\r\n dzenUrgencyHook = DzenUrgencyHook\r\n {duration = (5 `seconds`), args = []}\r\n}}}\r\n\r\nThe relevant code is:\r\n\r\n{{{\r\n-- | Flashes when a window requests your attention and you can't see it.\r\n-- Defaults to a duration of five seconds, and no extra args to dzen.\r\n-- See 'DzenUrgencyHook'.\r\ndzenUrgencyHook :: DzenUrgencyHook\r\ndzenUrgencyHook = DzenUrgencyHook { duration = (5 `seconds`), args = [] }\r\n}}}\r\n\r\nWhich looks harmless enough. In fact, rearranging the section let's it pass type checking:\r\n\r\n{{{\r\ndzenUrgencyHook = DzenUrgencyHook { duration = seconds 5, args = [] }\r\n}}}\r\n\r\nThe relevant code can be found here: http://code.haskell.org/XMonadContrib/XMonad/Hooks/UrgencyHook.hs, line 424.\r\n\r\nTo reproduce, assuming ghc 6.10 is installed, and X11,\r\n\r\n{{{\r\n$ cd XMonadContrib \r\n$ cabal install\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2761type checker bug2019-07-07T19:07:00Zguesttype checker bugThis causes a type error:
```
foo :: forall b. (b -> String, Int)
foo = (const "hi", 0)
bar :: (forall b. b -> String, Int)
bar = foo
```
This should compile fine since the types are equivalent.This causes a type error:
```
foo :: forall b. (b -> String, Int)
foo = (const "hi", 0)
bar :: (forall b. b -> String, Int)
bar = foo
```
This should compile fine since the types are equivalent.https://gitlab.haskell.org/ghc/ghc/-/issues/2767Type family bug ?2019-07-07T19:06:58ZtestType family bug ?I get this error when compiling a program with associated type families:
```
$ ghc --make Queens_v2.hs
[1 of 5] Compiling Domain ( Domain.hs, Domain.o )
[2 of 5] Compiling Solver ( Solver.hs, Solver.o )
[3 of 5] Com...I get this error when compiling a program with associated type families:
```
$ ghc --make Queens_v2.hs
[1 of 5] Compiling Domain ( Domain.hs, Domain.o )
[2 of 5] Compiling Solver ( Solver.hs, Solver.o )
[3 of 5] Compiling FD ( FD.hs, FD.o )
[4 of 5] Compiling SearchTree ( SearchTree.hs, SearchTree.o )
[5 of 5] Compiling Main ( Queens_v2.hs, Queens_v2.o )
ghc: panic! (the 'impossible' happened)
(GHC version 6.10.1 for i386-apple-darwin):
idInfo co{v a629} [tv]
```
Tom Schrijvers
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | MacOS X |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Type family bug ?","status":"New","operating_system":"MacOS X","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I get this error when compiling a program with associated type families:\r\n{{{\r\n$ ghc --make Queens_v2.hs \r\n[1 of 5] Compiling Domain ( Domain.hs, Domain.o )\r\n[2 of 5] Compiling Solver ( Solver.hs, Solver.o )\r\n[3 of 5] Compiling FD ( FD.hs, FD.o )\r\n[4 of 5] Compiling SearchTree ( SearchTree.hs, SearchTree.o )\r\n[5 of 5] Compiling Main ( Queens_v2.hs, Queens_v2.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 6.10.1 for i386-apple-darwin):\r\n\tidInfo co{v a629} [tv]\r\n}}}\r\n\r\nTom Schrijvers","type_of_failure":"OtherFailure","blocking":[]} -->6.12 branchManuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2787Panic (core lint failure) with type synonym in GHC 6.10.12019-07-07T19:06:50ZBenMoseleyPanic (core lint failure) with type synonym in GHC 6.10.1This causes a panic:
```
{-# LANGUAGE TypeFamilies, GADTs #-}
module GHCBug (
PVR(..),
Core(..),
analyseCore
)
where
data Core a where Ctr :: Core Double
data PVR a = PVR a deriving (Eq, Show)
class Sub a where
type AssocSy...This causes a panic:
```
{-# LANGUAGE TypeFamilies, GADTs #-}
module GHCBug (
PVR(..),
Core(..),
analyseCore
)
where
data Core a where Ctr :: Core Double
data PVR a = PVR a deriving (Eq, Show)
class Sub a where
type AssocSyn a :: * -> *
instance Sub Double where
type AssocSyn Double = PVR
analyseCore :: Core a -> ((AssocSyn a) a)
analyseCore Ctr = pvr
where
-- GHC panics if we use the below as the type sig for 'pvr'
pvr :: PVR ~ AssocSyn a => (AssocSyn a) a
-- pvr :: (AssocSyn a) a
pvr = undefined
main :: IO ()
main = print "ok"
```
The basic compiler panic is:
```
c:/ws/main/depot/QA/EDG/EDG_priv/FPF_Dev.br/src $ ghc -main-is GHCBug ~/GHCBug.hs
ghc.exe: panic! (the 'impossible' happened)
(GHC version 6.10.1 for i386-unknown-mingw32):
initC: srt_lbl
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
The core lint failure part is:
```
*** Checking old interface for main:GHCBug:
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size = 199
*** Core Lint Errors: in result of Desugar ***
{-# LINE 21 "F:\ME\GHCBug.hs #-}:
[RHS of pvr_awa :: GHCBug.AssocSyn
GHC.Types.Double GHC.Types.Double]
pvr_afN is out of scope
*** Offending Program ***
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Windows |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Panic (core lint failure) with type synonym in GHC 6.10.1","status":"New","operating_system":"Windows","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This causes a panic:\r\n\r\n{{{\r\n{-# LANGUAGE TypeFamilies, GADTs #-}\r\nmodule GHCBug (\r\n PVR(..),\r\n Core(..),\r\n analyseCore\r\n)\r\nwhere\r\n\r\ndata Core a where Ctr :: Core Double\r\ndata PVR a = PVR a deriving (Eq, Show)\r\n\r\n\r\nclass Sub a where\r\n type AssocSyn a :: * -> *\r\n\r\ninstance Sub Double where\r\n type AssocSyn Double = PVR\r\n\r\n\r\nanalyseCore :: Core a -> ((AssocSyn a) a)\r\nanalyseCore Ctr = pvr\r\n where\r\n -- GHC panics if we use the below as the type sig for 'pvr'\r\n pvr :: PVR ~ AssocSyn a => (AssocSyn a) a\r\n -- pvr :: (AssocSyn a) a\r\n pvr = undefined\r\n\r\nmain :: IO ()\r\nmain = print \"ok\"\r\n}}}\r\n\r\nThe basic compiler panic is:\r\n{{{\r\nc:/ws/main/depot/QA/EDG/EDG_priv/FPF_Dev.br/src $ ghc -main-is GHCBug ~/GHCBug.hs\r\nghc.exe: panic! (the 'impossible' happened)\r\n (GHC version 6.10.1 for i386-unknown-mingw32):\r\n\tinitC: srt_lbl\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nThe core lint failure part is:\r\n{{{\r\n*** Checking old interface for main:GHCBug:\r\n*** Parser:\r\n*** Renamer/typechecker:\r\n*** Desugar:\r\n Result size = 199\r\n*** Core Lint Errors: in result of Desugar ***\r\n{-# LINE 21 \"F:\\ME\\GHCBug.hs #-}:\r\n [RHS of pvr_awa :: GHCBug.AssocSyn\r\n GHC.Types.Double GHC.Types.Double]\r\n pvr_afN is out of scope\r\n*** Offending Program ***\r\n}}}\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/2851Improve error message for failed deriving2019-07-07T19:06:33ZguestImprove error message for failed derivingThe following does not work:
```
type family F a :: *
data D a = D (F a)
deriving (Show)
```
The natural way of adding an instance does work (with enough extensions turned on):
```
instance (Show (F a)) => Show (D a) where
sh...The following does not work:
```
type family F a :: *
data D a = D (F a)
deriving (Show)
```
The natural way of adding an instance does work (with enough extensions turned on):
```
instance (Show (F a)) => Show (D a) where
show (D x) = "D " ++ show x
```
It would be nice if the deriving mechanism could derive this code.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 6.10.1 |
| 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":"Deriving doesn't work when type families are involved","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"The following does not work:\r\n\r\n{{{\r\ntype family F a :: *\r\n\r\ndata D a = D (F a)\r\n deriving (Show)\r\n}}}\r\n\r\nThe natural way of adding an instance does work (with enough extensions turned on):\r\n\r\n{{{\r\ninstance (Show (F a)) => Show (D a) where\r\n show (D x) = \"D \" ++ show x\r\n}}}\r\n\r\nIt would be nice if the deriving mechanism could derive this code.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/2899GADT type inference with existentials2019-07-07T19:06:22ZjochembGADT type inference with existentialsThe following code works in GHC 6.8.2:
```
{-# OPTIONS -fglasgow-exts #-}
module Test where
data Existential = forall a. Ex (GADT a)
data GADT :: * -> * where
GCon :: Int -> GADT ()
-- g :: Existential -> Int
g (Ex (GCon x)) ...The following code works in GHC 6.8.2:
```
{-# OPTIONS -fglasgow-exts #-}
module Test where
data Existential = forall a. Ex (GADT a)
data GADT :: * -> * where
GCon :: Int -> GADT ()
-- g :: Existential -> Int
g (Ex (GCon x)) = x
```
The compiler correctly infers the type of x in the definition of g, and correctly infers the type of g.
In GHC 6.10.1, however, this fails with:
```
Test.hs:10:12:
GADT pattern match with non-rigid result type `t'
Solution: add a type signature
In the definition of `g': g (Ex (GCon x)) = x
Failed, modules loaded: none.
```
The solution, to include the type signature of g (that I have commented out), works, but why can't GHC figure out the type of g? GHC 6.8.2 could!
An equivalent version with a non-GADT instead, works correctly:
```
data GADT a = GCon Int
```
Ticket #2206 might be related.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GADT type inference with existentials","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":["GADT,","existential","types"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"\r\nThe following code works in GHC 6.8.2:\r\n\r\n{{{\r\n{-# OPTIONS -fglasgow-exts #-}\r\nmodule Test where\r\n\r\ndata Existential = forall a. Ex (GADT a)\r\n\r\ndata GADT :: * -> * where\r\n GCon :: Int -> GADT ()\r\n\r\n-- g :: Existential -> Int\r\ng (Ex (GCon x)) = x\r\n}}}\r\n\r\nThe compiler correctly infers the type of x in the definition of g, and correctly infers the type of g.\r\n\r\nIn GHC 6.10.1, however, this fails with:\r\n{{{\r\nTest.hs:10:12:\r\n GADT pattern match with non-rigid result type `t'\r\n Solution: add a type signature\r\n In the definition of `g': g (Ex (GCon x)) = x\r\nFailed, modules loaded: none.\r\n}}}\r\n\r\nThe solution, to include the type signature of g (that I have commented out), works, but why can't GHC figure out the type of g? GHC 6.8.2 could!\r\n\r\nAn equivalent version with a non-GADT instead, works correctly:\r\n{{{\r\ndata GADT a = GCon Int\r\n}}}\r\n\r\nTicket #2206 might be related.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2900Confusing error message for monadic function with wrong number of arguments2019-07-07T19:06:21Zchevalier@alum.wellesley.eduConfusing error message for monadic function with wrong number of argumentsIf I compile the following code:
```
import Control.Monad.State
foo :: MonadIO m => Int -> m ()
foo x y = return ()
```
I get the error message:
```
bug.hs:6:10:
Couldn't match expected type `()' against inferred type `m ()'
...If I compile the following code:
```
import Control.Monad.State
foo :: MonadIO m => Int -> m ()
foo x y = return ()
```
I get the error message:
```
bug.hs:6:10:
Couldn't match expected type `()' against inferred type `m ()'
In the expression: return ()
In the definition of `foo': foo x y = return ()
```
On the other hand, if I change foo's type signature to:
```
foo :: Int -> IO ()
```
I get the more helpful:
```
bug.hs:6:0:
The equation(s) for `foo' have two arguments,
but its type `Int -> IO ()' has only one
```
It would be good if the second error message appeared in the first case as well.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Confusing error message for monadic function with wrong number of arguments","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If I compile the following code:\r\n\r\n{{{\r\nimport Control.Monad.State\r\n\r\nfoo :: MonadIO m => Int -> m ()\r\nfoo x y = return ()\r\n}}}\r\n\r\nI get the error message:\r\n\r\n{{{\r\nbug.hs:6:10:\r\n Couldn't match expected type `()' against inferred type `m ()'\r\n In the expression: return ()\r\n In the definition of `foo': foo x y = return ()\r\n}}}\r\n\r\nOn the other hand, if I change foo's type signature to:\r\n{{{\r\nfoo :: Int -> IO ()\r\n}}}\r\nI get the more helpful:\r\n{{{\r\nbug.hs:6:0:\r\n The equation(s) for `foo' have two arguments,\r\n but its type `Int -> IO ()' has only one\r\n}}}\r\n\r\nIt would be good if the second error message appeared in the first case as well.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2905require -XGADTs in order to pattern-match GADTs2023-04-01T12:41:21Zguestrequire -XGADTs in order to pattern-match GADTsWithout -XGADTs, pattern-matching GADTs causes weird typechecking problems (due to the lack of implied -XRelaxedPolyRec), see this thread http://thread.gmane.org/gmane.comp.lang.haskell.glasgow.user/16064 , and some history in bug #2004
...Without -XGADTs, pattern-matching GADTs causes weird typechecking problems (due to the lack of implied -XRelaxedPolyRec), see this thread http://thread.gmane.org/gmane.comp.lang.haskell.glasgow.user/16064 , and some history in bug #2004
I propose that pattern-matching against any constructor that uses sufficient GADT features that it's particularly confused without -XRelaxedPolyRec, should require -XGADTs
(I don't understand the issue well enough to know if what I'm saying makes sense. I guess ordinary data and mere existentials don't need it, even when defined with GADT syntax...?)
Alternately we could just require -XRelaxedPolyRec, but that seems even more confusing (and it wouldn't help make code portable to other compilers, as GADTs are definitely being used). Or if Haskell-prime ever comes around and makes -XRelaxedPolyRec default (is it planning to?), then the issue might be moot. I don't think the argument (against requiring -XGADTs) by parallel to -XOverlappingInstances is particularly strong... -XOverlappingInstances has an implicit effect on a module's class definitions... also I don't necessarily agree with that we made that decision for existing flags either :-)
--Isaac Dupree
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------------------------ |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | id@isaac.cedarswampstudios.org |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"require -XGADTs in order to pattern-match GADTs","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["id@isaac.cedarswampstudios.org"],"type":"Bug","description":"Without -XGADTs, pattern-matching GADTs causes weird typechecking problems (due to the lack of implied -XRelaxedPolyRec), see this thread http://thread.gmane.org/gmane.comp.lang.haskell.glasgow.user/16064 , and some history in bug #2004\r\n\r\nI propose that pattern-matching against any constructor that uses sufficient GADT features that it's particularly confused without -XRelaxedPolyRec, should require -XGADTs\r\n\r\n(I don't understand the issue well enough to know if what I'm saying makes sense. I guess ordinary data and mere existentials don't need it, even when defined with GADT syntax...?)\r\n\r\nAlternately we could just require -XRelaxedPolyRec, but that seems even more confusing (and it wouldn't help make code portable to other compilers, as GADTs are definitely being used). Or if Haskell-prime ever comes around and makes -XRelaxedPolyRec default (is it planning to?), then the issue might be moot. I don't think the argument (against requiring -XGADTs) by parallel to -XOverlappingInstances is particularly strong... -XOverlappingInstances has an implicit effect on a module's class definitions... also I don't necessarily agree with that we made that decision for existing flags either :-)\r\n\r\n\r\n--Isaac Dupree\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/2944Mutually recursive equality constraints2019-07-07T19:06:11ZMartijnVanSteenbergenMutually recursive equality constraintsGiven this piece of code:
```
{-# LANGUAGE TypeFamilies #-}
class C a where
type T a :: *
f1 :: T a ~ () => a
f1 = f2
f2 :: T a ~ () => a
f2 = f1
```
GHC complains:
```
Couldn't match expected type `T a ~ ()'
again...Given this piece of code:
```
{-# LANGUAGE TypeFamilies #-}
class C a where
type T a :: *
f1 :: T a ~ () => a
f1 = f2
f2 :: T a ~ () => a
f2 = f1
```
GHC complains:
```
Couldn't match expected type `T a ~ ()'
against inferred type `T a1 ~ ()'
When matching the contexts of the signatures for
f1 :: forall a. (T a ~ ()) => a
f2 :: forall a. (T a ~ ()) => a
The signature contexts in a mutually recursive group should all be identical
When generalising the type(s) for f1, f2
```
Is this a bug? Enabling RelaxedPolyRec fixes the problem. Should TypeFamiliesājust like GADTsāimply RelaxedPolyRec?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Mutually recursive equality constraints","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Given this piece of code:\r\n\r\n{{{\r\n{-# LANGUAGE TypeFamilies #-}\r\n\r\nclass C a where\r\n type T a :: *\r\n\r\nf1 :: T a ~ () => a\r\nf1 = f2\r\n\r\nf2 :: T a ~ () => a\r\nf2 = f1\r\n}}}\r\n\r\nGHC complains:\r\n\r\n{{{\r\n Couldn't match expected type `T a ~ ()'\r\n against inferred type `T a1 ~ ()'\r\n When matching the contexts of the signatures for\r\n f1 :: forall a. (T a ~ ()) => a\r\n f2 :: forall a. (T a ~ ()) => a\r\n The signature contexts in a mutually recursive group should all be identical\r\n When generalising the type(s) for f1, f2\r\n}}}\r\n\r\nIs this a bug? Enabling RelaxedPolyRec fixes the problem. Should TypeFamiliesājust like GADTsāimply RelaxedPolyRec?\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/2999yi darcs crashes ghc 6.11.200902012019-07-07T19:05:57ZIlmari Vacklinyi darcs crashes ghc 6.11.20090201```
Building yi-0.5.3...
[ 1 of 107] Compiling System.FriendlyPath ( System/FriendlyPath.hs, dist/build/System/FriendlyPath.o )
[ 2 of 107] Compiling Shim.ProjectContent ( Shim/ProjectContent.hs, dist/build/Shim/ProjectContent.o )
WARN...```
Building yi-0.5.3...
[ 1 of 107] Compiling System.FriendlyPath ( System/FriendlyPath.hs, dist/build/System/FriendlyPath.o )
[ 2 of 107] Compiling Shim.ProjectContent ( Shim/ProjectContent.hs, dist/build/Shim/ProjectContent.o )
WARNING: file simplCore/SimplCore.lhs line 545
Simplifier still going after 4 iterations; bailing out. Size = 4969
[ 3 of 107] Compiling Parser.Incremental ( Parser/Incremental.hs, dist/build/Parser/Incremental.o )
ghc: panic! (the 'impossible' happened)
(GHC version 6.11.20090201 for x86_64-unknown-linux):
ASSERT failed! file typecheck/TcTyFuns.lhs line 286
[Wanted t_a89i{tv} [tau] :: a{tv a89b} [sk]
~
a{tv a89a} [sk] -> t_a89h{tv} [tau]]
```Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/3011ASSERT failed: file typecheck/TcMType.lhs line 526 t_a32G{tv}2019-07-07T19:05:53ZbatterseapowerASSERT failed: file typecheck/TcMType.lhs line 526 t_a32G{tv}NB: this is NOT AFAIK a duplicate of the previous ticket about the TcMType ASSERT failure. It was observed on a recent HEAD (as of 6th February 2009) while I happened to be using a stage 2 compiler with -DDEBUG on to compile some code I ...NB: this is NOT AFAIK a duplicate of the previous ticket about the TcMType ASSERT failure. It was observed on a recent HEAD (as of 6th February 2009) while I happened to be using a stage 2 compiler with -DDEBUG on to compile some code I was working on.
Error is as follows:
```
$ ./Setup clean && ./Setup configure --with-compiler=/Users/mbolingbroke/Programming/Checkouts/ghc.working/ghc/stage2-inplace/ghc --with-hc-pkg=/Users/mbolingbroke/Programming/Checkouts/ghc.working/ghc/stage2-inplace/ghc-pkg --ghc --global && ./Setup build && dist/build/vector-tests/vector-tests
cleaning...
Configuring vector-tests-0.2...
Preprocessing executables for vector-tests-0.2...
Building vector-tests-0.2...
[1 of 3] Compiling Utilities ( Utilities.hs, dist/build/vector-tests/vector-tests-tmp/Utilities.o )
WARNING: file simplCore/SimplCore.lhs line 545
Simplifier still going after 4 iterations; bailing out. Size = 1398
[2 of 3] Compiling Properties ( Properties.hs, dist/build/vector-tests/vector-tests-tmp/Properties.o )
WARNING: file typecheck/TcTyFuns.lhs line 284
(This warning is harmless; for Simon & Manuel)
[Wanted t_a32G{tv} [tau] :: ghc-prim:GHC.Types.[]{(w) tc 317}
~
v{tv a2S9} [sk]]
ghc: panic! (the 'impossible' happened)
(GHC version 6.11.20090204 for i386-apple-darwin):
ASSERT failed! file typecheck/TcMType.lhs line 526 t_a32G{tv} [tau]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Where that code look something like this:
```
do { ASSERTM2( do { details <- readMetaTyVar tyvar; return (isFlexi details) }, ppr tyvar )
; traceTc (text "writeMetaTyVar" <+> ppr tyvar <+> text ":=" <+> ppr ty)
; writeMutVar (metaTvRef tyvar) (Indirect ty) }
```
Full program is attached.
Actually, the program has a type error (as rerunning with a non -DDEBUG build showed):
```
Properties.hs:78:25:
Could not deduce (Data.Vector.Unboxed.IVector [] a)
from the context (Eq a,
Ord a,
Eq (v a),
Ord (v a),
Show a,
Arbitrary a,
Model a a,
Show (v a),
Arbitrary (v a),
Model (v a) [a],
Data.Vector.Unboxed.IVector v a,
Show (v Bool),
Arbitrary (v Bool),
Model (v Bool) [Bool],
Data.Vector.Unboxed.IVector v Bool)
arising from a use of `Data.Vector.Unboxed.length'
at Properties.hs:78:25-32
Possible fix:
add (Data.Vector.Unboxed.IVector [] a) to the context of
the type signature for `testVersusLists'
or add an instance declaration for
(Data.Vector.Unboxed.IVector [] a)
In the first argument of `eq1', namely
`(Data.Vector.Unboxed.length :: v a -> Int)'
In the expression:
(Data.Vector.Unboxed.length :: v a -> Int) `eq1` length
In the definition of `prop_length':
prop_length = (Data.Vector.Unboxed.length :: v a -> Int)
`eq1`
length
Properties.hs:83:25:
No instance for (Data.Vector.Unboxed.IVector [] Bool)
arising from a use of `Data.Vector.Unboxed.and'
at Properties.hs:83:25-29
Possible fix:
add an instance declaration for
(Data.Vector.Unboxed.IVector [] Bool)
In the first argument of `eq1', namely
`(Data.Vector.Unboxed.and :: v Bool -> Bool)'
In the expression:
(Data.Vector.Unboxed.and :: v Bool -> Bool) `eq1` and
In the definition of `prop_and':
prop_and = (Data.Vector.Unboxed.and :: v Bool -> Bool) `eq1` and
Properties.hs:95:24:
Could not deduce (Eq ([a] -> [a]))
from the context (Eq a,
Ord a,
Eq (v a),
Ord (v a),
Show a,
Arbitrary a,
Model a a,
Show (v a),
Arbitrary (v a),
Model (v a) [a],
Data.Vector.Unboxed.IVector v a,
Show (v Bool),
Arbitrary (v Bool),
Model (v Bool) [Bool],
Data.Vector.Unboxed.IVector v Bool)
arising from a use of `eq2' at Properties.hs:95:24-86
Possible fix:
add (Eq ([a] -> [a])) to the context of
the type signature for `testVersusLists'
or add an instance declaration for (Eq ([a] -> [a]))
In the expression:
(Data.Vector.Unboxed.zipWith :: (a -> a -> a) -> v a -> v a -> v a)
`eq2`
zipWith
In the definition of `prop_zipWith':
prop_zipWith = (Data.Vector.Unboxed.zipWith ::
(a -> a -> a) -> v a -> v a -> v a)
`eq2`
zipWith
In the definition of `testVersusLists':
testVersusLists _ = [testGroup "Prelude" prelude_tests,
testGroup "Data.List" data_list_tests,
testGroup "Extras" extra_tests]
where
prelude_tests = [testProperty "length" prop_length, ....]
prop_length = (Data.Vector.Unboxed.length :: v a -> Int)
`eq1`
length
prop_null = (Data.Vector.Unboxed.null :: v a -> Bool) `eq1` null
prop_and = (Data.Vector.Unboxed.and :: v Bool -> Bool) `eq1` and
....
Properties.hs:114:25:
Couldn't match expected type `v' against inferred type `[]'
`v' is a rigid type variable bound by
the type signature for `testVersusLists' at Properties.hs:19:28
In the first argument of `eq2', namely
`(enumFromTo :: a -> a -> v a)'
In the expression: (enumFromTo :: a -> a -> v a) `eq2` enumFromTo
In the definition of `prop_enumFromTo':
prop_enumFromTo = (enumFromTo :: a -> a -> v a) `eq2` enumFromTo
Properties.hs:115:76:
Could not deduce (Enum a)
from the context (Eq a,
Ord a,
Eq (v a),
Ord (v a),
Show a,
Arbitrary a,
Model a a,
Show (v a),
Arbitrary (v a),
Model (v a) [a],
Data.Vector.Unboxed.IVector v a,
Show (v Bool),
Arbitrary (v Bool),
Model (v Bool) [Bool],
Data.Vector.Unboxed.IVector v Bool)
arising from a use of `enumFromThenTo' at Properties.hs:115:76-89
Possible fix:
add (Enum a) to the context of
the type signature for `testVersusLists'
In the second argument of `eq3', namely `enumFromThenTo'
In the expression:
(enumFromThenTo :: a -> a -> a -> v a) `eq3` enumFromThenTo
In the definition of `prop_enumFromThenTo':
prop_enumFromThenTo = (enumFromThenTo :: a -> a -> a -> v a)
`eq3`
enumFromThenTo
Properties.hs:176:16:
Could not deduce (Model [a] [a])
from the context (Eq a,
Ord a,
Eq (v a),
Ord (v a),
Show a,
Arbitrary a,
Model a a,
Show (v a),
Arbitrary (v a),
Model (v a) [a],
Data.Vector.Unboxed.IVector v a,
Show (v Bool),
Arbitrary (v Bool),
Model (v Bool) [Bool],
Data.Vector.Unboxed.IVector v Bool)
arising from a use of `eq2' at Properties.hs:176:16-71
Possible fix:
add (Model [a] [a]) to the context of
the type signature for `testVersusLists'
or add an instance declaration for (Model [a] [a])
In the expression:
(Data.Vector.Unboxed.snoc :: v a -> a -> v a) `eq2` snoc
In the definition of `prop_snoc':
prop_snoc = (Data.Vector.Unboxed.snoc :: v a -> a -> v a)
`eq2`
snoc
In the definition of `testVersusLists':
testVersusLists _ = [testGroup "Prelude" prelude_tests,
testGroup "Data.List" data_list_tests,
testGroup "Extras" extra_tests]
where
prelude_tests = [testProperty "length" prop_length, ....]
prop_length = (Data.Vector.Unboxed.length :: v a -> Int)
`eq1`
length
prop_null = (Data.Vector.Unboxed.null :: v a -> Bool) `eq1` null
prop_and = (Data.Vector.Unboxed.and :: v Bool -> Bool) `eq1` and
....
```
But we probably still shouldn't get the ASSERT.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"ASSERT failed: file typecheck/TcMType.lhs line 526 t_a32G{tv}","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"NB: this is NOT AFAIK a duplicate of the previous ticket about the TcMType ASSERT failure. It was observed on a recent HEAD (as of 6th February 2009) while I happened to be using a stage 2 compiler with -DDEBUG on to compile some code I was working on.\r\n\r\nError is as follows:\r\n{{{\r\n$ ./Setup clean && ./Setup configure --with-compiler=/Users/mbolingbroke/Programming/Checkouts/ghc.working/ghc/stage2-inplace/ghc --with-hc-pkg=/Users/mbolingbroke/Programming/Checkouts/ghc.working/ghc/stage2-inplace/ghc-pkg --ghc --global && ./Setup build && dist/build/vector-tests/vector-tests\r\ncleaning...\r\nConfiguring vector-tests-0.2...\r\nPreprocessing executables for vector-tests-0.2...\r\nBuilding vector-tests-0.2...\r\n[1 of 3] Compiling Utilities ( Utilities.hs, dist/build/vector-tests/vector-tests-tmp/Utilities.o )\r\nWARNING: file simplCore/SimplCore.lhs line 545\r\nSimplifier still going after 4 iterations; bailing out. Size = 1398\r\n\r\n[2 of 3] Compiling Properties ( Properties.hs, dist/build/vector-tests/vector-tests-tmp/Properties.o )\r\nWARNING: file typecheck/TcTyFuns.lhs line 284\r\n(This warning is harmless; for Simon & Manuel)\r\n[Wanted t_a32G{tv} [tau] :: ghc-prim:GHC.Types.[]{(w) tc 317}\r\n ~\r\n v{tv a2S9} [sk]]\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 6.11.20090204 for i386-apple-darwin):\r\n ASSERT failed! file typecheck/TcMType.lhs line 526 t_a32G{tv} [tau]\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nWhere that code look something like this:\r\n\r\n{{{\r\n do\t{ ASSERTM2( do { details <- readMetaTyVar tyvar; return (isFlexi details) }, ppr tyvar )\r\n\t; traceTc (text \"writeMetaTyVar\" <+> ppr tyvar <+> text \":=\" <+> ppr ty)\r\n\t; writeMutVar (metaTvRef tyvar) (Indirect ty) }\r\n}}}\r\n\r\nFull program is attached.\r\n\r\nActually, the program has a type error (as rerunning with a non -DDEBUG build showed):\r\n\r\n{{{\r\nProperties.hs:78:25:\r\n Could not deduce (Data.Vector.Unboxed.IVector [] a)\r\n from the context (Eq a,\r\n Ord a,\r\n Eq (v a),\r\n Ord (v a),\r\n Show a,\r\n Arbitrary a,\r\n Model a a,\r\n Show (v a),\r\n Arbitrary (v a),\r\n Model (v a) [a],\r\n Data.Vector.Unboxed.IVector v a,\r\n Show (v Bool),\r\n Arbitrary (v Bool),\r\n Model (v Bool) [Bool],\r\n Data.Vector.Unboxed.IVector v Bool)\r\n arising from a use of `Data.Vector.Unboxed.length'\r\n at Properties.hs:78:25-32\r\n Possible fix:\r\n add (Data.Vector.Unboxed.IVector [] a) to the context of\r\n the type signature for `testVersusLists'\r\n or add an instance declaration for\r\n (Data.Vector.Unboxed.IVector [] a)\r\n In the first argument of `eq1', namely\r\n `(Data.Vector.Unboxed.length :: v a -> Int)'\r\n In the expression:\r\n (Data.Vector.Unboxed.length :: v a -> Int) `eq1` length\r\n In the definition of `prop_length':\r\n prop_length = (Data.Vector.Unboxed.length :: v a -> Int)\r\n `eq1`\r\n length\r\n\r\nProperties.hs:83:25:\r\n No instance for (Data.Vector.Unboxed.IVector [] Bool)\r\n arising from a use of `Data.Vector.Unboxed.and'\r\n at Properties.hs:83:25-29\r\n Possible fix:\r\n add an instance declaration for\r\n (Data.Vector.Unboxed.IVector [] Bool)\r\n In the first argument of `eq1', namely\r\n `(Data.Vector.Unboxed.and :: v Bool -> Bool)'\r\n In the expression:\r\n (Data.Vector.Unboxed.and :: v Bool -> Bool) `eq1` and\r\n In the definition of `prop_and':\r\n prop_and = (Data.Vector.Unboxed.and :: v Bool -> Bool) `eq1` and\r\n\r\nProperties.hs:95:24:\r\n Could not deduce (Eq ([a] -> [a]))\r\n from the context (Eq a,\r\n Ord a,\r\n Eq (v a),\r\n Ord (v a),\r\n Show a,\r\n Arbitrary a,\r\n Model a a,\r\n Show (v a),\r\n Arbitrary (v a),\r\n Model (v a) [a],\r\n Data.Vector.Unboxed.IVector v a,\r\n Show (v Bool),\r\n Arbitrary (v Bool),\r\n Model (v Bool) [Bool],\r\n Data.Vector.Unboxed.IVector v Bool)\r\n arising from a use of `eq2' at Properties.hs:95:24-86\r\n Possible fix:\r\n add (Eq ([a] -> [a])) to the context of\r\n the type signature for `testVersusLists'\r\n or add an instance declaration for (Eq ([a] -> [a]))\r\n In the expression:\r\n (Data.Vector.Unboxed.zipWith :: (a -> a -> a) -> v a -> v a -> v a)\r\n `eq2`\r\n zipWith\r\n In the definition of `prop_zipWith':\r\n prop_zipWith = (Data.Vector.Unboxed.zipWith ::\r\n (a -> a -> a) -> v a -> v a -> v a)\r\n `eq2`\r\n zipWith\r\n In the definition of `testVersusLists':\r\n testVersusLists _ = [testGroup \"Prelude\" prelude_tests,\r\n testGroup \"Data.List\" data_list_tests,\r\n testGroup \"Extras\" extra_tests]\r\n where\r\n prelude_tests = [testProperty \"length\" prop_length, ....]\r\n prop_length = (Data.Vector.Unboxed.length :: v a -> Int)\r\n `eq1`\r\n length\r\n prop_null = (Data.Vector.Unboxed.null :: v a -> Bool) `eq1` null\r\n prop_and = (Data.Vector.Unboxed.and :: v Bool -> Bool) `eq1` and\r\n ....\r\n\r\nProperties.hs:114:25:\r\n Couldn't match expected type `v' against inferred type `[]'\r\n `v' is a rigid type variable bound by\r\n the type signature for `testVersusLists' at Properties.hs:19:28\r\n In the first argument of `eq2', namely\r\n `(enumFromTo :: a -> a -> v a)'\r\n In the expression: (enumFromTo :: a -> a -> v a) `eq2` enumFromTo\r\n In the definition of `prop_enumFromTo':\r\n prop_enumFromTo = (enumFromTo :: a -> a -> v a) `eq2` enumFromTo\r\n\r\nProperties.hs:115:76:\r\n Could not deduce (Enum a)\r\n from the context (Eq a,\r\n Ord a,\r\n Eq (v a),\r\n Ord (v a),\r\n Show a,\r\n Arbitrary a,\r\n Model a a,\r\n Show (v a),\r\n Arbitrary (v a),\r\n Model (v a) [a],\r\n Data.Vector.Unboxed.IVector v a,\r\n Show (v Bool),\r\n Arbitrary (v Bool),\r\n Model (v Bool) [Bool],\r\n Data.Vector.Unboxed.IVector v Bool)\r\n arising from a use of `enumFromThenTo' at Properties.hs:115:76-89\r\n Possible fix:\r\n add (Enum a) to the context of\r\n the type signature for `testVersusLists'\r\n In the second argument of `eq3', namely `enumFromThenTo'\r\n In the expression:\r\n (enumFromThenTo :: a -> a -> a -> v a) `eq3` enumFromThenTo\r\n In the definition of `prop_enumFromThenTo':\r\n prop_enumFromThenTo = (enumFromThenTo :: a -> a -> a -> v a)\r\n `eq3`\r\n enumFromThenTo\r\n\r\nProperties.hs:176:16:\r\n Could not deduce (Model [a] [a])\r\n from the context (Eq a,\r\n Ord a,\r\n Eq (v a),\r\n Ord (v a),\r\n Show a,\r\n Arbitrary a,\r\n Model a a,\r\n Show (v a),\r\n Arbitrary (v a),\r\n Model (v a) [a],\r\n Data.Vector.Unboxed.IVector v a,\r\n Show (v Bool),\r\n Arbitrary (v Bool),\r\n Model (v Bool) [Bool],\r\n Data.Vector.Unboxed.IVector v Bool)\r\n arising from a use of `eq2' at Properties.hs:176:16-71\r\n Possible fix:\r\n add (Model [a] [a]) to the context of\r\n the type signature for `testVersusLists'\r\n or add an instance declaration for (Model [a] [a])\r\n In the expression:\r\n (Data.Vector.Unboxed.snoc :: v a -> a -> v a) `eq2` snoc\r\n In the definition of `prop_snoc':\r\n prop_snoc = (Data.Vector.Unboxed.snoc :: v a -> a -> v a)\r\n `eq2`\r\n snoc\r\n In the definition of `testVersusLists':\r\n testVersusLists _ = [testGroup \"Prelude\" prelude_tests,\r\n testGroup \"Data.List\" data_list_tests,\r\n testGroup \"Extras\" extra_tests]\r\n where\r\n prelude_tests = [testProperty \"length\" prop_length, ....]\r\n prop_length = (Data.Vector.Unboxed.length :: v a -> Int)\r\n `eq1`\r\n length\r\n prop_null = (Data.Vector.Unboxed.null :: v a -> Bool) `eq1` null\r\n prop_and = (Data.Vector.Unboxed.and :: v Bool -> Bool) `eq1` and\r\n ....\r\n}}}\r\n\r\nBut we probably still shouldn't get the ASSERT.","type_of_failure":"OtherFailure","blocking":[]} -->7.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/3014Any type being derived in Haskell 98 module2019-07-07T19:05:53Ziampure@gmail.comAny type being derived in Haskell 98 moduleLoad the attached module with ghci -ignore-dot-ghci, do :browse and observe the type of z, z :: GHC.Prim.Any -\> Double
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ----------------...Load the attached module with ghci -ignore-dot-ghci, do :browse and observe the type of z, z :: GHC.Prim.Any -\> Double
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Any type being derived in Haskell 98 module","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":["any","type"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Load the attached module with ghci -ignore-dot-ghci, do :browse and observe the type of z, z :: GHC.Prim.Any -> Double\r\n\r\n\r\n\r\n ","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3023Wrong inferred type shown2019-07-07T19:05:50ZguestWrong inferred type shownWhen the warning for missing type signatures is turned on the displayed type is sometimes totally bogus.
```
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #-}
module Bug where
class C a b | a -> b, b ...When the warning for missing type signatures is turned on the displayed type is sometimes totally bogus.
```
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #-}
module Bug where
class C a b | a -> b, b -> a where
f :: a -> b
instance C Int Bool where
f = undefined
instance (C a c, C b d) => C (a -> b) (c -> d) where
f = undefined
foo :: Int -> Int
foo = undefined
bar = f foo
```
GHC says:
```
Warning: Definition but no type signature for `bar'
Inferred type: bar :: c -> d
```
The type for bar is, of course, Bool-\>Bool, and nothing else.
> -- Lennart
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | lennart@augustsson.net |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Wrong inferred type shown","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["lennart@augustsson.net"],"type":"Bug","description":"When the warning for missing type signatures is turned on the displayed type is sometimes totally bogus.\r\n\r\n{{{\r\n{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #-}\r\nmodule Bug where\r\n\r\nclass C a b | a -> b, b -> a where\r\n f :: a -> b\r\n\r\ninstance C Int Bool where\r\n f = undefined\r\ninstance (C a c, C b d) => C (a -> b) (c -> d) where\r\n f = undefined\r\n\r\nfoo :: Int -> Int\r\nfoo = undefined\r\n\r\nbar = f foo\r\n}}}\r\nGHC says:\r\n{{{\r\n Warning: Definition but no type signature for `bar'\r\n Inferred type: bar :: c -> d\r\n}}}\r\nThe type for bar is, of course, Bool->Bool, and nothing else.\r\n\r\n -- Lennart\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3043An unrelated definition monomorphizes a type even without the MR2019-07-07T19:05:41ZDeewiantAn unrelated definition monomorphizes a type even without the MRThe following code:
```
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-}
class Id a b | b -> a where id' :: a -> b
instance Id [Char] [Char] where id' = id
cl...The following code:
```
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-}
class Id a b | b -> a where id' :: a -> b
instance Id [Char] [Char] where id' = id
class Fst a where fst' :: a -> String
instance Fst ([Char],a) where fst' = fst
data Void a = Void
void :: (String,a) -> Void a
void _ = Void
fst'' (a,b) =
let x = (id' a, b)
y = void x :: Void Int -- remove this line and the code compiles
in fst' x
```
Results in:
```
arst.hs:18:6:
No instance for (Fst (b, Int))
arising from a use of `fst'' at arst.hs:18:6-11
Possible fix: add an instance declaration for (Fst (b, Int))
In the expression: fst' x
In the expression:
let
x = (id' a, b)
y = void x :: Void Int
in fst' x
In the definition of `fst''':
fst'' (a, b)
= let
x = ...
y = ...
in fst' x
arst.hs:18:11:
No instance for (Id [Char] b)
arising from a use of `x' at arst.hs:18:11
Possible fix: add an instance declaration for (Id [Char] b)
In the first argument of `fst'', namely `x'
In the expression: fst' x
In the expression:
let
x = (id' a, b)
y = void x :: Void Int
in fst' x
```
It seems that the definition of `y` locks down the type of `x` somewhat even though the monomorphism restriction is disabled. If we remove the definition:
```
*Main> :t fst''
fst'' :: (Id t b, Fst (b, t1)) => (t, t1) -> String
```
To be completely honest I'm not sure whether the code should be accepted or not, since `(Id t b, Fst (b, t1))` can't be satisfied. Only the fully monomorphic signature `([Char], Int) -> String`, which is obtained with the definition of `y` in place and the monomorphism restriction enabled, works.
In any case, I think it's a bug that the results of the type check depend on whether `y` is defined or not: surely that shouldn't matter at all, no matter what the end result is.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"An unrelated definition monomorphizes a type even without the MR","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code:\r\n{{{\r\n{-# LANGUAGE NoMonomorphismRestriction #-}\r\n{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-}\r\n\r\nclass Id a b | b -> a where id' :: a -> b\r\ninstance Id [Char] [Char] where id' = id\r\n\r\nclass Fst a where fst' :: a -> String\r\ninstance Fst ([Char],a) where fst' = fst\r\n\r\ndata Void a = Void\r\n\r\nvoid :: (String,a) -> Void a\r\nvoid _ = Void\r\n\r\nfst'' (a,b) =\r\n let x = (id' a, b)\r\n y = void x :: Void Int -- remove this line and the code compiles\r\n in fst' x\r\n}}}\r\nResults in:\r\n{{{\r\narst.hs:18:6:\r\n No instance for (Fst (b, Int))\r\n arising from a use of `fst'' at arst.hs:18:6-11\r\n Possible fix: add an instance declaration for (Fst (b, Int))\r\n In the expression: fst' x\r\n In the expression:\r\n let\r\n x = (id' a, b)\r\n y = void x :: Void Int\r\n in fst' x\r\n In the definition of `fst''':\r\n fst'' (a, b)\r\n = let\r\n x = ...\r\n y = ...\r\n in fst' x\r\n\r\narst.hs:18:11:\r\n No instance for (Id [Char] b)\r\n arising from a use of `x' at arst.hs:18:11\r\n Possible fix: add an instance declaration for (Id [Char] b)\r\n In the first argument of `fst'', namely `x'\r\n In the expression: fst' x\r\n In the expression:\r\n let\r\n x = (id' a, b)\r\n y = void x :: Void Int\r\n in fst' x\r\n}}}\r\n\r\nIt seems that the definition of `y` locks down the type of `x` somewhat even though the monomorphism restriction is disabled. If we remove the definition:\r\n{{{\r\n*Main> :t fst''\r\nfst'' :: (Id t b, Fst (b, t1)) => (t, t1) -> String\r\n}}}\r\n\r\nTo be completely honest I'm not sure whether the code should be accepted or not, since `(Id t b, Fst (b, t1))` can't be satisfied. Only the fully monomorphic signature `([Char], Int) -> String`, which is obtained with the definition of `y` in place and the monomorphism restriction enabled, works.\r\n\r\nIn any case, I think it's a bug that the results of the type check depend on whether `y` is defined or not: surely that shouldn't matter at all, no matter what the end result is.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3064Very long compile times with type functions2019-07-07T19:05:34ZSimon Peyton JonesVery long compile times with type functionsthe attached module is a much reduced version of some type-level assurance
stuff (inspired by the Lightweight Monadic Regions paper) I am trying to
do. I am almost certain that it could be reduced further but it is late and
I want to get...the attached module is a much reduced version of some type-level assurance
stuff (inspired by the Lightweight Monadic Regions paper) I am trying to
do. I am almost certain that it could be reduced further but it is late and
I want to get this off my desk.
Note the 4 test functions, test11 .. test14. The following are timings for
compiling the module only with all test functions commented out, except
respectively, test11, test12, test13, and test14:
```
ben@sarun[1] > time ghc -c Bug2.hs
ghc -c Bug2.hs 1,79s user 0,04s system 99% cpu 1,836 total
ben@sarun[1] > time ghc -c Bug2.hs
ghc -c Bug2.hs 5,87s user 0,14s system 99% cpu 6,028 total
ben@sarun[1] > time ghc -c Bug2.hs
ghc -c Bug2.hs 23,52s user 0,36s system 99% cpu 23,899 total
ben@sarun[1] > time ghc -c Bug2.hs
ghc -c Bug2.hs 102,20s user 1,32s system 97% cpu 1:45,89 total
```
It seems something is scaling very badly. You really don't want to wait for
a version with 20 levels of nesting to compile...
If anyone has a good explanation for this, I'd be grateful.
BTW, I am not at all certain that this is ghc's fault, it may well be my
program, i.e. the constraints are too complex, whatever. I have no idea how
hard it is for the compiler to do all the unification. Also, the problem is
not of much practical relevance, as no sensible program will use more than
a handful levels of nesting.
SLPJ says: let's investigate this once the new solver is done.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ben.franksen@online.de |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Very long compile times with type functions","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"chak"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["ben.franksen@online.de"],"type":"Bug","description":"the attached module is a much reduced version of some type-level assurance\r\nstuff (inspired by the Lightweight Monadic Regions paper) I am trying to\r\ndo. I am almost certain that it could be reduced further but it is late and\r\nI want to get this off my desk.\r\n\r\nNote the 4 test functions, test11 .. test14. The following are timings for\r\ncompiling the module only with all test functions commented out, except\r\nrespectively, test11, test12, test13, and test14:\r\n{{{\r\nben@sarun[1] > time ghc -c Bug2.hs\r\nghc -c Bug2.hs 1,79s user 0,04s system 99% cpu 1,836 total\r\n\r\nben@sarun[1] > time ghc -c Bug2.hs\r\nghc -c Bug2.hs 5,87s user 0,14s system 99% cpu 6,028 total\r\n\r\nben@sarun[1] > time ghc -c Bug2.hs\r\nghc -c Bug2.hs 23,52s user 0,36s system 99% cpu 23,899 total\r\n\r\nben@sarun[1] > time ghc -c Bug2.hs\r\nghc -c Bug2.hs 102,20s user 1,32s system 97% cpu 1:45,89 total\r\n}}}\r\nIt seems something is scaling very badly. You really don't want to wait for\r\na version with 20 levels of nesting to compile...\r\n\r\nIf anyone has a good explanation for this, I'd be grateful.\r\n\r\nBTW, I am not at all certain that this is ghc's fault, it may well be my\r\nprogram, i.e. the constraints are too complex, whatever. I have no idea how\r\nhard it is for the compiler to do all the unification. Also, the problem is\r\nnot of much practical relevance, as no sensible program will use more than\r\na handful levels of nesting.\r\n\r\nSLPJ says: let's investigate this once the new solver is done.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/3102The impossible happened with implicit parameters2019-07-07T19:05:23ZAshley YakeleyThe impossible happened with implicit parameters```
{-# OPTIONS -XImplicitParams -XRankNTypes #-}
module Bug where
t :: forall a. ((?p :: Int) => a) -> String
t _ = "Hello"
f :: (forall a. a -> String) -> Int
f _ = 3
result :: Int
result = f t
```
```
$ ghc -c Bug.hs
ghc: panic! (...```
{-# OPTIONS -XImplicitParams -XRankNTypes #-}
module Bug where
t :: forall a. ((?p :: Int) => a) -> String
t _ = "Hello"
f :: (forall a. a -> String) -> Int
f _ = 3
result :: Int
result = f t
```
```
$ ghc -c Bug.hs
ghc: panic! (the 'impossible' happened)
(GHC version 6.10.1 for x86_64-unknown-linux):
TcTyFuns.flattenType: unexpected PredType
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"The impossible happened with implicit parameters","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\n{-# OPTIONS -XImplicitParams -XRankNTypes #-}\r\nmodule Bug where\r\n\r\nt :: forall a. ((?p :: Int) => a) -> String\r\nt _ = \"Hello\"\r\n\r\nf :: (forall a. a -> String) -> Int\r\nf _ = 3\r\n\r\nresult :: Int\r\nresult = f t\r\n}}}\r\n\r\n{{{\r\n$ ghc -c Bug.hs\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 6.10.1 for x86_64-unknown-linux):\r\n\tTcTyFuns.flattenType: unexpected PredType\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->6.12.1Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/3108Do a better job of solving recursive type-class constraints with functional d...2019-07-07T19:05:21ZSimon Peyton JonesDo a better job of solving recursive type-class constraints with functional dependenciesThis ticket is just to track this interesting thread on the Haskell list, concerning recursive type-class constraints:
http://www.haskell.org/pipermail/haskell/2009-March/021115.html.
We might want to get back to this when the new constr...This ticket is just to track this interesting thread on the Haskell list, concerning recursive type-class constraints:
http://www.haskell.org/pipermail/haskell/2009-March/021115.html.
We might want to get back to this when the new constraint solver is in place.
The question concerns the interaction of solving recursive type-class constraints, where it is important to aggressively apply functional dependencies. Here's Tom Schrijvers's analysis of Ralf's example:
"The cyclic dictionaries approach is a bit fragile. The problem appears to
be here that GHC alternates exhaustive phases of constraint reduction and
functional dependency improvement. The problem is that in your example you
need both for detecting a cycle.
This can happen:
```
C1 Int
==> 3rd C1 inst
C2 Int y, C1 (y,Bool)
==> 1st C1 inst
C2 Int y, C1 y, C1 Bool
==> 2nd C1 inst
C2 Int y, C1 y
==> 3rd C1 inst
C2 Int y, C2 y z, C1 (z,Bool)
==>
...
```
where all the constraint are different because fresh variables are
introduced.
What you want to happen is:
```
C1 Int
==> 3rd C1 inst
C2 Int y, C1 (y,Bool)
==> 1st C1 inst
C2 Int y, C1 y, C1 Bool
==> 2nd C1 inst
C2 Int y, C1 y
==> C2 FD improvement {Int/y} <<<<
C2 Int Int, C1 Int
==> C1 Int cycle detected
C2 Int Int
==> C2 1st instance
{}
```
It seems that you want improvement to happen at a higher priority than GHC
does now."
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Do a better job of solving recursive type-class constraints with functional dependencies","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"6.12 branch","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This ticket is just to track this interesting thread on the Haskell list, concerning recursive type-class constraints:\r\nhttp://www.haskell.org/pipermail/haskell/2009-March/021115.html.\r\nWe might want to get back to this when the new constraint solver is in place.\r\n\r\nThe question concerns the interaction of solving recursive type-class constraints, where it is important to aggressively apply functional dependencies. Here's Tom Schrijvers's analysis of Ralf's example:\r\n\r\n\"The cyclic dictionaries approach is a bit fragile. The problem appears to\r\nbe here that GHC alternates exhaustive phases of constraint reduction and\r\nfunctional dependency improvement. The problem is that in your example you\r\nneed both for detecting a cycle.\r\n\r\nThis can happen:\r\n{{{\r\n C1 Int\r\n ==> 3rd C1 inst\r\n C2 Int y, C1 (y,Bool)\r\n ==> 1st C1 inst\r\n C2 Int y, C1 y, C1 Bool\r\n ==> 2nd C1 inst\r\n C2 Int y, C1 y\r\n ==> 3rd C1 inst\r\n C2 Int y, C2 y z, C1 (z,Bool)\r\n ==>\r\n ...\r\n}}}\r\nwhere all the constraint are different because fresh variables are\r\nintroduced.\r\n\r\nWhat you want to happen is:\r\n{{{\r\n C1 Int\r\n ==> 3rd C1 inst\r\n C2 Int y, C1 (y,Bool)\r\n ==> 1st C1 inst\r\n C2 Int y, C1 y, C1 Bool\r\n ==> 2nd C1 inst\r\n C2 Int y, C1 y\r\n ==> C2 FD improvement {Int/y} <<<<\r\n C2 Int Int, C1 Int\r\n ==> C1 Int cycle detected\r\n C2 Int Int\r\n ==> C2 1st instance\r\n {}\r\n}}}\r\nIt seems that you want improvement to happen at a higher priority than GHC\r\ndoes now.\"\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/3150Overlapping data instances can segfault2019-07-07T19:05:08ZguestOverlapping data instances can segfaultWhen exploring data families for some fast unboxed tuple representation, we came across the following scenario.
```
class Foo a where
data Bar a :: *
instance Foo a where
data Bar a = PBar a
instance Foo () where
data Bar ...When exploring data families for some fast unboxed tuple representation, we came across the following scenario.
```
class Foo a where
data Bar a :: *
instance Foo a where
data Bar a = PBar a
instance Foo () where
data Bar () = PUnit
```
```
GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( Foo.hs, interpreted )
Ok, modules loaded: Main.
*Main> case PUnit of PBar x -> x
Segmentation fault
```
It appears the compiler is allowing the refinement of a into () because they overlap, when it shouldn't.
This is less academic than this example, because it affects doing similar operations to automatically unbox tuples of primitives when possible.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ekmett@gmail.com |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Overlapping data instances can segfault","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["ekmett@gmail.com"],"type":"Bug","description":"When exploring data families for some fast unboxed tuple representation, we came across the following scenario.\r\n\r\n{{{\r\nclass Foo a where\r\n data Bar a :: *\r\n\r\ninstance Foo a where\r\n data Bar a = PBar a\r\n\r\ninstance Foo () where\r\n data Bar () = PUnit\r\n}}}\r\n\r\n{{{\r\n\r\nGHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help\r\nLoading package ghc-prim ... linking ... done.\r\nLoading package integer ... linking ... done.\r\nLoading package base ... linking ... done.\r\n[1 of 1] Compiling Main ( Foo.hs, interpreted )\r\nOk, modules loaded: Main.\r\n*Main> case PUnit of PBar x -> x\r\nSegmentation fault\r\n}}}\r\n\r\nIt appears the compiler is allowing the refinement of a into () because they overlap, when it shouldn't.\r\n\r\nThis is less academic than this example, because it affects doing similar operations to automatically unbox tuples of primitives when possible.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3154Type families bug with data family instances2019-07-07T19:05:07ZtrevorType families bug with data family instancesThis data family definition led to the ability to define a generic cast:
```
{-# LANGUAGE TypeFamilies #-}
data family T a b t
data instance T a b t = L a
data instance T a b () = R b
cast :: a -> b
cast x = let L i = R x in i
get :...This data family definition led to the ability to define a generic cast:
```
{-# LANGUAGE TypeFamilies #-}
data family T a b t
data instance T a b t = L a
data instance T a b () = R b
cast :: a -> b
cast x = let L i = R x in i
get :: IO Char
get = cast ()
```
This bug was observed in ghc version 6.10.1, 6.10.1.20090326 and 6.10.2.
```
% ghci test.hs
GHCi, version 6.10.2: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( test.hs, interpreted )
Ok, modules loaded: Main.
*Main> get
'\4312564'
*Main> get
<interactive>: internal error: stg_ap_v_ret
(GHC version 6.10.2 for x86_64_unknown_linux)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
zsh: abort ghci test.hs
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Type families bug with data family instances","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.2","keywords":["families","type"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This data family definition led to the ability to define a generic cast:\r\n\r\n{{{\r\n{-# LANGUAGE TypeFamilies #-}\r\n\r\ndata family T a b t\r\ndata instance T a b t = L a\r\ndata instance T a b () = R b\r\n\r\ncast :: a -> b\r\ncast x = let L i = R x in i\r\n\r\nget :: IO Char\r\nget = cast ()\r\n}}}\r\n\r\nThis bug was observed in ghc version 6.10.1, 6.10.1.20090326 and 6.10.2.\r\n\r\n{{{\r\n% ghci test.hs\r\nGHCi, version 6.10.2: http://www.haskell.org/ghc/ :? for help\r\nLoading package ghc-prim ... linking ... done.\r\nLoading package integer ... linking ... done.\r\nLoading package base ... linking ... done.\r\n[1 of 1] Compiling Main ( test.hs, interpreted )\r\nOk, modules loaded: Main.\r\n*Main> get\r\n'\\4312564'\r\n*Main> get\r\n<interactive>: internal error: stg_ap_v_ret\r\n (GHC version 6.10.2 for x86_64_unknown_linux)\r\n Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\nzsh: abort ghci test.hs\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3163GADTs should not allow polymorphism in return type2019-07-07T19:05:04ZScott TurnerGADTs should not allow polymorphism in return type```
{-# LANGUAGE GADTs, RankNTypes, ImpredicativeTypes #-}
module Report (eval) where
data Taker a where
Unreached :: Taker (forall s. s)
eval :: a -> Taker a -> (forall t. t)
eval x c = case c of
Unreached -> x
```
I wanted t...```
{-# LANGUAGE GADTs, RankNTypes, ImpredicativeTypes #-}
module Report (eval) where
data Taker a where
Unreached :: Taker (forall s. s)
eval :: a -> Taker a -> (forall t. t)
eval x c = case c of
Unreached -> x
```
I wanted the quantified types to match and the code to get past the type-checker, as it would if the forall type annotations were replaced with any ordinary type. However, ghc reported:
```
Couldn't match expected type `t'
against inferred type `forall s. s'
`t' is a rigid type variable bound by
the type signature for `eval' at ghc_report.hs:7:32
In the expression: x
In a case alternative: Unreached -> x
In the expression: case c of { Unreached -> x }
```
I was unable to get around this problem by adding type annotations. However, I did get around it by using a similar type
```
data Z = Z (forall t.t)
```
instead of the bare forall type.
----
```
(yawl:~/programs/cat_type) scott% ghc -v -dcore-lint ghc_report.hs
Glasgow Haskell Compiler, Version 6.10.1, for Haskell 98, stage 2 booted by GHC version 6.10.1
Using package config file: /usr/lib/ghc-6.10.1/./package.conf
hiding package base-3.0.3.0 to avoid conflict with later version base-4.0.0.0
hiding package filepath-1.1.0.1 to avoid conflict with later version filepath-1.1.0.2
hiding package Cabal-1.6.0.1 to avoid conflict with later version Cabal-1.6.0.2
hiding package QuickCheck-1.2.0.0 to avoid conflict with later version QuickCheck-2.1.0.1
hiding package parsec-2.1.0.1 to avoid conflict with later version parsec-3.0.0
wired-in package ghc-prim mapped to ghc-prim-0.1.0.0
wired-in package integer mapped to integer-0.1.0.0
wired-in package base mapped to base-4.0.0.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0.1.0
wired-in package syb mapped to syb-0.1.0.0
wired-in package template-haskell mapped to template-haskell-2.3.0.0
wired-in package dph-seq[""] not found.
wired-in package dph-par[""] not found.
Hsc static flags: -static
Created temporary directory: /tmp/ghc26608_0
*** Checking old interface for main:Report:
*** Parser:
*** Renamer/typechecker:
ghc_report.hs:9:17:
Couldn't match expected type `t'
against inferred type `forall s. s'
`t' is a rigid type variable bound by
the type signature for `eval' at ghc_report.hs:7:32
In the expression: x
In a case alternative: Unreached -> x
In the expression: case c of { Unreached -> x }
*** Deleting temp files:
Deleting: /tmp/ghc26608_0/ghc26608_0.s
Warning: deleting non-existent /tmp/ghc26608_0/ghc26608_0.s
*** Deleting temp dirs:
Deleting: /tmp/ghc26608_0
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"quantified types fail to match in GADT case","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\n{-# LANGUAGE GADTs, RankNTypes, ImpredicativeTypes #-}\r\n\r\nmodule Report (eval) where\r\n\r\ndata Taker a where\r\n Unreached :: Taker (forall s. s)\r\neval :: a -> Taker a -> (forall t. t)\r\neval x c = case c of\r\n Unreached -> x\r\n}}}\r\nI wanted the quantified types to match and the code to get past the type-checker, as it would if the forall type annotations were replaced with any ordinary type. However, ghc reported:\r\n{{{\r\n Couldn't match expected type `t'\r\n against inferred type `forall s. s'\r\n `t' is a rigid type variable bound by\r\n the type signature for `eval' at ghc_report.hs:7:32\r\n In the expression: x\r\n In a case alternative: Unreached -> x\r\n In the expression: case c of { Unreached -> x }\r\n}}}\r\nI was unable to get around this problem by adding type annotations. However, I did get around it by using a similar type\r\n\r\n{{{\r\ndata Z = Z (forall t.t)\r\n}}}\r\ninstead of the bare forall type.\r\n\r\n----\r\n\r\n{{{\r\n(yawl:~/programs/cat_type) scott% ghc -v -dcore-lint ghc_report.hs\r\nGlasgow Haskell Compiler, Version 6.10.1, for Haskell 98, stage 2 booted by GHC version 6.10.1\r\nUsing package config file: /usr/lib/ghc-6.10.1/./package.conf\r\nhiding package base-3.0.3.0 to avoid conflict with later version base-4.0.0.0\r\nhiding package filepath-1.1.0.1 to avoid conflict with later version filepath-1.1.0.2\r\nhiding package Cabal-1.6.0.1 to avoid conflict with later version Cabal-1.6.0.2\r\nhiding package QuickCheck-1.2.0.0 to avoid conflict with later version QuickCheck-2.1.0.1\r\nhiding package parsec-2.1.0.1 to avoid conflict with later version parsec-3.0.0\r\nwired-in package ghc-prim mapped to ghc-prim-0.1.0.0\r\nwired-in package integer mapped to integer-0.1.0.0\r\nwired-in package base mapped to base-4.0.0.0\r\nwired-in package rts mapped to rts-1.0\r\nwired-in package haskell98 mapped to haskell98-1.0.1.0\r\nwired-in package syb mapped to syb-0.1.0.0\r\nwired-in package template-haskell mapped to template-haskell-2.3.0.0\r\nwired-in package dph-seq[\"\"] not found.\r\nwired-in package dph-par[\"\"] not found.\r\nHsc static flags: -static\r\nCreated temporary directory: /tmp/ghc26608_0\r\n*** Checking old interface for main:Report:\r\n*** Parser:\r\n*** Renamer/typechecker:\r\n\r\nghc_report.hs:9:17:\r\n Couldn't match expected type `t'\r\n against inferred type `forall s. s'\r\n `t' is a rigid type variable bound by\r\n the type signature for `eval' at ghc_report.hs:7:32\r\n In the expression: x\r\n In a case alternative: Unreached -> x\r\n In the expression: case c of { Unreached -> x }\r\n*** Deleting temp files:\r\nDeleting: /tmp/ghc26608_0/ghc26608_0.s\r\nWarning: deleting non-existent /tmp/ghc26608_0/ghc26608_0.s\r\n*** Deleting temp dirs:\r\nDeleting: /tmp/ghc26608_0\r\n\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.12.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/3169Bad occurs-check error message2019-07-07T19:05:02ZSimon Peyton JonesBad occurs-check error messageConsider this:
```
{-# LANGUAGE TypeFamilies, ScopedTypeVariables #-}
module Map where
import Prelude hiding ( lookup )
class Key k where
type Map k :: * -> *
lookup :: k -> Map k elt -> Maybe elt
instance (Key a, Key b) => Key ...Consider this:
```
{-# LANGUAGE TypeFamilies, ScopedTypeVariables #-}
module Map where
import Prelude hiding ( lookup )
class Key k where
type Map k :: * -> *
lookup :: k -> Map k elt -> Maybe elt
instance (Key a, Key b) => Key (a,b) where
type Map (a,b) = MP a b
lookup (a,b) (m :: Map (a,b) elt)
= case lookup a m :: Maybe (Map b elt) of
Just (m2 :: Map b elt) -> lookup b m2 :: Maybe elt
data MP a b elt = MP (Map a (Map b elt))
```
This ought to typecheck, even in the absence of all those type signatures. But alas:
```
Map.hs:13:12:
Occurs check: cannot construct the infinite type: elt = t elt
In the expression: lookup a m :: Maybe (Map b elt)
In the expression:
case lookup a m :: Maybe (Map b elt) of {
Just (m2 :: Map b elt) -> lookup b m2 :: Maybe elt }
```
Simon
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.10.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":"Type families occurs check","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"6.12.1","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"chak"},"version":"6.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider this:\r\n{{{\r\n{-# LANGUAGE TypeFamilies, ScopedTypeVariables #-}\r\nmodule Map where\r\n\r\nimport Prelude hiding ( lookup )\r\n\r\nclass Key k where\r\n type Map k :: * -> *\r\n lookup :: k -> Map k elt -> Maybe elt\r\n\r\ninstance (Key a, Key b) => Key (a,b) where\r\n type Map (a,b) = MP a b\r\n lookup (a,b) (m :: Map (a,b) elt) \r\n = case lookup a m :: Maybe (Map b elt) of\r\n\t Just (m2 :: Map b elt) -> lookup b m2 :: Maybe elt\r\n\r\ndata MP a b elt = MP (Map a (Map b elt))\r\n}}}\r\nThis ought to typecheck, even in the absence of all those type signatures. But alas:\r\n{{{\r\nMap.hs:13:12:\r\n Occurs check: cannot construct the infinite type: elt = t elt\r\n In the expression: lookup a m :: Maybe (Map b elt)\r\n In the expression:\r\n case lookup a m :: Maybe (Map b elt) of {\r\n Just (m2 :: Map b elt) -> lookup b m2 :: Maybe elt }\r\n}}}\r\nSimon","type_of_failure":"OtherFailure","blocking":[]} -->7.0.2https://gitlab.haskell.org/ghc/ghc/-/issues/3190Type checker fails to unify/expand type definitions in certain contexts2019-07-07T19:04:58ZferridderType checker fails to unify/expand type definitions in certain contextsWhen compiling
type TMvar a = TVar (Maybe a)
mynewEmptyMvar :: STM (TMVar a)
mynewEmptyMvar = newTVar Nothing
the type checker complains
Couldn't match expected type `TMVar a'
against inferred type `TVar (Maybe a1)'
Expe...When compiling
type TMvar a = TVar (Maybe a)
mynewEmptyMvar :: STM (TMVar a)
mynewEmptyMvar = newTVar Nothing
the type checker complains
Couldn't match expected type `TMVar a'
against inferred type `TVar (Maybe a1)'
Expected type: STM (TMVar a)
Inferred type: STM (TVar (Maybe a1))
In the expression: newTVar Nothing
In the definition of \`mynewEmptyMvar':
> mynewEmptyMvar = newTVar Nothing
although the definition of TMvar is
type TMvar a = TVar (Maybe a)
This behaviour could not be duplicated in the IO monad.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Type checker fails to unify/expand type definitions in certain contexts","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When compiling \r\n\r\ntype TMvar a = TVar (Maybe a)\r\nmynewEmptyMvar :: STM (TMVar a)\r\nmynewEmptyMvar = newTVar Nothing\r\n\r\nthe type checker complains\r\n\r\n Couldn't match expected type `TMVar a'\r\n against inferred type `TVar (Maybe a1)'\r\n Expected type: STM (TMVar a)\r\n Inferred type: STM (TVar (Maybe a1))\r\n In the expression: newTVar Nothing\r\n In the definition of `mynewEmptyMvar':\r\n mynewEmptyMvar = newTVar Nothing\r\n\r\nalthough the definition of TMvar is\r\ntype TMvar a = TVar (Maybe a)\r\n\r\nThis behaviour could not be duplicated in the IO monad.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3197disambiguating type family instances with qualified names not possible2019-07-07T19:04:56Zclaus.reinke@talk21.comdisambiguating type family instances with qualified names not possibleWhile reading [1](http://www.haskell.org/pipermail/haskell-cafe/2009-April/060665.html), it occured to me that type families could be used to parameterize modules by types. So I modified my example from [2](http://www.haskell.org/piperma...While reading [1](http://www.haskell.org/pipermail/haskell-cafe/2009-April/060665.html), it occured to me that type families could be used to parameterize modules by types. So I modified my example from [2](http://www.haskell.org/pipermail/haskell-cafe/2009-April/060324.html), trying to parameterize two modules `A` and `B` with a shared type `Label` (sharing expressed in `C)`, but ran into a few issues:
```
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE EmptyDataDecls #-}
module LA where
data MyLabel
y = undefined::MyLabel
type family Label a
z = undefined::Label ()
```
```
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE EmptyDataDecls #-}
module LB where
data MyLabel
y = undefined::MyLabel
type family Label a
z = undefined::Label ()
```
```
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
module LC where
import LA
import LB
-- fails = [LA.y,LB.y]
-- express type sharing while leaving actual type open
type family Label a
type instance LA.Label a = LC.Label a
type instance LB.Label a = LC.Label a
ok2 = [LA.z,LB.z]
-- for testing only
-- type instance Label a = () -- can't use with or without qualifier:-(
```
Issues:
- is it really necessary for type families to have at least one index? Without that, type constants could be expressed directly
- uncommenting that last line demonstrates a couple of bugs:
- as it stands, the type instance is ambiguous, but the error message has an incorrect source location (`1:0`)
- trying to disambiguate by defining `type instance LC.Label` results in : "Qualified name in binding position: LC.Label" (note that this is permitted a couple of lines up, so it is related to whether the qualifier refers to the current module or an imported one)
\[the bug is not really in the type checker, but specific to type families..\]
Bug aside, it works (`length ok2` gives two, not an error, as `fail` would).
This could be a useful type family programming pattern (it is probably implicit in the comparisons of SML functors vs Haskell type classes/families, I just don't recall it being made so explicit before, just focussing on type parameterization and sharing)!-)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"disambiguating type family instances with qualified names not possible","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"While reading [http://www.haskell.org/pipermail/haskell-cafe/2009-April/060665.html 1], it occured to me that type families could be used to parameterize modules by types. So I modified my example from [http://www.haskell.org/pipermail/haskell-cafe/2009-April/060324.html 2], trying to parameterize two modules `A` and `B` with a shared type `Label` (sharing expressed in `C)`, but ran into a few issues:\r\n{{{\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE EmptyDataDecls #-}\r\nmodule LA where \r\ndata MyLabel\r\ny = undefined::MyLabel\r\n\r\ntype family Label a\r\nz = undefined::Label ()\r\n}}}\r\n{{{\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE EmptyDataDecls #-}\r\nmodule LB where \r\ndata MyLabel\r\ny = undefined::MyLabel\r\n\r\ntype family Label a\r\nz = undefined::Label ()\r\n}}}\r\n{{{\r\n{-# LANGUAGE UndecidableInstances #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\nmodule LC where\r\nimport LA\r\nimport LB\r\n\r\n-- fails = [LA.y,LB.y]\r\n\r\n-- express type sharing while leaving actual type open\r\ntype family Label a\r\ntype instance LA.Label a = LC.Label a\r\ntype instance LB.Label a = LC.Label a\r\nok2 = [LA.z,LB.z]\r\n\r\n-- for testing only\r\n-- type instance Label a = () -- can't use with or without qualifier:-(\r\n}}}\r\nIssues:\r\n - is it really necessary for type families to have at least one index? Without that, type constants could be expressed directly\r\n\r\n - uncommenting that last line demonstrates a couple of bugs: \r\n\r\n * as it stands, the type instance is ambiguous, but the error message has an incorrect source location (`1:0`)\r\n\r\n * trying to disambiguate by defining `type instance LC.Label` results in : \"Qualified name in binding position: LC.Label\" (note that this is permitted a couple of lines up, so it is related to whether the qualifier refers to the current module or an imported one)\r\n\r\n[the bug is not really in the type checker, but specific to type families..]\r\n\r\nBug aside, it works (`length ok2` gives two, not an error, as `fail` would). \r\n\r\nThis could be a useful type family programming pattern (it is probably implicit in the comparisons of SML functors vs Haskell type classes/families, I just don't recall it being made so explicit before, just focussing on type parameterization and sharing)!-)","type_of_failure":"OtherFailure","blocking":[]} -->6.12.1https://gitlab.haskell.org/ghc/ghc/-/issues/3219functions on records with overloaded names can be given a too-specific type2019-07-07T19:04:50Zdmwitfunctions on records with overloaded names can be given a too-specific typeHere's a reduced test-case showing a discrepancy between the symmetric functions `foo` and `bar`; the inferred type for `foo` is too specific.
```
data T a = A{ m1 :: a } | B{ m1, m2 :: a } | C{ m2 :: a }
-- bar :: (t -> a) -> T t -> T...Here's a reduced test-case showing a discrepancy between the symmetric functions `foo` and `bar`; the inferred type for `foo` is too specific.
```
data T a = A{ m1 :: a } | B{ m1, m2 :: a } | C{ m2 :: a }
-- bar :: (t -> a) -> T t -> T a
bar f x@(A m) = x{m1 = f m}
-- foo :: (a -> a) -> T a -> T a
foo f x@(C m) = x{m2 = f m}
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"functions on records with overloaded names can be given a too-specific type","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here's a reduced test-case showing a discrepancy between the symmetric functions `foo` and `bar`; the inferred type for `foo` is too specific.\r\n\r\n{{{\r\ndata T a = A{ m1 :: a } | B{ m1, m2 :: a } | C{ m2 :: a }\r\n\r\n-- bar :: (t -> a) -> T t -> T a\r\nbar f x@(A m) = x{m1 = f m}\r\n\r\n-- foo :: (a -> a) -> T a -> T a\r\nfoo f x@(C m) = x{m2 = f m}\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3220type variables appearing only in type equality constraints are not generalized2019-07-07T19:04:50Zguesttype variables appearing only in type equality constraints are not generalized```
{-# LANGUAGE TypeFamilies, ScopedTypeVariables#-}
class Foo m where
type Bar m :: *
action :: m -> Bar m -> m
right x m = action m (Right x)
right' :: (Either a b ~ Bar m, Foo m) => b -> m -> m
right' x m = action m (Right...```
{-# LANGUAGE TypeFamilies, ScopedTypeVariables#-}
class Foo m where
type Bar m :: *
action :: m -> Bar m -> m
right x m = action m (Right x)
right' :: (Either a b ~ Bar m, Foo m) => b -> m -> m
right' x m = action m (Right x)
instance Foo Int where
type Bar Int = Either Int Int
action m a = either (*) (+) a m
main = print $ right (1::Int) (3 :: Int)
```
with the above code i get:
```
*Main> :type right
right :: (Either Int b ~ Bar m, Foo m) => b -> m -> m
```
without the main definition i get instead:
```
*Main> :t right
right :: (Either GHC.Prim.Any b ~ Bar m, Foo m) => b -> m -> m
```
while i expect the correct type to be the one of right'.
It looks related to bug #1813
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | sanzhiyan@gmail.com |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"type variables appearing only in type equality constraints are not generalized","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["sanzhiyan@gmail.com"],"type":"Bug","description":"{{{\r\n{-# LANGUAGE TypeFamilies, ScopedTypeVariables#-}\r\n\r\nclass Foo m where\r\n type Bar m :: *\r\n action :: m -> Bar m -> m\r\n\r\nright x m = action m (Right x)\r\n\r\nright' :: (Either a b ~ Bar m, Foo m) => b -> m -> m\r\nright' x m = action m (Right x)\r\n\r\ninstance Foo Int where\r\n type Bar Int = Either Int Int\r\n action m a = either (*) (+) a m\r\n\r\nmain = print $ right (1::Int) (3 :: Int)\r\n}}}\r\nwith the above code i get:\r\n{{{\r\n*Main> :type right\r\n \r\nright :: (Either Int b ~ Bar m, Foo m) => b -> m -> m\r\n}}}\r\nwithout the main definition i get instead:\r\n{{{\r\n*Main> :t right\r\nright :: (Either GHC.Prim.Any b ~ Bar m, Foo m) => b -> m -> m\r\n}}}\r\n\r\nwhile i expect the correct type to be the one of right'.\r\nIt looks related to bug #1813\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.12.1https://gitlab.haskell.org/ghc/ghc/-/issues/3244Associated type panic2019-07-07T19:04:45Zred5_2@hotmail.comAssociated type panicGHC panics with the attached use of associated types. Curiously, if I flatten the nested let-clauses in 'foo', the error goes away.
```
ghc: panic! (the 'impossible' happened)
(GHC version 6.10.1 for x86_64-unknown-linux):
ini...GHC panics with the attached use of associated types. Curiously, if I flatten the nested let-clauses in 'foo', the error goes away.
```
ghc: panic! (the 'impossible' happened)
(GHC version 6.10.1 for x86_64-unknown-linux):
initC: srt_lbl
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Associated type panic","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":["family","type"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC panics with the attached use of associated types. Curiously, if I flatten the nested let-clauses in 'foo', the error goes away.\r\n\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 6.10.1 for x86_64-unknown-linux):\r\n initC: srt_lbl\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3272GHC panics when contexts are put late in function types2019-07-07T19:04:39ZdmwitGHC panics when contexts are put late in function typesHere's a simple transcript from ghci:
```
Prelude> :m + Data.List
Prelude Data.List> :t genericLength :: [a] -> Num b => b
ghc: panic! (the 'impossible' happened)
(GHC version 6.10.3 for x86_64-unknown-linux):
TcTyFuns.flattenType: u...Here's a simple transcript from ghci:
```
Prelude> :m + Data.List
Prelude Data.List> :t genericLength :: [a] -> Num b => b
ghc: panic! (the 'impossible' happened)
(GHC version 6.10.3 for x86_64-unknown-linux):
TcTyFuns.flattenType: unexpected PredType
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC panics when contexts are put late in function types","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here's a simple transcript from ghci:\r\n{{{\r\nPrelude> :m + Data.List\r\nPrelude Data.List> :t genericLength :: [a] -> Num b => b\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 6.10.3 for x86_64-unknown-linux):\r\n\tTcTyFuns.flattenType: unexpected PredType\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->6.12.1https://gitlab.haskell.org/ghc/ghc/-/issues/3278Make lazy unlifted bindings an error2023-08-17T15:12:03ZIan Lynagh <igloo@earth.li>Make lazy unlifted bindings an errorRemove `Opt_WarnLazyUnliftedBindings`, and turn the `warnTc` into an `checkTc`.
Remove `-Werror` from test T2806.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- ...Remove `Opt_WarnLazyUnliftedBindings`, and turn the `warnTc` into an `checkTc`.
Remove `-Werror` from test T2806.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Make lazy unlifted bindings an error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"6.14.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"\r\nRemove `Opt_WarnLazyUnliftedBindings`, and turn the `warnTc` into an `checkTc`.\r\n\r\nRemove `-Werror` from test T2806.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3297Compiler panic on incorrect code (TcTyFuns.flattenType: synonym family in a r...2019-07-07T19:04:31ZhesselinkCompiler panic on incorrect code (TcTyFuns.flattenType: synonym family in a rank-n type)On the following code sample the compiler panics with:
```
ghc: panic! (the 'impossible' happened)
(GHC version 6.11.20090403 for i386-unknown-linux):
TcTyFuns.flattenType: synonym family in a rank-n type
```
I found this when work...On the following code sample the compiler panics with:
```
ghc: panic! (the 'impossible' happened)
(GHC version 6.11.20090403 for i386-unknown-linux):
TcTyFuns.flattenType: synonym family in a rank-n type
```
I found this when working on some code when I made a mistake; the code should not type check, but should probably not crash the compiler either. I simplified the code to:
```
{-# LANGUAGE TypeFamilies
, KindSignatures
, RankNTypes
#-}
type family PF a :: (* -> *) -> * -> *
class Ix a where
type Es a :: * -> *
from :: a -> PF a (Es a) a
crash :: (forall n. Es a n) -> a
crash = from
```
It seems similar to #3101, but that one was about data types. A similar example also seems to be in #1897, but this bug doesn't seem to fit that ticket's description.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Compiler panic on incorrect code (TcTyFuns.flattenType: synonym family in a rank-n type)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"On the following code sample the compiler panics with:\r\n\r\n{{{\r\n ghc: panic! (the 'impossible' happened)\r\n (GHC version 6.11.20090403 for i386-unknown-linux):\r\n\tTcTyFuns.flattenType: synonym family in a rank-n type\r\n}}}\r\n\r\nI found this when working on some code when I made a mistake; the code should not type check, but should probably not crash the compiler either. I simplified the code to:\r\n\r\n{{{\r\n{-# LANGUAGE TypeFamilies\r\n , KindSignatures\r\n , RankNTypes\r\n #-}\r\n\r\ntype family PF a :: (* -> *) -> * -> *\r\n\r\nclass Ix a where\r\n type Es a :: * -> *\r\n from :: a -> PF a (Es a) a\r\n\r\ncrash :: (forall n. Es a n) -> a\r\ncrash = from\r\n}}}\r\n\r\nIt seems similar to #3101, but that one was about data types. A similar example also seems to be in #1897, but this bug doesn't seem to fit that ticket's description.","type_of_failure":"OtherFailure","blocking":[]} -->7.2.1Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/3323panic: funArgTy2019-07-07T19:04:25ZSimon Marlowpanic: funArgTyThe following module crashes GHC 6.11.20090615:
```
module V where
import GHC.IO.Handle.Types
import GHC.IO.Handle.Internals
f :: Handle -> IO ()
f hdl = withHandle_ "" hdl $ \h -> return h{haDevice=undefined}
```
results:
```
$ ghc...The following module crashes GHC 6.11.20090615:
```
module V where
import GHC.IO.Handle.Types
import GHC.IO.Handle.Internals
f :: Handle -> IO ()
f hdl = withHandle_ "" hdl $ \h -> return h{haDevice=undefined}
```
results:
```
$ ghc-testing2 --make V.hs
[1 of 1] Compiling V ( V.hs, V.o )
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 6.11.20090615 for x86_64-unknown-linux):
funArgTy ghc-prim:GHC.Unit.(){(w) tc 40}
```
It imports some internals of the IO library; I tried to reproduce it with a completely standalone module, but failed. The field `haDevice` of `Handle__` has existential type - normally GHC rejects a record update when the field has existential type, but does not in this case, I'm not sure why.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"panic: funArgTy","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"6.12.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following module crashes GHC 6.11.20090615:\r\n\r\n{{{\r\nmodule V where\r\n\r\nimport GHC.IO.Handle.Types\r\nimport GHC.IO.Handle.Internals\r\n\r\nf :: Handle -> IO ()\r\nf hdl = withHandle_ \"\" hdl $ \\h -> return h{haDevice=undefined}\r\n}}}\r\n\r\nresults:\r\n\r\n{{{\r\n$ ghc-testing2 --make V.hs\r\n[1 of 1] Compiling V ( V.hs, V.o )\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 6.11.20090615 for x86_64-unknown-linux):\r\n funArgTy ghc-prim:GHC.Unit.(){(w) tc 40}\r\n}}}\r\n\r\nIt imports some internals of the IO library; I tried to reproduce it with a completely standalone module, but failed. The field `haDevice` of `Handle__` has existential type - normally GHC rejects a record update when the field has existential type, but does not in this case, I'm not sure why.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->6.12.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/3330Type checker hangs2019-07-07T19:04:23ZMartijnVanSteenbergenType checker hangsThe following module causes `ghc --make` and `ghci` to hang. `-ddump-tc-trace` produces output indefinitely.
```
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleContexts #-}
import Generics.MultiRec
import Control.Monad.Writer
data AnyF s...The following module causes `ghc --make` and `ghci` to hang. `-ddump-tc-trace` produces output indefinitely.
```
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleContexts #-}
import Generics.MultiRec
import Control.Monad.Writer
data AnyF s f where
AnyF :: s ix -> f ix -> AnyF s f
children :: HFunctor s (PF s) => s ix -> (PF s) r ix -> [AnyF s r]
children p x = execWriter (hmapM p collect x) where
collect :: (HFunctor s (PF s)) => s ix -> r ix -> Writer [AnyF s r] (r ix)
collect w x = tell [AnyF w x] >> return x
```
Module `Generics.MultiRec` is from Hackage package `multirec-0.4`.
The code contains a type error: if arguments `p` and `collect` are swapped the code compiles fine.
I haven't tried making this example any smaller.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown/Multiple |
| Architecture | Unknown/Multiple |
</details>
<!-- {"blocked_by":[],"summary":"Type checker hangs","status":"New","operating_system":"Unknown/Multiple","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown/Multiple","cc":[""],"type":"Bug","description":"The following module causes `ghc --make` and `ghci` to hang. `-ddump-tc-trace` produces output indefinitely.\r\n\r\n{{{\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE FlexibleContexts #-}\r\n\r\nimport Generics.MultiRec\r\nimport Control.Monad.Writer\r\n\r\ndata AnyF s f where\r\n AnyF :: s ix -> f ix -> AnyF s f\r\n\r\nchildren :: HFunctor s (PF s) => s ix -> (PF s) r ix -> [AnyF s r]\r\nchildren p x = execWriter (hmapM p collect x) where\r\n collect :: (HFunctor s (PF s)) => s ix -> r ix -> Writer [AnyF s r] (r ix)\r\n collect w x = tell [AnyF w x] >> return x\r\n}}}\r\n\r\nModule `Generics.MultiRec` is from Hackage package `multirec-0.4`.\r\n\r\nThe code contains a type error: if arguments `p` and `collect` are swapped the code compiles fine.\r\n\r\nI haven't tried making this example any smaller.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->Manuel M T ChakravartyManuel M T Chakravartyhttps://gitlab.haskell.org/ghc/ghc/-/issues/3383Confluent type family instances confuse the solver2019-07-07T19:04:08ZMiƫtek BakConfluent type family instances confuse the solverWhile attempting to define integer arithmetic using type families, I encountered a problem with the type checker failing to recognize equivalent types:
```
{-# LANGUAGE EmptyDataDecls, TypeFamilies #-}
module WithBug where
data Z
data...While attempting to define integer arithmetic using type families, I encountered a problem with the type checker failing to recognize equivalent types:
```
{-# LANGUAGE EmptyDataDecls, TypeFamilies #-}
module WithBug where
data Z
data S a
data P a b
type family N a
type instance N (P Z a) = P Z a
type instance N (P a Z) = P a Z -- with bug
type instance N (P (S a) (S b)) = N (P a b)
```
```
$ ghci WithBug
*WithBug> :t (undefined :: N (P Z Z)) :: P Z Z
<interactive>:1:1:
Couldn't match expected type `P Z Z'
against inferred type `N (P Z Z)'
In the expression: (undefined :: N (P Z Z)) :: P Z Z
```
Rewriting the problematic instance fixed the problem:
```
{-# LANGUAGE EmptyDataDecls, TypeFamilies #-}
module WithoutBug where
data Z
data S a
data P a b
type family N a
type instance N (P Z a) = P Z a
type instance N (P (S a) Z) = P (S a) Z -- without bug
type instance N (P (S a) (S b)) = N (P a b)
```
```
$ ghci WithoutBug
*WithoutBug> :t (undefined :: N (P Z Z)) :: P Z Z
(undefined :: N (P Z Z)) :: P Z Z :: P Z Z
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Confluent type instances confuse the solver","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.3","keywords":["families","family","instance","instances","type"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"While attempting to define integer arithmetic using type families, I encountered a problem with the type checker failing to recognize equivalent types:\r\n\r\n{{{\r\n{-# LANGUAGE EmptyDataDecls, TypeFamilies #-}\r\n\r\nmodule WithBug where\r\n\r\ndata Z\r\ndata S a\r\ndata P a b\r\n\r\ntype family N a\r\n\r\ntype instance N (P Z a) = P Z a\r\ntype instance N (P a Z) = P a Z -- with bug\r\ntype instance N (P (S a) (S b)) = N (P a b)\r\n}}}\r\n\r\n{{{\r\n$ ghci WithBug\r\n*WithBug> :t (undefined :: N (P Z Z)) :: P Z Z\r\n<interactive>:1:1:\r\n Couldn't match expected type `P Z Z'\r\n against inferred type `N (P Z Z)'\r\n In the expression: (undefined :: N (P Z Z)) :: P Z Z\r\n}}}\r\n\r\nRewriting the problematic instance fixed the problem:\r\n\r\n{{{\r\n{-# LANGUAGE EmptyDataDecls, TypeFamilies #-}\r\n\r\nmodule WithoutBug where\r\n\r\ndata Z\r\ndata S a\r\ndata P a b\r\n\r\ntype family N a\r\n\r\ntype instance N (P Z a) = P Z a\r\ntype instance N (P (S a) Z) = P (S a) Z -- without bug\r\ntype instance N (P (S a) (S b)) = N (P a b)\r\n}}}\r\n\r\n{{{\r\n$ ghci WithoutBug\r\n*WithoutBug> :t (undefined :: N (P Z Z)) :: P Z Z\r\n(undefined :: N (P Z Z)) :: P Z Z :: P Z Z\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3440Improve error message for GADT failures2019-07-07T19:03:53ZSimon Peyton JonesImprove error message for GADT failuresIf you write
```
type family Fam a :: *
data GADT :: * -> * where
GADT :: a -> Fam a -> GADT (Fam a)
unwrap :: GADT (Fam a) -> (a, Fam a)
unwrap (GADT x y) = (x, y)
```
then typechecking `unwrap` should certainly fail. And it ...If you write
```
type family Fam a :: *
data GADT :: * -> * where
GADT :: a -> Fam a -> GADT (Fam a)
unwrap :: GADT (Fam a) -> (a, Fam a)
unwrap (GADT x y) = (x, y)
```
then typechecking `unwrap` should certainly fail. And it does, but with a horrible message:
```
Main.hs:9:21:
Couldn't match expected type `a' against inferred type `a1'
`a' is a rigid type variable bound by
the type signature for `unwrap' at Main.hs:8:20
`a1' is a rigid type variable bound by
the constructor `GADT' at Main.hs:9:8
In the expression: x
In the expression: (x, y)
In the definition of `unwrap': unwrap (GADT x y) = (x, y)
```
It would be better to say something more like:
```
Cannot deduce (a ~ a1) from (Fam a ~ Fam a1)
```
See the thread at [http://thread.gmane.org/gmane.comp.lang.haskell.cafe/62322](http://thread.gmane.org/gmane.comp.lang.haskell.cafe/62322)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Improve error message for GADT failures","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"6.12.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If you write\r\n{{{\r\n type family Fam a :: *\r\n\r\n data GADT :: * -> * where\r\n GADT :: a -> Fam a -> GADT (Fam a)\r\n\r\n unwrap :: GADT (Fam a) -> (a, Fam a)\r\n unwrap (GADT x y) = (x, y)\r\n}}}\r\nthen typechecking `unwrap` should certainly fail. And it does, but with a horrible message:\r\n{{{\r\n Main.hs:9:21:\r\n Couldn't match expected type `a' against inferred type `a1'\r\n `a' is a rigid type variable bound by\r\n the type signature for `unwrap' at Main.hs:8:20\r\n `a1' is a rigid type variable bound by\r\n the constructor `GADT' at Main.hs:9:8\r\n In the expression: x\r\n In the expression: (x, y)\r\n In the definition of `unwrap': unwrap (GADT x y) = (x, y)\r\n}}}\r\nIt would be better to say something more like:\r\n{{{\r\n\tCannot deduce (a ~ a1) from (Fam a ~ Fam a1)\r\n}}}\r\nSee the thread at [http://thread.gmane.org/gmane.comp.lang.haskell.cafe/62322]","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/3460Can't use superclass when type coercions are involved2019-07-07T19:03:46ZryaniCan't use superclass when type coercions are involvedGHC 6.10.4.
```
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module Coercion where
class Nat n where
toInt :: n -> Int
class (Nat (Arity f)) => Model f where
type Arity f
ok :: Model f => f -> Arity f -> Int
ok _ n = toInt...GHC 6.10.4.
```
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module Coercion where
class Nat n where
toInt :: n -> Int
class (Nat (Arity f)) => Model f where
type Arity f
ok :: Model f => f -> Arity f -> Int
ok _ n = toInt n
bug :: (Model f, Arity f ~ n) => f -> n -> Int
bug _ n = toInt n
```
I expect that (Model f) brings (Nat (Arity f)) into scope, and that (Arity f \~ n) means we can derive (Nat n). But the compiler disagrees.
```
Coercion.hs:14:10:
Could not deduce (Nat n) from the context (Arity f ~ n, Model f)
arising from a use of `toInt' at Coercion.hs:14:10-16
Possible fix:
add (Nat n) to the context of the type signature for `bug'
In the expression: toInt n
In the definition of `bug': bug _ n = toInt n
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.10.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Can't use superclass when type coercions are involved","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC 6.10.4.\r\n\r\n{{{\r\n{-# LANGUAGE TypeFamilies, FlexibleContexts #-}\r\nmodule Coercion where\r\n\r\nclass Nat n where\r\n toInt :: n -> Int\r\n\r\nclass (Nat (Arity f)) => Model f where\r\n type Arity f\r\n\r\nok :: Model f => f -> Arity f -> Int\r\nok _ n = toInt n\r\n\r\nbug :: (Model f, Arity f ~ n) => f -> n -> Int\r\nbug _ n = toInt n\r\n}}}\r\n\r\nI expect that (Model f) brings (Nat (Arity f)) into scope, and that (Arity f ~ n) means we can derive (Nat n). But the compiler disagrees.\r\n\r\n{{{\r\nCoercion.hs:14:10:\r\n Could not deduce (Nat n) from the context (Arity f ~ n, Model f)\r\n arising from a use of `toInt' at Coercion.hs:14:10-16\r\n Possible fix:\r\n add (Nat n) to the context of the type signature for `bug'\r\n In the expression: toInt n\r\n In the definition of `bug': bug _ n = toInt n\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->Manuel M T ChakravartyManuel M T Chakravarty