[GHC] #13662: Type inference fails in connection with TypeFamilies, 'let', type equalities ...

#13662: Type inference fails in connection with TypeFamilies, 'let', type equalities ... -------------------------------------+------------------------------------- Reporter: Lemming | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1-rc1 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The following example is a pretty involved use of type equality. It was accepted by GHC-8.0 and before, but GHC-8.2.0.20170505 cannot infer a type. {{{ $ cat MonomorphismEquality.hs {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} module MonomorphismEquality (run) where newtype Value a = Value a type family Repr (f :: * -> *) a :: * type instance Repr f Int = f Int class (Repr Value i ~ Value ir) => Native i ir where instance Native Int Int where fromInt :: (Native i ir) => i -> a fromInt = undefined apply :: (Int -> a -> a) -> a -> a apply weight = id run :: Float -> Float run = let weight = \clip v -> fromInt clip * v in apply weight $ ghc-8.0.2 -Wall MonomorphismEquality.hs [1 of 1] Compiling MonomorphismEquality ( MonomorphismEquality.hs, MonomorphismEquality.o ) MonomorphismEquality.hs:6:19: warning: [-Wunused-top-binds] Defined but not used: data constructor ‘Value’ MonomorphismEquality.hs:20:7: warning: [-Wunused-matches] Defined but not used: ‘weight’ $ ghc-8.2.0.20170505 -Wall MonomorphismEquality.hs [1 of 1] Compiling MonomorphismEquality ( MonomorphismEquality.hs, MonomorphismEquality.o ) MonomorphismEquality.hs:24:28: error: • Ambiguous type variable ‘ir0’ arising from a use of ‘fromInt’ prevents the constraint ‘(Native Int ir0)’ from being solved. Probable fix: use a type annotation to specify what ‘ir0’ should be. These potential instance exist: instance Native Int Int -- Defined at MonomorphismEquality.hs:13:10 • In the first argument of ‘(*)’, namely ‘fromInt clip’ In the expression: fromInt clip * v In the expression: \ clip v -> fromInt clip * v | 24 | let weight = \clip v -> fromInt clip * v | ^^^^^^^^^^^^ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13662 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13662: Type inference fails in connection with TypeFamilies, 'let', type equalities ... -------------------------------------+------------------------------------- Reporter: Lemming | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1-rc1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Ah good. I know what is going on here. Fix coming. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13662#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13662: Type inference fails in connection with TypeFamilies, 'let', type
equalities ...
-------------------------------------+-------------------------------------
Reporter: Lemming | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.2.1-rc1
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#13662: Type inference fails in connection with TypeFamilies, 'let', type equalities ... -------------------------------------+------------------------------------- Reporter: Lemming | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1-rc1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_compile/T13662 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => indexed-types/should_compile/T13662 Comment: Thanks for the report. Worth merging when convenient. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13662#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13662: Type inference fails in connection with TypeFamilies, 'let', type equalities ... -------------------------------------+------------------------------------- Reporter: Lemming | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.2.1-rc1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_compile/T13662 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13662#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13662: Type inference fails in connection with TypeFamilies, 'let', type equalities ... -------------------------------------+------------------------------------- Reporter: Lemming | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.2.1-rc1 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_compile/T13662 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged with b6f73dd7bacec13a7a8898fb0843efc10d4405e5. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13662#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13662: Type inference fails in connection with TypeFamilies, 'let', type equalities ... -------------------------------------+------------------------------------- Reporter: Lemming | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.2.1-rc1 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_compile/T13662 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Lemming): Indeed, my problem is gone in ghc-8.2.0.20170517, thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13662#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC