LayeredHaskell-0.1.0.0: A friendly layered implementation of a subset of Haskell.
Copyright(c) Hangil Kim 2026
Kairon Johnson 2026
Leonidas Sallos 2026
Oscar Abelanet 2026
LicenseMIT
Maintainerkimhang@oregonstate.edu
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

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

buildError

Methods

renderError Source #

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.

buildError Source #

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

Instances details
LHsError LHsTextError Source # 
Instance details

Defined in LH.Text.Parser.Monad

LHsError a => LHsError (LHsMaxError a) Source #

Multiple simultaneous errors up to a maximum are printed, then elided with the message "...and \(m-n\) more errors" if the number of errors \(m\) exceeds the maximum \(n\).

renderError prints the errors separately, while buildError merges them all into one.

Instance details

Defined in LH.Data.Error

LHsError a => LHsError [a] Source #

Multiple simultaneous errors are all printed.

renderError prints the errors separately, while buildError merges them all into one.

Instance details

Defined in LH.Data.Error

Methods

renderError :: FilePath -> Text -> [a] -> Text Source #

buildError :: FilePath -> [a] -> Errata Source #

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

Instances details
LHsError a => LHsError (LHsMaxError a) Source #

Multiple simultaneous errors up to a maximum are printed, then elided with the message "...and \(m-n\) more errors" if the number of errors \(m\) exceeds the maximum \(n\).

renderError prints the errors separately, while buildError merges them all into one.

Instance details

Defined in LH.Data.Error

Formatting errors

underline Source #

Arguments

:: FilePath

The filepath of the source text.

-> LHsSpan

The source span to underline.

-> Text

A label.

-> Block 

Underlines a single-line span alongside a label.

(+>) :: LHsPos -> Int -> LHsSpan infix 5 Source #

Constructs a span of a given length starting at a given position.