on master help sign in
Add something like Haskell's "error" function.
aaaad69David Raymond Christiansen
libs/base/Debug/Error.idrnew file+20
@@ -0,0 +1,20 @@
1+module Debug.Error
2+
3+import Language.Reflection
4+import System
5+
6+||| Terminate the program after printing a user-specified error message.
7+|||
8+||| @ loc The source location to display for the error
9+||| @ message The error to print
10+partial
11+error : {default tactics {sourceLocation} loc : SourceLocation} ->
12+ (message : String) ->
13+ a
14+error {loc = FileLoc filename (line, col) _} message =
15+ believe_me . unsafePerformIO $
16+ do let place = filename ++ " line " ++ show line ++ " column " ++ show col
17+ let message' = place ++ ": " ++ message
18+ putStrLn message'
19+ exit 1
20+
libs/base/base.ipkg+1−1
@@ -4,7 +4,7 @@ opts = "--nobasepkgs --total -i ../prelude"
4modules = System,
4modules = System,
5
5
6 Network.Cgi, Network.Socket,
6 Network.Cgi, Network.Socket,
7− Debug.Trace,
7+ Debug.Error, Debug.Trace,
8
8
9 System.Info,
9 System.Info,
10 System.Concurrency.Raw, System.Concurrency.Process,
10 System.Concurrency.Raw, System.Concurrency.Process,