Skip to content

Commit

Permalink
Use new comment syntax in Assert
Browse files Browse the repository at this point in the history
  • Loading branch information
forell committed Dec 12, 2024
1 parent cef6ac9 commit 18b0324
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/Base/Assert.fram
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
(* This file is part of DBL, released under MIT license.
* See LICENSE for details.
*)
{# This file is part of DBL, released under MIT license.
# See LICENSE for details.
#}

import open Types

(** Abort the program with given message.
{## Abort the program with given message.

Note that this function is pure. In correct programs, this function should
be never called at runtime, but it can be used to appease the type-checker.
never be called at runtime, but it can be used to appease the type-checker.
Use this function only in impossible match clauses or in case of gross
violation of function preconditions (e.g., division by zero). *)
violation of function preconditions (e.g., division by zero).
#}
pub let runtimeError {type T} =
(extern dbl_runtimeError : String ->[] T)

(** Explicitly assert, that this case is impossible *)
{## Explicitly assert that this case is impossible.
#}
pub let impossible {?msg : String} () =
runtimeError
match msg with
| None => "Assertion failed"
| Some msg => msg
end

(** Assert, that given condition should always hold. *)
{## Assert that given condition should always hold.
#}
pub let assert {?msg} b =
if b then ()
else
Expand Down

0 comments on commit 18b0324

Please sign in to comment.