# Assert functions

## `lib.asserts.assertMsg`

assertMsg :: Bool -> String -> Bool

Print a trace message if `pred` is false.

Intended to be used to augment asserts with helpful error messages.

`pred`

  Condition under which the `msg` should not be printed.

`msg`

  Message to print.

### Printing when the predicate is false

    assert lib.asserts.assertMsg ("foo" == "bar") "foo is not bar, silly"
    stderr> trace: foo is not bar, silly
    stderr> assert failed

## `lib.asserts.assertOneOf`

assertOneOf :: String -> String -> StringList -> Bool

Specialized `asserts.assertMsg` for checking if `val` is one of the elements of `xs`. Useful for checking enums.

`name`

  The name of the variable the user entered `val` into, for inclusion in the error message.

`val`

  The value of what the user provided, to be compared against the values in `xs`.

`xs`

  The list of valid values.

### Ensuring a user provided a possible value

    let sslLibrary = "bearssl";
    in lib.asserts.assertOneOf "sslLibrary" sslLibrary [ "openssl" "bearssl" ];
    => false
    stderr> trace: sslLibrary must be one of "openssl", "libressl", but is: "bearssl"