It wouldn't solve the problem, because in reality I'm matching something like this piece of code implementing a doubly-linked list:

type 'a cell = { data : 'a;
                 next : 'a link ref;
                 last : 'a link ref;
               }

and 'a link = Cons of 'a cell | Nil

type 'a t = {
  firstl: 'a link ref;
  lastl:  'a link ref;
}

  let pop s = match s with
    | {firstl = {contents=Nil}; lastl = _ } -> raise Empty

    | {lastl = {contents=Cons {data; _}}} when s.lastl == s.firstl ->
        (* one term *)
        s.lastl := Nil;
        s.firstl := Nil;
        data

    | {firstl =
      {contents=Cons {data; next={contents=Cons n}; last={contents=Nil}}}} ->
        n.last := Nil;
        s.firstl := Cons n;
        data
    | _ -> failwith "Error in pop"


See how unwieldy that is without the ability to clean it up by matching on refs?

-Yotam


On Thu, Oct 10, 2013 at 3:34 PM, Ashish Agarwal <agarwal1975@gmail.com> wrote:
Would it solve your problem to instead write:

match !x with
| y -> ...


On Thu, Oct 10, 2013 at 3:17 PM, Yotam Barnoy <yotambarnoy@gmail.com> wrote:
I recently found out how ugly it is to pattern-match on a ref, using {contents=...}. This should be extremely easy to fix in the parser. Can it please be put into the next version of ocaml?
ie.

match x with
| ref y -> ...

-Yotam