[GHC] #8450: can't match type Bool with (), but shouldn't have to

#8450: can't match type Bool with (), but shouldn't have to ------------------------------------+------------------------------------- Reporter: dmwit | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- The following (definitely type-incorrect) file: {{{ {-# LANGUAGE ScopedTypeVariables #-} runEffect :: Either Bool r -> r runEffect = undefined run :: forall a. a run = runEffect $ (undefined :: Either a ()) }}} produces the following error: {{{ test.hs:7:7: Couldn't match type `Bool' with `()' Expected type: a Actual type: () In the expression: runEffect $ (undefined :: Either a ()) In an equation for `run': run = runEffect $ (undefined :: Either a ()) }}} This is strange because one of the two types it claims it can't unify (Bool) doesn't appear in either the expected or actual type. Note that removing the ($) gets a different error message that makes it a bit more clear what's going on: {{{ test.hs:7:18: Couldn't match type `Bool' with `()' Expected type: Either Bool a Actual type: Either a () In the first argument of `runEffect', namely `(undefined :: Either a ())' In the expression: runEffect (undefined :: Either a ()) In an equation for `run': run = runEffect (undefined :: Either a ()) }}} So it seems it's trying to unify Bool and () because it's unifying both a with Bool and a with (); however, the usual comments about rigid type variables aren't there, which makes even this error message a bit confusing. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8450 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8450: can't match type Bool with (), but shouldn't have to -------------------------------------+------------------------------------ Reporter: dmwit | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by carter): I hit this problem or something very very close to it, earlier this week. Though in my case it was for type correct code that i had to hoist out as a top level definition to type check.. I'll see if i can repro it in a smaller example. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8450#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8450: can't match type Bool with (), but shouldn't have to -------------------------------------+------------------------------------ Reporter: dmwit | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by simonpj): * cc: dimitris@… (added) Comment: Nice example. (The rest of this is cryptic comments mainly for Dimitrios.) The issue is this. We have a skolem 'a', and two constraints {{{ [w} a ~ Bool [w] a ~ () }}} But because we rewrite wanteds with wanteds, we rewrite to {{{ [w] Bool ~ () }}} which is really quite unhelpful. I'm beginning to wonder: what would happen if we never rewrote a wanted with another wanted? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8450#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8450: can't match type Bool with (), but shouldn't have to
-------------------------------------+------------------------------------
Reporter: dmwit | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Simon Peyton Jones

#8450: can't match type Bool with (), but shouldn't have to
-------------------------------------+------------------------------------
Reporter: dmwit | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Simon Peyton Jones

#8450: can't match type Bool with (), but shouldn't have to ------------------------------------------------+-------------------------- Reporter: dmwit | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: typecheck/should_fail/T8450 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by simonpj): * status: new => closed * testcase: => typecheck/should_fail/T8450 * resolution: => fixed Comment: Thank you for the provocation. Things are much better now. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8450#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8450: can't match type Bool with (), but shouldn't have to
------------------------------------------------+--------------------------
Reporter: dmwit | Owner:
Type: feature request | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Test Case: typecheck/should_fail/T8450 | Difficulty:
Blocking: | Unknown
| Blocked By:
| Related Tickets:
------------------------------------------------+--------------------------
Comment (by Simon Peyton Jones
participants (1)
-
GHC