[GHC] #9180: New magic function `staticError`

#9180: New magic function `staticError` ------------------------------------+------------------------------------- Reporter: nomeata | Owner: nomeata Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- While playing games with `RULES`, I had the need for a way to tell the compiler “please spit out an error message”, in my case if list fusion fails where the user explicitly requested for it. Currently I put an `error "List did not fuse"` in the code using a `RULE`, but what I’d really like to do is to put in a `staticError "List did not fuse"` that, if appearing in Core (say, after the final simplification) causes GHC to abort and print this message. (I’m tempted to use type level strings somehow to make sure that the parameter to `staticError` is not present at the value level, and also that the string is easier to obtain. I’ll see.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9180 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9180: New magic function `staticError` -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): I'd be happy with something like this, provided * It's reported by Lint * It has runtime behaviour too (in case you don't run Lint) Of course I could be wrong about this, but making it another Lint check seems right to me. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9180#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9180: New magic function `staticError` -------------------------------------+------------------------------------- Reporter: nomeata | Owner: nomeata Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.2 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by nomeata): Lint is not run by default, is it? In that case I don’t think it would quite cut it. I imagine that `staticError` could be quite a general tool that library authors can use to warn unaware users when they use the library wrongly; a user that deliberately runs the linter is, by definition, not unaware. Another use case would be to have rules that detect certain patterns that the library author knows that do not make sense, by having a rule `foo doNotPassMeToFoo = staticError "Bad user!"` he could prevent that. (Of course we’d like library authors to use the type system for that, but that might not be possible in all cases...) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9180#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9180: New magic function `staticError` -------------------------------------+------------------------------------- Reporter: nomeata | Owner: nomeata Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.2 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): My guess is that you'll be plagued with false positives, but you can try. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9180#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9180: New magic function `staticError` -------------------------------------+------------------------------------- Reporter: nomeata | Owner: nomeata Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9637 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by goldfire): * related: => #9637 Comment: See also #9637 for a type-level variant of this idea. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9180#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC