| Copyright | (c) Hangil Kim 2026 Kairon Johnson 2026 Leonidas Sallos 2026 Oscar Abelanet 2026 |
|---|---|
| License | MIT |
| Maintainer | kimhang@oregonstate.edu |
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
LH.Data.Error
Description
This module provides an interface for errors emitted by Layered Haskell, and provides a few formatting helpers to aid in the construction of error messages.
Synopsis
- class LHsError a where
- renderError :: FilePath -> Text -> a -> Text
- buildError :: FilePath -> a -> Errata
- newtype LHsMaxError a = LHsMaxError (Int, [a])
- underline :: FilePath -> LHsSpan -> Text -> Block
- (+>) :: LHsPos -> Int -> LHsSpan
Errors
class LHsError a where Source #
A type representing an error is obligated to implement two functions: renderError and buildError.
renderError displays an error as Text, whereas buildError constructs the error message itself.
Note that renderError has a default definition that will be sufficient in the vast majority of cases.
Minimal complete definition
Methods
Arguments
| :: FilePath | The filepath of the source text. |
| -> Text | The source text itself. |
| -> a | An error. |
| -> Text | The resulting message. |
Renders an error as a message referencing the source text.
Arguments
| :: FilePath | The filepath of the source text. |
| -> a | An error. |
| -> Errata | A pretty-printable representation of the error. This is where the error message itself should be written, in addition to places in the source that it may need to point to. |
Builds the message corresponding to an error.
Instances
| LHsError LHsTextError Source # | |
Defined in LH.Text.Parser.Monad Methods renderError :: FilePath -> Text -> LHsTextError -> Text Source # buildError :: FilePath -> LHsTextError -> Errata Source # | |
| LHsError a => LHsError (LHsMaxError a) Source # | Multiple simultaneous errors up to a maximum are printed,
then elided with the message
|
Defined in LH.Data.Error Methods renderError :: FilePath -> Text -> LHsMaxError a -> Text Source # buildError :: FilePath -> LHsMaxError a -> Errata Source # | |
| LHsError a => LHsError [a] Source # | Multiple simultaneous errors are all printed.
|
Defined in LH.Data.Error | |
Reporting multiple errors
newtype LHsMaxError a Source #
A type for representing a number of errors simultaneously, but only up to a maximum.
Constructors
| LHsMaxError (Int, [a]) |
Instances
| LHsError a => LHsError (LHsMaxError a) Source # | Multiple simultaneous errors up to a maximum are printed,
then elided with the message
|
Defined in LH.Data.Error Methods renderError :: FilePath -> Text -> LHsMaxError a -> Text Source # buildError :: FilePath -> LHsMaxError a -> Errata Source # | |