X-Git-Url: https://git.xandkar.net/?p=tiger.ml.git;a=blobdiff_plain;f=compiler%2Fsrc%2Flib%2Ftiger%2Ftiger_opt.ml;fp=compiler%2Fsrc%2Flib%2Ftiger%2Ftiger_opt.ml;h=cdacd0e85fdb48a934eec22fc61196650a199ec4;hp=0000000000000000000000000000000000000000;hb=d1fe69d31f39d5481d739e592863e1126cfe0c35;hpb=3206cc891aacf41c6bc6c00ecb2b85b3a0a2b72a diff --git a/compiler/src/lib/tiger/tiger_opt.ml b/compiler/src/lib/tiger/tiger_opt.ml new file mode 100644 index 0000000..cdacd0e --- /dev/null +++ b/compiler/src/lib/tiger/tiger_opt.ml @@ -0,0 +1,11 @@ +type 'a t = 'a option + +let map t f = + match t with + | None -> None + | Some x -> Some (f x) + +let get t ~default = + match t with + | None -> default + | Some x -> x