From f21f0517e9281df7ad7d4c73ec43839bfcf4d932 Mon Sep 17 00:00:00 2001 From: sof <unknown> Date: Tue, 3 Feb 1998 22:47:48 +0000 Subject: [PATCH] [project @ 1998-02-03 22:47:48 by sof] Added entry for assertions --- ghc/docs/users_guide/3-01-notes.vsgml | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ghc/docs/users_guide/3-01-notes.vsgml b/ghc/docs/users_guide/3-01-notes.vsgml index ebb3bb23f66e..c5fd50a0f0b3 100644 --- a/ghc/docs/users_guide/3-01-notes.vsgml +++ b/ghc/docs/users_guide/3-01-notes.vsgml @@ -16,4 +16,34 @@ Changes made since 3.00: <item> imported HBC's quick-sort algorithm from @QSort@ into @List@. +<item> added support for assertions. Conceptually, a new function has + been added to the Prelude with the following type: + + <tscreen> <verb> + assert :: Bool -> a -> a + </verb> </tscreen> + + which has the following behaviour: + + <tscreen> <verb> + assert pred v + | pred = v + | otherwise = error "assertion failed" + </verb> </tscreen> + + However in this form, the practical use of assertions is + limited as no indication is given as to what assertion failed. + So to help out here, ghc will rewrite any uses of <tt/assert/ + to instead invoke the function <tt/assert__/ : + + <tscreen> <verb> + assert__ :: String -> Bool -> a -> a + </verb> </tscreen> + + where the first argument to <tt/assert__/ is a compiler generated string + which encodes the source location of the original <tt/assert/. + + Assertions are a Glasgow extension, so -fglasgow-exts is + needed to use them. + </itemize> -- GitLab