shithub: mc

ref: 94acc736ec2d8d80533439a24742d7c796aaab4f
dir: /libstd/try.myr/

View raw version
use "result.use"
use "option.use"
use "fmt.use"

pkg std =
	generic try : (v : result(@a, @b) -> @a)
	generic val : (v : option(@a) -> @a)
;;

generic try = {v
	match v
	| `Ok x:	-> x
	| `Fail m:	fatal("error: {}\n", m)
	;;
}

generic val = {v
	match v
	| `Some x:	-> x
	| `None:	fatal("error: option had `None\n")
	;;
}