[GHC] #10985: When a "non-exhaustive pattern"-error occurs, output the arguments (if possible)

#10985: When a "non-exhaustive pattern"-error occurs, output the arguments (if possible) -------------------------------------+------------------------------------- Reporter: Watercrystal | Owner: Type: feature | Status: new request | Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Debugging) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #10972 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- For Haskell-beginners like me, "non-exhaustive pattern"-errors occur rather often and they can take some time to fix. While it is obvious that one has made a critical mistake when writing a function, I don't think adding some debugging help would certainly not be bad. I know that this feature only really makes sense when working with types that are instances of `Show`, but then again beginners find themselves working with these types. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10985 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10985: When a "non-exhaustive pattern"-error occurs, output the arguments (if possible) -------------------------------------+------------------------------------- Reporter: Watercrystal | Owner: Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Debugging) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10972 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): I like this idea. In certain easy cases (pattern-matching against a monomorphic type that has an obvious `Show` instance) this would be quite easy to add, I think. Harder cases would be, well, harder. But perhaps the easy case is enough. Note that it would be hard to do a check to see if a type variable is instantiated to a type that has a `Show` instance. Or, instead of using `Show`, we could use whatever GHCi's `:force` command uses to print a value. (This doesn't require a `Show` instance.) It's even conceivable to use a `Show` instance if one is obviously available and fallback to the `:force` thing otherwise. Any volunteers to concretely specify this behavior and implement? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10985#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10985: When a "non-exhaustive pattern"-error occurs, output the arguments (if possible) -------------------------------------+------------------------------------- Reporter: Watercrystal | Owner: Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Debugging) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10972 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by kanetw): A few things to consider: {{{#!hs fix :: (a -> a) -> a fix f = let x = f x in x data Nat = Z | S Nat deriving Show badFunction Z = undefined }}} The error for `badFunction (fix S)` would never terminate, but we can limit the length here. Just a thing to keep in mind, though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10985#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC