unison/unison-src/transcripts/todo-bug-builtins.output.md

103 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

# The `todo` and `bug` builtin
`todo` and `bug` have type `a -> b`. They take a message or a value of type `a` and crash during runtime displaying `a` in ucm.
``` unison
> todo "implement me later"
```
``` ucm
Loading changes detected in scratch.u.
scratch.u changed.
2020-04-08 21:25:19 +03:00
Now evaluating any watch expressions (lines starting with
`>`)... Ctrl+C cancels.
💔💥
I've encountered a call to builtin.todo with the following
value:
2019-12-10 08:21:04 +03:00
"implement me later"
Stack trace:
todo
#qe5e1lcfn8
```
``` unison
> bug "there's a bug in my code"
```
``` ucm
Loading changes detected in scratch.u.
scratch.u changed.
2020-04-08 21:25:19 +03:00
Now evaluating any watch expressions (lines starting with
`>`)... Ctrl+C cancels.
💔💥
I've encountered a call to builtin.bug with the following
value:
2019-12-10 08:21:04 +03:00
"there's a bug in my code"
Stack trace:
bug
#m67hcdcoda
```
## Todo
2019-12-11 18:56:07 +03:00
`todo` is useful if you want to come back to a piece of code later but you want your project to compile.
``` unison
complicatedMathStuff x = todo "Come back and to something with x here"
```
``` ucm
Loading changes detected in scratch.u.
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
2020-10-22 05:47:25 +03:00
complicatedMathStuff : x -> r
```
## Bug
`bug` is used to indicate that a particular branch is not expected to execute.
``` unison
test = match true with
true -> "Yay"
false -> bug "Wow, that's unexpected"
```
``` ucm
Loading changes detected in scratch.u.
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
2019-12-10 08:21:04 +03:00
test : Text
```