union IntResult {
    Ok { value: Int }
    Err { error: String }
}

: is-ok? ( IntResult -- Bool )
    match
        Ok { >value } -> drop true
        Err { >error } -> drop false
    end
;

: is-err? ( IntResult -- Bool )
    match
        Ok { >value } -> drop false
        Err { >error } -> drop true
    end
;

: success ( Int -- IntResult )
    Make-Ok
;

: failure ( String -- IntResult )
    Make-Err
;

: test-ok ( -- )
    42 success is-ok?
    test.assert
;

: test-err ( -- )
    "oops" failure is-err?
    test.assert
;
