On Tue, Feb 3, 2015 at 2:25 PM, Thomas Leonard <[email protected]> wrote:
> > open Core.Std;; > > > > type myerr = [`Zero | `Neg of int] with sexp;; > > > > (* Get back to myerr if possible. *) > > let myerr_of_error (e:Error.t) : myerr option = > > match Error.sexp_of_t e with > > | Sexp.List (_::x::[]) -> Some (myerr_of_sexp x) > > | _ -> None > > I don't understand how this works. How does myerr_of_error know that > this is a myerr? It seems to be just testing that the sexp is a 2-item > list. It's a best effort implementation. Error.create puts a string as the first item of the list and your specific error value as the second item. I haven't checked what happens when you apply Error.tag. I'd have to investigate more to see if there's a reasonably predictable sexp structure, so you can know which part is the myerr. Does it throw an exception if given some different type of > error? > I decided to return None, but maybe we could again return an Error.t.
_______________________________________________ MirageOS-devel mailing list [email protected] http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel
