crisp-errors 1.8.1

Fallibility analysis and CrispError enum synthesis (spec §9)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
type IoError = { message: str }
type ParseError = { line: int }
type Config = { port: int }

read_file(path) -> str ! IoError = throw IoError { message: "not found" }

parse_config(text) -> Config ! ParseError = throw ParseError { line: 0 }

read_config(path) = {
    text := read_file(path)
    parse_config(text)
}

pub main() = {
    cfg := read_config("app.toml") catch _ -> Config { port: 3000 }
    print(cfg)
}