anchor.diff:      let infs = filter (fun (s,_) -> s <> ",") (infixes())
       mk_precedence infs typed_appl_preterm i
     and typed_appl_preterm i =
  -    (appl_preterm .>>. possibly (a (Resword ":") .>>. pretype >> snd) >> lmk_typed) i
  +    (appl_preterm .>>. possibly (a (Resword ":") .>>. pretype |>> snd) |>> lmk_typed) i
     and appl_preterm i =
       (pre_fix .>>. appl_preterm
  -     >> (fun (x,y) -> Combp(Varp(x,dpty),y))
  -      <|> binder_preterm .>>. many binder_preterm >>
  +     |>> (fun (x,y) -> Combp(Varp(x,dpty),y))
  +      <|> binder_preterm .>>. many binder_preterm |>>
           (fun (h,t) -> itlist (fun x y -> Combp(y,x)) (rev t) h)) i
     and binder_preterm i =
       (a (Resword "let") .>>.
  -     leftbin (preterm >> singleton1) (a (Resword "and")) (K (@)) "binding" .>>.
  +     leftbin (preterm |>> singleton1) (a (Resword "and")) (K (@)) "binding" .>>.
        a (Resword "in") .>>.
        preterm
  -    >> lmk_let
  -  <|> binder .>>. typed_apreterm .>>. many typed_apreterm .>>. a (Resword ".") .>>. preterm >> lmk_binder
  +    |>> lmk_let
  +  <|> binder .>>. typed_apreterm .>>. many typed_apreterm .>>. a (Resword ".") .>>. preterm |>> lmk_binder
     <|> atomic_preterm) i
     and typed_apreterm i =
  -    (atomic_preterm .>>. possibly (a (Resword ":") .>>. pretype >> snd) >> lmk_typed) i
  +    (atomic_preterm .>>. possibly (a (Resword ":") .>>. pretype |>> snd) |>> lmk_typed) i
     and atomic_preterm i =
       (try_user_parser
  -  <|> (a (Resword "(") .>>. a (Resword ":")) .>>. pretype .>>. a (Resword ")") >> lmk_univ
  -  <|> string >> pmk_string
  -  <|> a (Resword "(") .>>. (any_identifier >> (fun s -> Varp(s,dpty))) .>>. a (Resword ")") >> (snd << fst)
  -  <|> a (Resword "(") .>>. preterm .>>. a (Resword ")") >> (snd << fst)
  -  <|> a (Resword "if") .>>. preterm .>>. a (Resword "then") .>>. preterm .>>. a (Resword "else") .>>. preterm >> lmk_ite
  -  <|> a (Resword "[") .>>. elistof preterm (a (Resword ";")) "term" .>>. a (Resword "]") >> (pmk_list << snd << fst)
  +  <|> (a (Resword "(") .>>. a (Resword ":")) .>>. pretype .>>. a (Resword ")") |>> lmk_univ
  +  <|> string |>> pmk_string
  +  <|> a (Resword "(") .>>. (any_identifier |>> (fun s -> Varp(s,dpty))) .>>. a (Resword ")") |>> (snd << fst)
  +  <|> a (Resword "(") .>>. preterm .>>. a (Resword ")") |>> (snd << fst)
  +  <|> a (Resword "if") .>>. preterm .>>. a (Resword "then") .>>. preterm .>>. a (Resword "else") .>>. preterm |>> lmk_ite
  +  <|> a (Resword "[") .>>. elistof preterm (a (Resword ";")) "term" .>>. a (Resword "]") |>> (pmk_list << snd << fst)
     <|> a (Resword "{") .>>.
  -     (elistof nocommapreterm (a (Ident ",")) "term" .>>.  a (Resword "}") >> lmk_setenum
  -      <|> preterm .>>. a (Resword "|") .>>. preterm .>>. a (Resword "}") >> lmk_setabs
  -      <|> preterm .>>. a (Resword "|") .>>. preterm .>>. a (Resword "|") .>>. preterm .>>. a (Resword "}") >> lmk_setcompr) >> snd
  -  <|> a (Resword "match") .>>. preterm .>>. a (Resword "with") .>>. clauses >> (fun (((_,e),_),c) -> Combp(Combp(Varp("_MATCH",dpty),e),c))
  -  <|> a (Resword "function") .>>. clauses >> (fun (_,c) -> Combp(Varp("_FUNCTION",dpty),c))
  -  <|> a (Ident "#") .>>. identifier .>>. possibly (a (Resword ".") .>>. identifier >> snd) >> lmk_decimal
  +     (elistof nocommapreterm (a (Ident ",")) "term" .>>.  a (Resword "}") |>> lmk_setenum
  +      <|> preterm .>>. a (Resword "|") .>>. preterm .>>. a (Resword "}") |>> lmk_setabs
  +      <|> preterm .>>. a (Resword "|") .>>. preterm .>>. a (Resword "|") .>>. preterm .>>. a (Resword "}") |>> lmk_setcompr) |>> snd
  +  <|> a (Resword "match") .>>. preterm .>>. a (Resword "with") .>>. clauses |>> (fun (((_,e),_),c) -> Combp(Combp(Varp("_MATCH",dpty),e),c))
  +  <|> a (Resword "function") .>>. clauses |>> (fun (_,c) -> Combp(Varp("_FUNCTION",dpty),c))
  +  <|> a (Ident "#") .>>. identifier .>>. possibly (a (Resword ".") .>>. identifier |>> snd) |>> lmk_decimal
     <|> identifier
  -    >> (fun s -> Varp(s,dpty))) i
  +    |>> (fun s -> Varp(s,dpty))) i
     and pattern i =
  -    (preterm .>>. possibly (a (Resword "when") .>>. preterm >> snd)) i
  +    (preterm .>>. possibly (a (Resword "when") .>>. preterm |>> snd)) i
     and clause i =
  -   ((pattern .>>. (a (Resword "->") .>>. preterm >> snd)) >> pmk_pattern) i
  +   ((pattern .>>. (a (Resword "->") .>>. preterm |>> snd)) |>> pmk_pattern) i
     and clauses i =
      ((possibly (a (Resword "|")) .>>.
  -     listof clause (a (Resword "|")) "pattern-match clause" >> snd) >> end_itlist (fun s t -> Combp(Combp(Varp("_SEQPATTERN",dpty),s),t))) i
  +     listof clause (a (Resword "|")) "pattern-match clause" |>> snd) |>> end_itlist (fun s t -> Combp(Combp(Varp("_SEQPATTERN",dpty),s),t))) i
     (function
       | [Ident s] -> Varp(s,dpty),[]
       | inp -> preterm inp)
  
positive.code:     listof prs sep err <|> nothing;;
  
  let leftbin prs sep cons err =
      prs .>>. many (sep .>>. fix err prs) >>
      (fun (x,opxs) ->
          let ops, xs = unzip opxs
          itlist2 (fun op y x -> cons op x y) (rev ops) (rev xs) x);;
  
  let rightbin prs sep cons err =
      prs .>>. many (sep .>>. fix err prs) >>
      (fun (x, opxs) ->
          if opxs = [] then x
          else
  
negative.code:     | _ -> failwith "lex:unrecognized OCaml-style escape in string"
    let stringchar =
        some (fun i -> i <> "\\" && i <> "\"")
        <|> (a "\\" .>>. escapecode |>> snd) in
    let string = a "\"" .>>. many stringchar .>>. a "\"" |>> (fun ((_,s),_) -> "\""^implode s^"\"")
    let rawtoken = (string <|> some isbra <|> septok <|> ident) |>> (fun x -> Ident x)
    let simptoken = many (some isspace) .>>. rawtoken |>> (reserve << snd)
    let rec tokens i =
      try let (t,rst) = simptoken i in
          if t = !comment_token then
            (many (fun i -> if i <> [] && hd i <> "\n" then 1,tl i
                            else raise Noparse) .>>. tokens |>> snd) rst
          else
            let toks,rst1 = tokens rst in t::toks,rst1
      with Noparse -> [],i in
    fst << (tokens .>>. many (some isspace) .>>. finished |>> (fst << fst))
  
  (* ------------------------------------------------------------------------- *)
  (* Parser for pretypes. Concrete syntax:                                     *)
  