anchor.diff:      | _ -> failwithf "unsupported type '%O'" typeof<'T>
   
   
  +/// Generates a string parser for given type
  +let mkParser<'T> () : string -> 'T = 
  +    let fp = genParser<'T>() in 
  +    fun inp -> 
  +        match run fp inp with
  +        | Success(r,_,_) -> r
  +        | Failure(msg,_,_) -> failwithf "Parse error: %s" msg
  +
   // examples
   
   let p1 = mkParser<int * int list>()
  
positive.code: open FParsec
  open TypeShape
  
  [<AutoOpen>]
  module Utils =
      type Parser<'T> = Parser<'T, unit>
  
      let inline delay (f : unit -> 'T) : Parser<'T> =
          fun stream -> Reply(f ())
  
      /// Parser folding combinator with separator support
      let fold (folder : 'State -> 'T -> 'State) 
                  (init : Parser<'State>) (parsers : Parser<'T> []) 
                  (sep : Parser<'Sep>) : Parser<'State> =
  
          fun stream ->
              let mutable state = init stream
              if state.Status <> Ok then state else
              let mutable success = true
              let mutable i = 0
              let n = parsers.Length
              while i < n && success do
                  if i > 0 then 
                      let r = sep stream 
                      if r.Status <> Ok then
                          success <- false
                          state <- Reply(r.Status, r.Error)
  
                  if success then
                      let r = parsers.[i] stream
                      if r.Status <> Ok then
                          success <- false
                          state <- Reply(r.Status, r.Error)
                      else
                          state <- Reply(folder state.Result r.Result)
  
                  i <- i + 1
  
              state
  
  
  /// Generates a parser for given type
  let rec mkParser<'T> () : string -> 'T = 
      let fp = mkFParser<'T>() in 
      fun inp -> 
          match run fp inp with
          | Success(r,_,_) -> r
          | Failure(msg,_,_) -> failwithf "Parse error: %s" msg
  
  and private mkFParser<'T> () : Parser<'T> =
      let spaced p = between spaces spaces p
      let token str = spaced (pstring str) >>% ()
      let paren p = between (token "(") (token ")") p
      let wrap (p : Parser<'a>) = unbox<Parser<'T>>(spaced p)
  
      let mkMemberParser (shape : IShapeWriteMember<'DeclaringType>) =
          shape.Accept { new IWriteMemberVisitor<'DeclaringType, Parser<'DeclaringType -> 'DeclaringType>> with
              member __.Visit (shape : ShapeWriteMember<'DeclaringType, 'Field>) =
                  let fp = mkFParser<'Field>()
                  fp |>> fun f dt -> shape.Inject dt f
          }
  
      let combineMemberParsers 
          (init : Parser<'DeclaringType>) 
          (injectors : Parser<'DeclaringType -> 'DeclaringType> [])
          (separator : Parser<'Sep>) =
  
          fold (fun d i -> i d) init injectors separator
  
      match shapeof<'T> with
      | Shape.Unit -> wrap(paren spaces)
  
negative.code:         s.Accept {
              new IFSharpOptionVisitor<Parser<'T>> with
                  member __.Visit<'t> () =
                      let tp = genParser<'t>() |>> Some
                      let nP = stringReturn "None" None
                      let vp = attempt (paren tp) <|> tp
                      let sP = token "Some" >>. vp
  