Skip to content
  • Matthew Pickering's avatar
    e1bbd368
    Allow configuration of error message printing · e1bbd368
    Matthew Pickering authored and sheaf's avatar sheaf committed
    This MR implements the idea of #21731 that the printing of a diagnostic
    method should be configurable at the printing time.
    
    The interface of the `Diagnostic` class is modified from:
    
    ```
    class Diagnostic a where
      diagnosticMessage :: a -> DecoratedSDoc
      diagnosticReason  :: a -> DiagnosticReason
      diagnosticHints   :: a -> [GhcHint]
    ```
    
    to
    
    ```
    class Diagnostic a where
      type DiagnosticOpts a
      defaultDiagnosticOpts :: DiagnosticOpts a
      diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
      diagnosticReason  :: a -> DiagnosticReason
      diagnosticHints   :: a -> [GhcHint]
    ```
    
    and so each `Diagnostic` can implement their own configuration record
    which can then be supplied by a client in order to dictate how to print
    out the error message.
    
    At the moment this only allows us to implement #21722 nicely but in
    future it is more natural to separate the configuration of how much
    information we put into an error message and how much we decide to print
    out of it.
    
    Updates Haddock submodule
    e1bbd368
    Allow configuration of error message printing
    Matthew Pickering authored and sheaf's avatar sheaf committed
    This MR implements the idea of #21731 that the printing of a diagnostic
    method should be configurable at the printing time.
    
    The interface of the `Diagnostic` class is modified from:
    
    ```
    class Diagnostic a where
      diagnosticMessage :: a -> DecoratedSDoc
      diagnosticReason  :: a -> DiagnosticReason
      diagnosticHints   :: a -> [GhcHint]
    ```
    
    to
    
    ```
    class Diagnostic a where
      type DiagnosticOpts a
      defaultDiagnosticOpts :: DiagnosticOpts a
      diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
      diagnosticReason  :: a -> DiagnosticReason
      diagnosticHints   :: a -> [GhcHint]
    ```
    
    and so each `Diagnostic` can implement their own configuration record
    which can then be supplied by a client in order to dictate how to print
    out the error message.
    
    At the moment this only allows us to implement #21722 nicely but in
    future it is more natural to separate the configuration of how much
    information we put into an error message and how much we decide to print
    out of it.
    
    Updates Haddock submodule
Loading