GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T19:18:00Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/430Result type signatures and lexically scoped type variables2019-07-07T19:18:00ZnobodyResult type signatures and lexically scoped type variables```
Dear ghc developers,
The ghc documentation (7.4.10.) states that
"A lexically scoped type variable can be bound by:
[...] A result type signature"
However, actually trying to use them causes some
unexpected behavior:
import D...```
Dear ghc developers,
The ghc documentation (7.4.10.) states that
"A lexically scoped type variable can be bound by:
[...] A result type signature"
However, actually trying to use them causes some
unexpected behavior:
import Data.Typeable
foo :: Typeable b => b
foo :: a = typeOf (undefined :: a) `seq` (undefined :: a)
bar :: forall b. Typeable b => b
bar :: a = typeOf (undefined :: a) `seq` (undefined :: a)
baz :: forall a. Typeable a => a
baz :: a = typeOf (undefined :: a) `seq` (undefined :: a)
All three examples give rise to basically the same
error message, namely
Inferred type is less polymorphic than expected
Quantified type variable `b' is mentioned in the
environment:
Scoped type variable `a' = b (bound at:
test135.hs:4:7)
When trying to generalise the type inferred for `foo'
Signature type: forall b. (Typeable b) => b
Type to generalise: b
In the type signature for `foo'
When generalising the type(s) for `foo'
If I understand the documentation correctly, they
should all compile. An especially interesting case is
'baz', where the 'a' from the result type annotation
seems to shadow the a from the type signature (that
doesn't happen with pattern type annotations).
Another curiosity happens if we alpha-rename foo:
qux :: Typeable a => a
qux :: a = typeOf (undefined :: a) `seq` (undefined :: a)
The error message becomes
All of the type variables in the constraint
`Typeable a' are already in scope
(at least one must be universally quantified here)
In the type signature: qux :: (Typeable a) => a
This is just my wild speculation, but does this really
mean that the 'a' in qux's signature is bound by "qux
:: a"?
ghc6.2 gives the same error messages, where of course
'bar' behaves like 'foo' and 'baz' like 'qux'.
Thanks you,
-- Thomas Jäger
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | None |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedInvalid |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Result type signatures and lexically scoped type variables","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedInvalid","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"None","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nDear ghc developers,\n\nThe ghc documentation (7.4.10.) states that\n \"A lexically scoped type variable can be bound by: \n [...] A result type signature\"\n\nHowever, actually trying to use them causes some\nunexpected behavior:\n\nimport Data.Typeable\n\nfoo :: Typeable b => b\nfoo :: a = typeOf (undefined :: a) `seq` (undefined :: a)\n\nbar :: forall b. Typeable b => b\nbar :: a = typeOf (undefined :: a) `seq` (undefined :: a)\n \nbaz :: forall a. Typeable a => a\nbaz :: a = typeOf (undefined :: a) `seq` (undefined :: a)\n\nAll three examples give rise to basically the same\nerror message, namely\n\n Inferred type is less polymorphic than expected\n Quantified type variable `b' is mentioned in the\nenvironment:\n Scoped type variable `a' = b (bound at:\ntest135.hs:4:7)\n When trying to generalise the type inferred for `foo'\n Signature type: forall b. (Typeable b) => b\n Type to generalise: b\n In the type signature for `foo'\n When generalising the type(s) for `foo'\n\nIf I understand the documentation correctly, they\nshould all compile. An especially interesting case is\n'baz', where the 'a' from the result type annotation\nseems to shadow the a from the type signature (that\ndoesn't happen with pattern type annotations).\n\nAnother curiosity happens if we alpha-rename foo:\n\nqux :: Typeable a => a\nqux :: a = typeOf (undefined :: a) `seq` (undefined :: a)\n\nThe error message becomes\n\n All of the type variables in the constraint\n`Typeable a' are already in scope\n (at least one must be universally quantified here)\n In the type signature: qux :: (Typeable a) => a\n\nThis is just my wild speculation, but does this really\nmean that the 'a' in qux's signature is bound by \"qux\n:: a\"?\n\nghc6.2 gives the same error messages, where of course\n'bar' behaves like 'foo' and 'baz' like 'qux'.\n\nThanks you,\n\n-- Thomas Jäger\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/419TcSimplify.lhs:(2093,13)-(2094,38): Non-exhaustive patterns2019-07-07T19:18:02ZnobodyTcSimplify.lhs:(2093,13)-(2094,38): Non-exhaustive patterns```
Dear ghc developers,
instead of giving some kind of 'unresolved overloading'
error message, the following code
% cat Bug.hs
{-# OPTIONS_GHC -fglasgow-exts #-}
module Bug where
class Foo a
instance Foo (a -> b)
foo :: Foo a => a -...```
Dear ghc developers,
instead of giving some kind of 'unresolved overloading'
error message, the following code
% cat Bug.hs
{-# OPTIONS_GHC -fglasgow-exts #-}
module Bug where
class Foo a
instance Foo (a -> b)
foo :: Foo a => a -> ()
foo = undefined
class Bar a r
-- The same happens if we use fundeps:
-- class Bar a r | r -> a
bar :: Bar a r => r -> ()
bar = undefined
test = foo bar
causes ghc to panic:
% ghc Bug.hs
ghc-6.5.20050709: panic! (the `impossible' happened,
GHC version 6.5.20050709):
typecheck/TcSimplify.lhs:(2093,13)-(2094,38):
Non-exhaustive patterns in case
Best regards,
Thomas Jäger
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | None |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"TcSimplify.lhs:(2093,13)-(2094,38): Non-exhaustive patterns","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"None","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nDear ghc developers,\n\ninstead of giving some kind of 'unresolved overloading'\nerror message, the following code\n\n% cat Bug.hs\n{-# OPTIONS_GHC -fglasgow-exts #-}\nmodule Bug where\n\nclass Foo a\ninstance Foo (a -> b)\n\nfoo :: Foo a => a -> ()\nfoo = undefined\n\nclass Bar a r\n-- The same happens if we use fundeps:\n-- class Bar a r | r -> a\n\nbar :: Bar a r => r -> ()\nbar = undefined\n\ntest = foo bar\n\ncauses ghc to panic:\n\n% ghc Bug.hs\nghc-6.5.20050709: panic! (the `impossible' happened,\nGHC version 6.5.20050709):\n typecheck/TcSimplify.lhs:(2093,13)-(2094,38):\nNon-exhaustive patterns in case\n\n\nBest regards,\n\nThomas Jäger\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/416instance of synonym2019-07-07T19:18:03Znobodyinstance of synonym```
The following non-Haskell 98 instance is accepted even
without -fglasgow-exts:
type Foo = Double
instance Bounded Foo
The error message quotes the relevant part of the
Report (The instance type must be of form (T a b c)
where T is ...```
The following non-Haskell 98 instance is accepted even
without -fglasgow-exts:
type Foo = Double
instance Bounded Foo
The error message quotes the relevant part of the
Report (The instance type must be of form (T a b c)
where T is not a synonym, and a,b,c are distinct type
variables) and the code expresses this, but it seems
that type synonyms have already been expanded, so only
non-saturated ones are left at this stage.
ross@soi.city.ac.uk
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | None |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"instance of synonym","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"None","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nThe following non-Haskell 98 instance is accepted even\nwithout -fglasgow-exts:\n\ntype Foo = Double\ninstance Bounded Foo\n\nThe error message quotes the relevant part of the\nReport (The instance type must be of form (T a b c)\nwhere T is not a synonym, and a,b,c are distinct type\nvariables) and the code expresses this, but it seems\nthat type synonyms have already been expanded, so only\nnon-saturated ones are left at this stage.\n\nross@soi.city.ac.uk\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/415Bad location for violation of functional dependency2019-07-07T19:18:03ZmagunterBad location for violation of functional dependency```
The code below produces an error message which gives no
clue
that the actual source of the error is on the line
marked L3
(pointing instead to L1 and L2):
.../BadWarningLoc.hs:1:0:
Couldn't match `S Z' against `Z'
Expect...```
The code below produces an error message which gives no
clue
that the actual source of the error is on the line
marked L3
(pointing instead to L1 and L2):
.../BadWarningLoc.hs:1:0:
Couldn't match `S Z' against `Z'
Expected type: S Z
Inferred type: Z
When using functional dependencies to combine
MinMax a Z Z a,
arising from the instance declaration at
.../BadWarningLoc.hs:10:0
MinMax (S Z) Z _c d,
arising from use of `t' at .../BadWarningLoc.hs:21:8-10
With the type signature, marked L4, uncommented the error
message does indeed point to the culprit, L3.
(With L3 commented-out, the code compiles.)
thanks,
mike
{-# OPTIONS_GHC -fglasgow-exts
-fallow-undecidable-instances #-}
data Z = Z
data S a = S a
n0 = Z
n1 = S n0
class MinMax a b c d | a b -> c d, a c d -> b, b c d -> a
instance MinMax Z Z Z Z
instance MinMax a Z Z a -- L1: wrongly flagged as
error src.
instance MinMax Z b Z b
instance MinMax a b c d => MinMax (S a) (S b) (S c) (S d)
class Extend a b where extend :: a -> b -> b
instance Extend Z b where Z `extend` b = b
instance MinMax a b _c b => Extend a b where _a
`extend` b = b
t :: MinMax a b _c d => a -> b -> d
t _ _ = (undefined :: d)
t1 = n1 `t` n0 -- L2
t2 = n1 `extend` n0 -- L3: uncommenting just this line
produces
-- an error message pointing at L1 and L2
-- with no mention of the real culprit, L3.
--t1 :: S Z -- L4: uncommenting this and L3 produces an
-- error message rightly pointing at L2 and L3.
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Bad location for violation of functional dependency","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"6.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nThe code below produces an error message which gives no\nclue\nthat the actual source of the error is on the line\nmarked L3\n(pointing instead to L1 and L2):\n\n .../BadWarningLoc.hs:1:0:\n Couldn't match `S Z' against `Z'\n Expected type: S Z\n Inferred type: Z\n When using functional dependencies to combine\n MinMax a Z Z a,\n\tarising from the instance declaration at\n.../BadWarningLoc.hs:10:0\n MinMax (S Z) Z _c d,\n\tarising from use of `t' at .../BadWarningLoc.hs:21:8-10\n\nWith the type signature, marked L4, uncommented the error\nmessage does indeed point to the culprit, L3.\n\n(With L3 commented-out, the code compiles.)\n\n\tthanks,\n\tmike\n\n{-# OPTIONS_GHC -fglasgow-exts\n-fallow-undecidable-instances #-}\ndata Z\t\t= Z\ndata S a\t= S a\n\nn0\t= Z\nn1\t= S n0\n\nclass MinMax a b c d | a b -> c d, a c d -> b, b c d -> a\ninstance MinMax Z Z Z Z\t\t\t\t\ninstance MinMax a Z Z a\t -- L1: wrongly flagged as\nerror src.\ninstance MinMax Z b Z b\t\t\t\t\ninstance MinMax a b c d => MinMax (S a) (S b) (S c) (S d)\n\nclass Extend a b where extend :: a -> b -> b\ninstance Extend Z b where Z `extend` b = b\ninstance MinMax a b _c b => Extend a b where _a\n`extend` b = b\n\nt\t:: MinMax a b _c d => a -> b -> d\nt _ _\t= (undefined :: d)\n\nt1 = n1 `t` n0\t -- L2\nt2 = n1 `extend` n0 -- L3: uncommenting just this line\nproduces\n\t\t --\t an error message pointing at L1 and L2\n\t\t --\t with no mention of the real culprit, L3.\n--t1\t:: S Z\t -- L4: uncommenting this and L3 produces an\n\t\t --\terror message rightly pointing at L2 and L3.\n\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/411panic: "Non-exhaustive patterns in function zip_ty_env"2019-07-07T19:18:05Znobodypanic: "Non-exhaustive patterns in function zip_ty_env"```
ghc-6.4: panic! (the `impossible' happened, GHC version
6.4):
types/Type.lhs:(1107,0)-(1108,77):
Non-exhaustive patterns in function zip_ty_env
The same file compiles fine with GHC 6.2.2.
Unfortunately I don't have a small ...```
ghc-6.4: panic! (the `impossible' happened, GHC version
6.4):
types/Type.lhs:(1107,0)-(1108,77):
Non-exhaustive patterns in function zip_ty_env
The same file compiles fine with GHC 6.2.2.
Unfortunately I don't have a small example of this
behaviour. I can send you the whole library if you need
it, but it is not painless to get to this point.
It would be great if you could give me some pointers
about where the bug might lie - it uses MPTC instances,
recursive newtypes and the FFI.
thanks,
peter, peteg at unsw.edu.au
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | None |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"panic: \"Non-exhaustive patterns in function zip_ty_env\"","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"simonpj"},"version":"None","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nghc-6.4: panic! (the `impossible' happened, GHC version\n6.4):\n types/Type.lhs:(1107,0)-(1108,77):\nNon-exhaustive patterns in function zip_ty_env\n\nThe same file compiles fine with GHC 6.2.2.\n\nUnfortunately I don't have a small example of this\nbehaviour. I can send you the whole library if you need\nit, but it is not painless to get to this point.\n\nIt would be great if you could give me some pointers\nabout where the bug might lie - it uses MPTC instances,\nrecursive newtypes and the FFI.\n\nthanks,\npeter, peteg at unsw.edu.au\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/409confusing error2019-07-07T19:18:06Zpimlottconfusing error```
I got a perplexing error message. Here is a concise
example:
t = ((\Just x -> x) :: Maybe a -> a) (Just 1)
Try.hs:1:6:
Couldn't match the rigid variable `a' against
`t -> t1'
`a' is bound by the polym...```
I got a perplexing error message. Here is a concise
example:
t = ((\Just x -> x) :: Maybe a -> a) (Just 1)
Try.hs:1:6:
Couldn't match the rigid variable `a' against
`t -> t1'
`a' is bound by the polymorphic type `forall
a. Maybe a -> a' at Try.hs:1:5-34
Expected type: a
Inferred type: t -> t1
In the expression: (\ Just x -> x) :: Maybe a -> a
In the definition of `t': t = ((\ Just x -> x)
:: Maybe a -> a) (Just 1)
Failed, modules loaded: none.
It seems to be telling me that the whole expression "(\
Just x -> x) ::
Maybe a -> a" was expected to have type a, in
contradiction to the explicit
type annotation it prints out! In the context of a
larger program, this
threw me for a loop. I would have expected
Expected type: Maybe -> a
Inferred type: Maybe -> t -> t1
Even better, if I change the code, I get a helpful
diagnostic:
t = (\Just x -> x) (Just 1)
Try.hs:1:6:
Constructor `Just' should have 1 argument, but
has been given 0
When checking the pattern: Just
In a lambda abstraction: \ Just x -> x
In the definition of `t': t = (\ Just x -> x)
(Just 1)
Failed, modules loaded: none.
Could I get that error in the first example? You could
probably go even further: "(did you forget parentheses
around the pattern?)".
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | None |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"confusing error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"simonpj"},"version":"None","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nI got a perplexing error message. Here is a concise\nexample:\n\n t = ((\\Just x -> x) :: Maybe a -> a) (Just 1)\n \n Try.hs:1:6:\n Couldn't match the rigid variable `a' against\n`t -> t1'\n `a' is bound by the polymorphic type `forall\na. Maybe a -> a' at Try.hs:1:5-34\n Expected type: a\n Inferred type: t -> t1\n In the expression: (\\ Just x -> x) :: Maybe a -> a\n In the definition of `t': t = ((\\ Just x -> x)\n:: Maybe a -> a) (Just 1)\n Failed, modules loaded: none.\n\nIt seems to be telling me that the whole expression \"(\\\nJust x -> x) ::\nMaybe a -> a\" was expected to have type a, in\ncontradiction to the explicit\ntype annotation it prints out! In the context of a\nlarger program, this\nthrew me for a loop. I would have expected\n\n Expected type: Maybe -> a\n Inferred type: Maybe -> t -> t1\n\nEven better, if I change the code, I get a helpful\ndiagnostic:\n\n t = (\\Just x -> x) (Just 1)\n\n Try.hs:1:6:\n Constructor `Just' should have 1 argument, but\nhas been given 0\n When checking the pattern: Just\n In a lambda abstraction: \\ Just x -> x\n In the definition of `t': t = (\\ Just x -> x)\n(Just 1)\n Failed, modules loaded: none.\n\nCould I get that error in the first example? You could\nprobably go even further: \"(did you forget parentheses\naround the pattern?)\".\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/405Typechecker loop and stack overflow in 6.42019-07-07T19:18:08ZekarttunTypechecker loop and stack overflow in 6.4```
The following seems to trigger an loop in the typechecker,
which does from stack overflow after a while.
The example is quite pointless but shows
the bug.
newtype PRef a = PRef a
type Drop1 a = a
class Ref a r | a -> r where readRe...```
The following seems to trigger an loop in the typechecker,
which does from stack overflow after a while.
The example is quite pointless but shows
the bug.
newtype PRef a = PRef a
type Drop1 a = a
class Ref a r | a -> r where readRef :: a -> r
instance Ref (PRef a) (Drop1 a) where readRef (PRef v) = v
Here is a dump from the test (bug.hs contains the above code):
e@yui ~/work/pcl/hpclc $ ghci -v -fglasgow-exts bug.hs
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.4, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Using package config file: /usr/lib/ghc-6.4/package.conf
Using package config file: /home/e/.ghc/i386-linux-6.4/package.conf
Hsc static flags: -static
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
Loading package base-1.0 ... linking ... done.
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
*** Chasing dependencies:
unload: retaining objs []
unload: retaining bcos []
Stable modules:
unload: retaining objs []
unload: retaining bcos []
*** Compiling Main ( bug.hs, interpreted ):
compile: input file bug.hs
*** Checking old interface for Main:
Compiling Main ( bug.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Exception: stack overflow
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | None |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Typechecker loop and stack overflow in 6.4","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"None","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nThe following seems to trigger an loop in the typechecker,\nwhich does from stack overflow after a while.\nThe example is quite pointless but shows\nthe bug.\n\nnewtype PRef a = PRef a\ntype Drop1 a = a\nclass Ref a r | a -> r where readRef :: a -> r\ninstance Ref (PRef a) (Drop1 a) where readRef (PRef v) = v\n\nHere is a dump from the test (bug.hs contains the above code):\ne@yui ~/work/pcl/hpclc $ ghci -v -fglasgow-exts bug.hs \n ___ ___ _\n / _ \\ /\\ /\\/ __(_)\n / /_\\// /_/ / / | | GHC Interactive, version 6.4, for Haskell 98.\n/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n\\____/\\/ /_/\\____/|_| Type :? for help.\n\nUsing package config file: /usr/lib/ghc-6.4/package.conf\nUsing package config file: /home/e/.ghc/i386-linux-6.4/package.conf\nHsc static flags: -static\n*** Parser:\n*** Desugar:\n*** Simplify:\n*** CorePrep:\n*** ByteCodeGen:\nLoading package base-1.0 ... linking ... done.\n*** Parser:\n*** Desugar:\n*** Simplify:\n*** CorePrep:\n*** ByteCodeGen:\n*** Chasing dependencies:\nunload: retaining objs []\nunload: retaining bcos []\nStable modules:\nunload: retaining objs []\nunload: retaining bcos []\n*** Compiling Main ( bug.hs, interpreted ):\ncompile: input file bug.hs\n*** Checking old interface for Main:\nCompiling Main ( bug.hs, interpreted )\n*** Parser:\n*** Renamer/typechecker:\n*** Exception: stack overflow\n\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/393functions without implementations2023-04-01T22:28:21ZGhost Userfunctions without implementations```
Allow to declare a function by only supplying its type
signature.
This feature shall enhance rapid prototyping by fixing
an interface but leaving some functions unimplemented.
Currently this can be (only) simulated by supplying
dumm...```
Allow to declare a function by only supplying its type
signature.
This feature shall enhance rapid prototyping by fixing
an interface but leaving some functions unimplemented.
Currently this can be (only) simulated by supplying
dummy implementations, like
f :: ...
f = undefined
Since it is possible to supply dummy data types by
"data T" (not followed by "="), allowing functions
without implementations seems almost to be a logical
consequence. Surely, the compiler should emit warnings
for missing implementations.
It would be nice if such function declarations via type
signatures could be repeated at any position within a
module.
```IcelandjackIcelandjackhttps://gitlab.haskell.org/ghc/ghc/-/issues/392forall in pattern type sig has changed from 6.2.22019-07-07T19:18:11Zmtullsenforall in pattern type sig has changed from 6.2.2```
------ The program (straight from documentation :-) ------
$ cat Test.hs
test = \(f :: forall a. a -> a) -> (f True,f 'a')
------ Works fine under 6.2.2 ------
tests $ ghci-6.2.2 -fglasgow-exts Test.hs
...
Compiling Test ...```
------ The program (straight from documentation :-) ------
$ cat Test.hs
test = \(f :: forall a. a -> a) -> (f True,f 'a')
------ Works fine under 6.2.2 ------
tests $ ghci-6.2.2 -fglasgow-exts Test.hs
...
Compiling Test ( Test.hs, interpreted )
Ok, modules loaded: Test.
------ Doesn't typecheck under 6.4 ------
$ ghci-6.4 -fglasgow-exts Test.hs
...
Compiling Test ( Test.hs, interpreted )
Test.hs:3:9:
Inferred type is less polymorphic than expected
Quantified type variable `a' is mentioned in the environment:
test :: (a -> a) -> t (bound at Test.hs:3:0)
Expected type: forall a1. a1 -> a1
Inferred type: a -> a
In a lambda abstraction: \ (f :: forall a. a -> a) -> (f True, f 'a')
In the definition of `test': test = \ (f :: forall a. a -> a) -> (f True, f
'a')
...
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"forall in pattern type sig has changed from 6.2.2","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"6.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\n------ The program (straight from documentation :-) ------\n$ cat Test.hs\n\ntest = \\(f :: forall a. a -> a) -> (f True,f 'a')\n\n------ Works fine under 6.2.2 ------\ntests $ ghci-6.2.2 -fglasgow-exts Test.hs\n...\nCompiling Test ( Test.hs, interpreted )\nOk, modules loaded: Test.\n\n------ Doesn't typecheck under 6.4 ------\n$ ghci-6.4 -fglasgow-exts Test.hs\n...\nCompiling Test ( Test.hs, interpreted )\n\nTest.hs:3:9:\n Inferred type is less polymorphic than expected\n Quantified type variable `a' is mentioned in the environment:\n test :: (a -> a) -> t (bound at Test.hs:3:0)\n Expected type: forall a1. a1 -> a1\n Inferred type: a -> a\n In a lambda abstraction: \\ (f :: forall a. a -> a) -> (f True, f 'a')\n In the definition of `test': test = \\ (f :: forall a. a -> a) -> (f True, f \n'a')\n...\n\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/391unjustified deduction error2019-07-07T19:18:11Znobodyunjustified deduction error```
(also sent to glasgow-haskell-users) maeder@tzi.de
the following (reduced) example used to go through with
ghc-6.2.2 but fails with ghc-6.4.
This seems to be a - low priority - bug. (hugs accepts
this module.)
I compile with:
ghc...```
(also sent to glasgow-haskell-users) maeder@tzi.de
the following (reduced) example used to go through with
ghc-6.2.2 but fails with ghc-6.4.
This seems to be a - low priority - bug. (hugs accepts
this module.)
I compile with:
ghc -fglasgow-exts Context.hs
module Context where
class Language a
class Language a => Logic a b | a -> b
class (Language a, Logic b c, Logic d e)
=> Comorph a b c d e | a -> b, a -> d
instance (Comorph a1 b1 c1 d1 e1, Comorph a2 b2 c2 d2 e2)
=> Language (a1, a2)
instance (Comorph a1 b1 c1 d1 e1, Comorph a2 b2 c2 d2 e2)
=> Comorph (a1, a2) b1 c1 d2 e2
-- end of module
ghc-6.4 (or ghc-6.4.1) complains with:
Context.hs:11:0:
Could not deduce (Comorph a2 b2 c21 d2 e21, Comorph
a1 b1 c11 d1 e11)
from the context (Comorph a1 b1 c1 d1 e1, Comorph
a2 b2 c2 d2 e2)
arising from the superclasses of an instance
declaration at
Context.hs:11:0
Probable fix:
add (Comorph a2 b2 c21 d2 e21, Comorph a1 b1 c11
d1 e11)
to the instance declaration superclass context
In the instance declaration for `Comorph (a1, a2)
b1 c1 d2 e2'
If I replace the first instance with
"instance (Language a1, Language a2) => Language (a1, a2)"
then ghc-6.4 is happy.
Cheers Christian
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedInvalid |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"unjustified deduction error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedInvalid","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"6.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\n(also sent to glasgow-haskell-users) maeder@tzi.de\n\nthe following (reduced) example used to go through with\nghc-6.2.2 but fails with ghc-6.4. \n\nThis seems to be a - low priority - bug. (hugs accepts\nthis module.)\nI compile with:\n\nghc -fglasgow-exts Context.hs\n\n\nmodule Context where\n\nclass Language a\nclass Language a => Logic a b | a -> b\nclass (Language a, Logic b c, Logic d e)\n => Comorph a b c d e | a -> b, a -> d\n\ninstance (Comorph a1 b1 c1 d1 e1, Comorph a2 b2 c2 d2 e2)\n => Language (a1, a2)\n\ninstance (Comorph a1 b1 c1 d1 e1, Comorph a2 b2 c2 d2 e2)\n => Comorph (a1, a2) b1 c1 d2 e2\n\n-- end of module\n\nghc-6.4 (or ghc-6.4.1) complains with:\n\nContext.hs:11:0:\n Could not deduce (Comorph a2 b2 c21 d2 e21, Comorph\na1 b1 c11 d1 e11)\n from the context (Comorph a1 b1 c1 d1 e1, Comorph\na2 b2 c2 d2 e2)\n arising from the superclasses of an instance\ndeclaration at\nContext.hs:11:0\n Probable fix:\n add (Comorph a2 b2 c21 d2 e21, Comorph a1 b1 c11\nd1 e11)\n to the instance declaration superclass context\n In the instance declaration for `Comorph (a1, a2)\nb1 c1 d2 e2'\n\n\nIf I replace the first instance with\n\"instance (Language a1, Language a2) => Language (a1, a2)\"\nthen ghc-6.4 is happy.\n\nCheers Christian\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/385Kind error has wrong line2019-07-07T19:18:13ZnobodyKind error has wrong line```
With the attached test file (t.hs) I get the following
result:
--------------------------
cptchaos@motion2 ~ $ ghci-6.4 -fglasgow-exts t.hs
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, versi...```
With the attached test file (t.hs) I get the following
result:
--------------------------
cptchaos@motion2 ~ $ ghci-6.4 -fglasgow-exts t.hs
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version
6.4, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package base-1.0 ... linking ... done.
Compiling Main ( t.hs, interpreted )
t.hs:4:0:
Couldn't match kind `* -> *' against `*'
In the class declaration for `IOMatrixIf'
Failed, modules loaded: none.
Prelude>
------------------------------
but line 4 is correct (it is in fact an example from
the userguide)
-------------------------------------- example file: t.hs
module Main where
class IOMatrixIf (iomat :: * -> *) b where
iomatrix_new :: Int -> Int -> IO (iomat b)
-- ^ creates a matrix with random values ( just mem.
allocation)
iomatrix_rows :: (iomat b) -> Int
iomatrix_cols :: (iomat b) -> Int
iomatrix_read_elem :: (iomat b) -> Int -> Int -> IO b
iomatrix_write_elem :: (iomat b) -> Int -> Int -> b
-> IO ()
hello = "foo" -- junk code may be some lines
-- here is the kind error
type IOMatrix matRep = IOMatrixIf matRep b => (IO matRep)
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Kind error has wrong line","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"6.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\n\nWith the attached test file (t.hs) I get the following\nresult:\n--------------------------\n\ncptchaos@motion2 ~ $ ghci-6.4 -fglasgow-exts t.hs\n ___ ___ _\n / _ \\ /\\ /\\/ __(_)\n / /_\\// /_/ / / | | GHC Interactive, version\n6.4, for Haskell 98.\n/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n\\____/\\/ /_/\\____/|_| Type :? for help.\n\nLoading package base-1.0 ... linking ... done.\nCompiling Main ( t.hs, interpreted )\n\nt.hs:4:0:\n Couldn't match kind `* -> *' against `*'\n In the class declaration for `IOMatrixIf'\nFailed, modules loaded: none.\nPrelude>\n\n------------------------------\n\nbut line 4 is correct (it is in fact an example from\nthe userguide)\n\n-------------------------------------- example file: t.hs\nmodule Main where\n\nclass IOMatrixIf (iomat :: * -> *) b where\n iomatrix_new :: Int -> Int -> IO (iomat b)\n -- ^ creates a matrix with random values ( just mem.\nallocation)\n iomatrix_rows :: (iomat b) -> Int\n iomatrix_cols :: (iomat b) -> Int\n iomatrix_read_elem :: (iomat b) -> Int -> Int -> IO b\n iomatrix_write_elem :: (iomat b) -> Int -> Int -> b\n-> IO ()\n\n\nhello = \"foo\" -- junk code may be some lines\n\n\n-- here is the kind error \ntype IOMatrix matRep = IOMatrixIf matRep b => (IO matRep)\n\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/384internal compiler error: the `impossible' happened2019-07-07T19:18:13Zasamoilovinternal compiler error: the `impossible' happened```
Dear Haskellers,
I've got the following error message during
compilation of the attached Signal.hs file with ghc 6.4
and 6.5.
ghc -c Signal.hs
ghc-6.4: panic! (the `impossible' happened, GHC version
6.4):
types/Type.lhs:(11...```
Dear Haskellers,
I've got the following error message during
compilation of the attached Signal.hs file with ghc 6.4
and 6.5.
ghc -c Signal.hs
ghc-6.4: panic! (the `impossible' happened, GHC version
6.4):
types/Type.lhs:(1107,0)-(1108,77):
Non-exhaustive patterns in function zip_ty_env
Please report it as a compiler bug to
glasgow-haskell-bugs@haskell.org,
or http://sourceforge.net/projects/ghc/.
I spent some time stripping the file to only several
lines :)
Best regards
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"internal compiler error: the `impossible' happened","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"6.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nDear Haskellers,\n\nI've got the following error message during\ncompilation of the attached Signal.hs file with ghc 6.4\nand 6.5.\n\nghc -c Signal.hs\nghc-6.4: panic! (the `impossible' happened, GHC version\n6.4):\n types/Type.lhs:(1107,0)-(1108,77):\nNon-exhaustive patterns in function zip_ty_env\n \n \nPlease report it as a compiler bug to\nglasgow-haskell-bugs@haskell.org,\nor http://sourceforge.net/projects/ghc/.\n\nI spent some time stripping the file to only several\nlines :)\n\nBest regards\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/349Strange GADT behaviour2019-07-07T19:18:21ZjosefsStrange GADT behaviour```
When I try to get the file Bug.hs to type check I get
the strangest error messages from the type checker.
Just a short explanation of the program. It contains
some class declarations capturing some definitions from
category
theory. F...```
When I try to get the file Bug.hs to type check I get
the strangest error messages from the type checker.
Just a short explanation of the program. It contains
some class declarations capturing some definitions from
category
theory. Further down he have a data type for well typed
lambda expressions using GADTs. Finally we have a
function defining the semantics for lambda terms called
'interp'.
First of all the file doesn't compile as it stands,
giving me the following error:
<error>
Bug.hs:54:0:
Quantified type variable `t' is unified with
another quantified type variable terminal
When trying to generalise the type inferred for
`interp'
Signature type: forall terminal
(exp :: * -> * -> *)
(prod :: * -> * -> *)
(arr :: * -> * -> *)
s
t.
(CartesianClosed terminal exp
prod arr) =>
Lambda terminal exp prod s t
-> arr s t
Type to generalise: Lambda t exp prod s t -> arr s t
In the type signature for `interp'
When generalising the type(s) for `interp'
</error>
I don't understand why this is happening.
If I comment out the first line in the interpreter the
module typechecks. But I *want* that first line.
When I wanted to distill the example other funny things
started to happen. When I comment out the cases for Lam
and App in both the data type and the interpreter I get
the following two errors:
<error>
Bug.hs:53:26:
Kind error: `exp' is not applied to enough type
arguments
In the type signature:
interp :: (CartesianClosed terminal exp prod arr) =>
Lambda terminal exp prod s t -> arr s t
Bug.hs:56:22:
Occurs check: cannot construct the infinite type: a
= prod a b
Expected type: arr (prod a b) b
Inferred type: arr (prod (prod a b) b1) b
In the expression: first `comp` (interp (Var v))
In the definition of `interp':
interp (Var (S v)) = first `comp` (interp (Var v))
</error>
```6.8.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/310Data.Generics type error2019-07-07T19:18:32ZnobodyData.Generics type error```
I get a strange type error when using
Data.Generics.Twins - but if I include the text of the
definition in my own file it works!
I attach two files, one type checks, one does not. The
only difference is that I move a definition betw...```
I get a strange type error when using
Data.Generics.Twins - but if I include the text of the
definition in my own file it works!
I attach two files, one type checks, one does not. The
only difference is that I move a definition between
modules.
/Patrik
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Data.Generics type error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"6.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nI get a strange type error when using\nData.Generics.Twins - but if I include the text of the\ndefinition in my own file it works!\n\nI attach two files, one type checks, one does not. The\nonly difference is that I move a definition between\nmodules.\n\n/Patrik\n\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/304ghc hangs during compilation2019-07-07T19:18:33Znobodyghc hangs during compilation```
The following code causes both ghc-6.4.20050209 and
ghc-6.2.2 to hang during compilation.
newtype S = S { unS :: S -> S }
y :: S -> S
y (S f) = g (S g) where g h = f (unS h h)
Thomas Jäger <ThJaeger@gmail.com>
```
<details><summ...```
The following code causes both ghc-6.4.20050209 and
ghc-6.2.2 to hang during compilation.
newtype S = S { unS :: S -> S }
y :: S -> S
y (S f) = g (S g) where g h = f (unS h h)
Thomas Jäger <ThJaeger@gmail.com>
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | None |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedNoReason |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"ghc hangs during compilation","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedNoReason","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"None","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nThe following code causes both ghc-6.4.20050209 and\nghc-6.2.2 to hang during compilation.\n\nnewtype S = S { unS :: S -> S }\n\ny :: S -> S\ny (S f) = g (S g) where g h = f (unS h h)\n\n\nThomas Jäger <ThJaeger@gmail.com>\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/303Rebindable syntax doesn't work as advertised2019-07-07T19:18:33ZnobodyRebindable syntax doesn't work as advertised```
--
-- According to section 7.3.5. Rebindable syntax in the
user's manual
-- this should work (unless I totally misunderstood it).
-- It doesn't.
--
-- Compile with -fno-implicit-prelude
--
-- Lennart
--
import Prelude hiding(Mon...```
--
-- According to section 7.3.5. Rebindable syntax in the
user's manual
-- this should work (unless I totally misunderstood it).
-- It doesn't.
--
-- Compile with -fno-implicit-prelude
--
-- Lennart
--
import Prelude hiding(Monad(..))
class B a where
b :: a
instance B Bool where
b = False
class M m where
return :: a -> m a
(>>=) :: (B a) => m a -> (a -> m b) -> m b
(>>) :: (B a) => m a -> m b -> m b
fail :: String -> m a
p >> q = p >>= \ _ -> q
fail s = error s
instance M Maybe where
return x = Just x
(>>=) = error "bind"
test :: Maybe Bool
test = do
x <- return True
return (x && x)
unJust (Just x) = x
main = print (unJust test)
```nobodynobodyhttps://gitlab.haskell.org/ghc/ghc/-/issues/301GADT constructor constraints ignored2021-09-24T11:49:26Zwolfram_kahlGADT constructor constraints ignored```
Class constraints on GADT constructore appear to be
ignored.
I tried:
data Expr :: * -> * where
Const :: Show a => a -> Expr a
Apply :: Fct a b -> Expr a -> Expr b
and there is no way to define the expected constraint-less
Sho...```
Class constraints on GADT constructore appear to be
ignored.
I tried:
data Expr :: * -> * where
Const :: Show a => a -> Expr a
Apply :: Fct a b -> Expr a -> Expr b
and there is no way to define the expected constraint-less
Show instance --- for details, see Expr0.lhs.
```6.8.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/289class context restrictions in GADT types not assumed2019-07-07T19:18:38Zashley-yclass context restrictions in GADT types not assumed```
I think this should compile:
class C a where
f :: a -> Bool
data T a where
MkT :: (C a) => a -> T a
tf1 :: T Int -> Bool
tf1 (MkT aa) = f aa
tf2 :: T a -> Bool
tf2 (MkT aa) = f aa
tf1 does not give an error, but tf2 do...```
I think this should compile:
class C a where
f :: a -> Bool
data T a where
MkT :: (C a) => a -> T a
tf1 :: T Int -> Bool
tf1 (MkT aa) = f aa
tf2 :: T a -> Bool
tf2 (MkT aa) = f aa
tf1 does not give an error, but tf2 does. The type signature for tf2
should not need a class context, just as there's no "C Int" instance.
ThingEncoding.hs:32:23:
No instance for (C a)
arising from use of `f' at ThingEncoding.hs:32:23
Probable fix: Add (C a) to the type signature(s) for `tf2'
In the definition of `tf2': tf2 (MkT aa) = f aa
```6.8.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/214ghc "panic" - typecheck/TcRnTypes.lhs:2332019-07-07T19:19:07Zfergusghc "panic" - typecheck/TcRnTypes.lhs:233```
I got a ghc "panic" when trying to compile some code
which made use of .hi-boot files. The exact panic
message was
ghc-6.0.1: panic! (the `impossible' happened, GHC
version 6.0.1):
typecheck/TcRnTypes.lhs:233: Missing field...```
I got a ghc "panic" when trying to compile some code
which made use of .hi-boot files. The exact panic
message was
ghc-6.0.1: panic! (the `impossible' happened, GHC
version 6.0.1):
typecheck/TcRnTypes.lhs:233: Missing field in
record construction TcRnTypes.top_errs
This was on a RedHat 8.0 Linux system,
with the following version of ghc:
Glasgow Haskell Compiler, Version 6.0.1, for Haskell
98, compiled by GHC version 6.0
I apologize for the incompleteness of this bug report,
but unfortunately the source code which triggered this
bug is proprietary, so I can't include it here. Sorry!
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"ghc \"panic\" - typecheck/TcRnTypes.lhs:233","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"simonpj"},"version":"6.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nI got a ghc \"panic\" when trying to compile some code\nwhich made use of .hi-boot files. The exact panic\nmessage was\n\nghc-6.0.1: panic! (the `impossible' happened, GHC\nversion 6.0.1):\n typecheck/TcRnTypes.lhs:233: Missing field in\nrecord construction TcRnTypes.top_errs\n\nThis was on a RedHat 8.0 Linux system,\nwith the following version of ghc:\nGlasgow Haskell Compiler, Version 6.0.1, for Haskell\n98, compiled by GHC version 6.0\n\nI apologize for the incompleteness of this bug report,\nbut unfortunately the source code which triggered this\nbug is proprietary, so I can't include it here. Sorry!\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/189Malformed Predicate w/ Template Haskell2019-07-07T19:19:13ZjcastMalformed Predicate w/ Template Haskell```
The following two modules:
--- Cut ---
module ScratchTemplates where
import Language.Haskell.THSyntax
newtype Interaction a = Interaction a deriving Show
ret = Interaction
instance Monad Interaction where
return = Interactio...```
The following two modules:
--- Cut ---
module ScratchTemplates where
import Language.Haskell.THSyntax
newtype Interaction a = Interaction a deriving Show
ret = Interaction
instance Monad Interaction where
return = Interaction
Interaction x >>= f = f x
instance Functor Interaction where
fmap f x = x >>= return . f
interactionT t = tcon (TconName "Interaction") `tapp` t
class Flatten a b | a -> b where
flatten :: a -> b
flattenT :: TypQ -> TypQ -> TypQ
flattenT t t' = tvar "Flatten" `tapp` t `tapp` t
baseType t = sequence [
inst (return []) (flattenT t t)
[val (pvar "flatten") (normal (var "id")) []],
inst (return []) (flattenT (interactionT t)
(interactionT t))
[val (pvar "flatten") (normal (var "id")) []]]
instance Flatten a b =>
Flatten (Interaction (Interaction a))
(Interaction b) where
flatten a = a >>= id >>= return . flatten
module Main where
import Monad
import ScratchTemplates
import Language.Haskell.THSyntax
$(baseType (tcon (Tuple 0)))
instance Flatten String String where
flatten a = a
instance Flatten (Interaction String) (Interaction
String) where
flatten a = a
instance Flatten b c => Combine String b (String, c) where
combine a b = liftM2 (,) a (fmap flatten b)
instance Flatten Int Int where
flatten a = a
class Combine a b c | a b -> c where
combine :: Interaction a -> Interaction b ->
Interaction c
instance Combine () b b where
combine a b = b
instance Flatten b c => Combine Int b (Int, c) where
combine a b = do
x <- a
y <- fmap flatten b
return (x, y)
instance (Flatten b c, Combine a c d) =>
Flatten (Interaction a, Interaction b)
(Interaction d) where
flatten (a, b) = combine a (fmap flatten b)
main = main
--- Cut here ---
loaded into ghci -fglasgow-exts produce the following
error message:
Compiling ScratchTemplates ( ScratchTemplates.hs,
interpreted )
Compiling Main ( scratch.hs, interpreted )
ghc-6.0.1: panic! (the `impossible' happened, GHC
version 6.0.1):
Malformed predicate
Please report it as a compiler bug to
glasgow-haskell-bugs@haskell.org,
or http://sourceforge.net/projects/ghc/.
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Malformed Predicate w/ Template Haskell","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"ResolvedFixed","owner":{"tag":"OwnedBy","contents":"nobody"},"version":"6.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\nThe following two modules:\n\n --- Cut ---\n\nmodule ScratchTemplates where\n\nimport Language.Haskell.THSyntax\n\nnewtype Interaction a = Interaction a deriving Show\n\nret = Interaction\n\ninstance Monad Interaction where\n return = Interaction\n Interaction x >>= f = f x\n\ninstance Functor Interaction where\n fmap f x = x >>= return . f\n\ninteractionT t = tcon (TconName \"Interaction\") `tapp` t\n\nclass Flatten a b | a -> b where\n flatten :: a -> b\n\nflattenT :: TypQ -> TypQ -> TypQ\nflattenT t t' = tvar \"Flatten\" `tapp` t `tapp` t\n\nbaseType t = sequence [\n inst (return []) (flattenT t t)\n [val (pvar \"flatten\") (normal (var \"id\")) []],\n inst (return []) (flattenT (interactionT t)\n(interactionT t))\n [val (pvar \"flatten\") (normal (var \"id\")) []]]\n\ninstance Flatten a b =>\n Flatten (Interaction (Interaction a))\n(Interaction b) where\n flatten a = a >>= id >>= return . flatten\n\nmodule Main where\n\nimport Monad\nimport ScratchTemplates\nimport Language.Haskell.THSyntax\n\n$(baseType (tcon (Tuple 0)))\n\ninstance Flatten String String where\n flatten a = a\n\ninstance Flatten (Interaction String) (Interaction\nString) where\n flatten a = a\n\ninstance Flatten b c => Combine String b (String, c) where\n combine a b = liftM2 (,) a (fmap flatten b)\n\ninstance Flatten Int Int where\n flatten a = a\n\nclass Combine a b c | a b -> c where\n combine :: Interaction a -> Interaction b ->\nInteraction c\n\ninstance Combine () b b where\n combine a b = b\n\ninstance Flatten b c => Combine Int b (Int, c) where\n combine a b = do\n x <- a\n y <- fmap flatten b\n return (x, y)\n\ninstance (Flatten b c, Combine a c d) =>\n Flatten (Interaction a, Interaction b)\n(Interaction d) where\n flatten (a, b) = combine a (fmap flatten b)\n\nmain = main\n\n --- Cut here ---\n\nloaded into ghci -fglasgow-exts produce the following\nerror message:\n\nCompiling ScratchTemplates ( ScratchTemplates.hs,\ninterpreted )\nCompiling Main ( scratch.hs, interpreted )\nghc-6.0.1: panic! (the `impossible' happened, GHC\nversion 6.0.1):\n\tMalformed predicate\n\nPlease report it as a compiler bug to\nglasgow-haskell-bugs@haskell.org,\nor http://sourceforge.net/projects/ghc/.\n\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->nobodynobody