[GHC] #13734: Code requires ScopedTypeVariables, possibly erroneously

#13734: Code requires ScopedTypeVariables, possibly erroneously -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 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: -------------------------------------+------------------------------------- This doesn't work without `ScopedTypeVariables`, but shouldn't it? (on `8.0.1`, 8.2.0.20170507`) {{{#!hs {-# Language ScopedTypeVariables, TypeApplications, AllowAmbiguousTypes, InstanceSigs #-} class Sized f where size :: Int instance Sized Int where size :: Int size = 42 instance (Sized a, Sized b) => Sized (a, b) where size :: Int size = size @a + size @b }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13734 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13734: Code requires ScopedTypeVariables, possibly erroneously -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 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 RyanGlScott): This looks like expected behavior to me. After all, this won't typecheck without `ScopedTypeVariables` either: {{{#!hs {-# Language ScopedTypeVariables, TypeApplications, InstanceSigs #-} import Data.Proxy class Sized f where size :: proxy f -> Int instance Sized Int where size :: proxy Int -> Int size _ = 42 instance (Sized a, Sized b) => Sized (a, b) where size :: proxy (a, b) -> Int size _ = size (Proxy :: Proxy a) + size (Proxy :: Proxy b) }}} I don't see why `TypeApplications` would be different in that regard. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13734#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13734: Code requires ScopedTypeVariables, possibly erroneously -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: invalid | 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: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: Without `ScopedTypeVariables` the type variables mentioned in are, well, not in scope. (As specified in the Haskell 2010 report.) We get {{{ T13734.hs:16:18: error: Not in scope: type variable ‘a’ | 16 | size _ = size @a + size @b | ^ }}} So I agree with Ryan. Please re-open if you disagree. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13734#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC