Forlan Manual


The Messages Module


Synopsis

signature MESSAGES
structure Messages :> MESSAGES

This module contains functions for issuing informational and error messages.


Interface

val messagePP : (unit -> PP.pp list) -> unit
val messageString : (unit -> string list) -> unit
exception Error
val errorPP : (unit -> PP.pp list) -> 'a
val errorString : (unit -> string list) -> 'a
val quiet : (unit -> 'a-> 'a
exception CannotHappen
val cannotHappen : unit -> 'a

Description

messagePP f
applies PP.toString to each element of the result of evaluating f(), and then prints the resulting strings in sequence on the standard output, followed by a newline. Multiple strings are combined—separated by blanks—on single lines, when they fit.

messageString f
evaluates f(), and then prints the resulting strings in sequence on the standard output, followed by a newline. Multiple strings are combined—separated by blanks—on single lines, when they fit.

exception Error
Exception raised when an error message is issued.

errorPP f
is the same as messagePP f, except that Error is raised after messagePP returns.

errorString f
is the same as messageString f, except that Error is raised after messageString returns.

quiet f
evaluates f() in such a way that any calls made by f to messagePP, messageString, errorPP and errorString have no effect (and don't even result in the arguments to messagePP, messageString, errorPP and errorString being called). Whatever f() returns is what quiet returns; or if f() raises an exception, this exception is caught and re-raised by quiet. f()must have no side effects except via calls to messagePP, messageString, errorPP and errorString.

exception CannotHappen
Exception raised by cannotHappen.

cannotHappen()
raises CannotHappen. Used when an expression of some type is needed, but the expression will never be evaluated
Example:

To avoid a nonexaustive match warning message, we could write

  fun f nil       = Messages.cannotHappen()
    | f (x :: xs) = (x, xs)
if we knew that f would never be called with the empty list.



[ Top | Parent | Root | Contents | Index ]

Forlan Version 4.15
Copyright © 2022 Alley Stoughton