[GHC] #13485: Doesn't warn about variable not in scope

#13485: Doesn't warn about variable not in scope -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: GADTs | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Running this works fine {{{#!hs {-# Language GADTs, TypeFamilies, InstanceSigs #-} data FunC a where (:$) :: FunC (a -> b) -> FunC a -> FunC b Lam :: (FunC a -> FunC b) -> FunC (a -> b) Add :: Num a => FunC (a -> a -> a) class Syntactic a where type Internal a toFunC :: a -> FunC (Internal a) fromFunC :: FunC (Internal a) -> a instance Syntactic (FunC a) where type Internal (FunC a) = a toFunC, fromFunC :: FunC a -> FunC a toFunC ast = ast fromFunC ast = ast instance (Syntactic a, Syntactic b) => Syntactic (a -> b) where type Internal (a -> b) = Internal a -> Internal b toFunC :: (a -> b) -> FunC (Internal a -> Internal b) toFunC f = Lam (toFunC . f . fromFunC) fromFunC :: FunC (Internal a -> Internal b) -> (a -> b) fromFunC f = fromFunC . (f :$) . toFunC add :: Num a => FunC a -> FunC a -> FunC a add = fromFunC Add }}} A folklore for infix expressions is writing `expr a b` as `a &expr$ b`, if I try that '''without''' importing `(Data.Function.&)` I get {{{#!hs -- tghl.hs:29:23-25: error: … -- • Couldn't match type ‘Internal t0’ with ‘a0 -> a0 -> a0’ -- Expected type: FunC (Internal t0) -- Actual type: FunC (a0 -> a0 -> a0) -- The type variables ‘t0’, ‘a0’ are ambiguous -- • In the first argument of ‘fromFunC’, namely ‘Add’ -- In the second argument of ‘(&)’, namely ‘fromFunC Add’ -- In the expression: (&) a fromFunC Add add :: Num a => FunC a -> FunC a -> FunC a add a b = a &fromFunC Add$ b }}} I would expect a `Variable not in scope: (&)` error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13485 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13485: Doesn't warn about variable not in scope -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: worksforme | Keywords: GADTs 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 RyanGlScott): * status: new => closed * resolution: => worksforme Comment: Erm, GHC //does// give you a `Variable not in scope: (&)` error in GHC 8.0.1, 8.0.2 and 8.2. {{{ $ /opt/ghc/8.0.2/bin/ghci Bug2.hs -Wall GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( Bug2.hs, interpreted ) Bug2.hs:29:13: error: Variable not in scope: (&) :: FunC a -> t0 -> FunC a -> FunC a Bug2.hs:29:23: error: • Couldn't match type ‘Internal t0’ with ‘a0 -> a0 -> a0’ Expected type: FunC (Internal t0) Actual type: FunC (a0 -> a0 -> a0) The type variables ‘t0’, ‘a0’ are ambiguous • In the first argument of ‘fromFunC’, namely ‘Add’ In the second argument of ‘(&)’, namely ‘fromFunC Add’ In the expression: (&) a fromFunC Add }}} {{{ $ /opt/ghc/8.2.1/bin/ghci Bug2.hs -Wall GHCi, version 8.2.0.20170321: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( Bug2.hs, interpreted ) Bug2.hs:29:13: error: Variable not in scope: (&) :: FunC a -> t0 -> FunC a -> FunC a | 29 | add a b = a &fromFunC Add$ b | ^ Bug2.hs:29:23: error: • Couldn't match type ‘Internal t0’ with ‘a0 -> a0 -> a0’ Expected type: FunC (Internal t0) Actual type: FunC (a0 -> a0 -> a0) The type variables ‘t0’, ‘a0’ are ambiguous • In the first argument of ‘fromFunC’, namely ‘Add’ In the second argument of ‘(&)’, namely ‘fromFunC Add’ In the expression: (&) a fromFunC Add | 29 | add a b = a &fromFunC Add$ b | ^^^ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13485#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13485: Doesn't warn about variable not in scope -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: worksforme | Keywords: GADTs 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 Iceland_jack): Ah you need to add {{{#!hs {-# OPTIONS_GHC -fdefer-typed-holes #-} }}} I have it in my `.ghci` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13485#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13485: Doesn't warn about variable not in scope -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: worksforme | Keywords: GADTs 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): I'm still not reproducing the error, even with `-fdefer-typed-holes`. {{{ $ ghci Bug.hs -fdefer-typed-holes GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( Bug.hs, interpreted ) Bug.hs:29:13: error: Variable not in scope: (&) :: FunC a -> t0 -> FunC a -> FunC a Bug.hs:29:23: error: • Couldn't match type ‘Internal t0’ with ‘a0 -> a0 -> a0’ Expected type: FunC (Internal t0) Actual type: FunC (a0 -> a0 -> a0) The type variables ‘t0’, ‘a0’ are ambiguous • In the first argument of ‘fromFunC’, namely ‘Add’ In the second argument of ‘(&)’, namely ‘fromFunC Add’ In the expression: (&) a fromFunC Add }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13485#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC