multiarg-0.2.0.0: Combinators to build command line parsers

Safe HaskellSafe-Infered

System.Console.MultiArg.Error

Description

Errors. Parsing a command line when a user has entered it correctly is easy; doing something sensible when an incorrect line has been entered is a bit more difficult. This module exports an Error typeclass, which you can declare instances of in order to have your own type to represent errors. Or you can use SimpleError, which is already an instance of Error.

Synopsis

Documentation

class Error e whereSource

Instances of this typeclass represent multiarg errors. You can declare instances of this typeclass so that you can use your own type for errors. This makes multiarg easy to integrate into your own programs. Then you can also easily add other errors, which you can report from the parsers you build by calling throw.

Methods

parseErr :: Expecting -> Saw -> eSource

Store an error in your Error instance.

data SimpleError Source

A simple type that is already an instance of Error.

Constructors

SimpleError Expecting Saw 

printError :: SimpleError -> TextSource

Generates error messages.

data Expecting Source

Each error consists of two parts: what the parser was expecting to see, and what it actually saw. This type holds what the parser expected to see. If you just want to give some text to be used in an error message, use ExpTextError. To generate a generic error, use ExpOtherFailure.

printExpecting :: Expecting -> TextSource

Generates an error message from an Expecting.

printSaw :: Saw -> TextSource

Generates error messages from a Saw.