[GHC] #13451: Bind implicit parameter in patterns

#13451: Bind implicit parameter in patterns -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple ImplicitParams | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Is there any reason why variables for `ImplicitParams` can't be bound in patterns, so you can write {{{#!hs data Exp = Val Int | Op Op Exp Exp data Op = Add | Mul data Protect where Protect :: (?op :: Op) => Protect protectOp :: Exp -> Maybe Protect protectOp (Op ?op _ _) = Just Protect protectOp _ = Nothing }}} instead of {{{#!hs protectOp :: Exp -> Maybe Protect protectOp (Op op _ _) = Just Protect where ?op = op protectOp _ = Nothing }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13451 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13451: Bind implicit parameter in patterns -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | ImplicitParams 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): Also applies here maybe, {{{#!hs greet :: (?name :: String) => String greet = "hi " ++ ?name -- t1QY.hs:12:4-8: error: Parse error in pattern: ?name -- Compilation failed. a :: String a = greet where (?name, False) = ("Iceland_jack", True) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13451#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13451: Bind implicit parameter in patterns -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: task | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: invalid | Keywords: | ImplicitParams Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15456 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => invalid * related: => #15456 Comment: (Copying the resolution from #15456, which is a duplicate of this ticket.) This is a worthwhile idea to consider, but it should really go via the https://github.com/ghc-proposals/ghc-proposals process, as it's a user- facing language change. I'm closing this ticket as invalid, but I really do encourage you to post a proposal. That process is working well and has incorporated quite a few changes into the language. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13451#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC