anchor.diff:                  let rewritten = Pattern.repeatAtMost atMost r
   
                   // Process the rewritten expression.
  -                validateAndSimplify rewritten cont
  +                return! validateAndSimplify rewritten
   
               | Some atLeast, None ->
                   /// Repeats the pattern at least the specified number of times.
                   let rewritten = Pattern.repeatAtLeast atLeast r
   
                   // Process the rewritten expression.
  -                validateAndSimplify rewritten cont
  +                return! validateAndSimplify rewritten
   
               | Some atLeast, Some atMost
                   when atLeast > atMost ->
  -                ["Invalid number of repetitions. The lower value of the range is greater than the upper value of the range."]
  -                |> Choice2Of2
  -                |> cont
  +                return
  +                    ["Invalid number of repetitions. The lower value of the range is greater than the upper value of the range."]
  +                    |> Choice2Of2
   
               | Some atLeast, Some atMost ->
                   /// Repeats the pattern at least 'atLeast' times and at most 'atMost' times.
                   let rewritten = Pattern.repeat atLeast atMost r
   
                   // Process the rewritten expression.
  -                validateAndSimplify rewritten cont
  +                return! validateAndSimplify rewritten
  +        }
   
       // Call the function which traverses the pattern to validate/preprocess it.
       validateAndSimplify pattern <| function
  
positive.code:     //
      // OPTIMIZE : Modify this function to use a LazyList to hold the errors
      // instead of an F# list to avoid the list concatenation overhead.
      // OPTIMIZE : Simplify this function using the Cps.choice workflow from ExtCore.
      let rec validateAndSimplify pattern cont =
          match pattern with
          | Pattern.Epsilon ->
              Choice1Of2 Regex.Epsilon
              |> cont
  
          | Pattern.CharacterSet charSet ->
              // Make sure all of the characters in the set are ASCII characters unless the 'Unicode' option is set.
              if options.Unicode || CharSet.forall (fun c -> int c <= int System.Byte.MaxValue) charSet then
                  Regex.CharacterSet charSet
                  |> Choice1Of2
                  |> cont
              else
                  ["Unicode characters may not be used in patterns unless the 'Unicode' compiler option is set."]
                  |> Choice2Of2
                  |> cont
  
          | Pattern.Macro macroId ->
              match Map.tryFind macroId macroEnv with
  
negative.code:                     if Set.contains nestedMacroId badMacros then
                          // We have to return something, so return Empty to take the place
                          // of this macro reference.
                          return Choice1Of2 Regex.empty
                      else
                          return Choice2Of2 [ sprintf "The macro '%s' is not defined." nestedMacroId ]
  
                  | Some nestedMacro ->
                      // Return the pattern for the nested macro so it'll be "inlined" into this pattern.
                      return Choice1Of2 nestedMacro
  
          (* Characters and character sets *)
          | Pattern.Empty ->
              return
                  Regex.empty
                  |> Choice1Of2
  
          | Pattern.Character c ->
              // Make sure the character is an ASCII character unless the 'Unicode' option is set.
              if options.Unicode || int c <= 255 then
                  return
                      Regex.ofChar c
                      |> Choice1Of2
              else
                  return
                      ["Unicode characters may not be used in patterns unless the 'Unicode' compiler option is set."]
                      |> Choice2Of2
  
          | Pattern.CharacterSet charSet ->
              // Make sure all of the characters in the set are ASCII characters unless the 'Unicode' option is set.
              if options.Unicode || CharSet.forall (fun c -> int c <= 255) charSet then
                  return
                      Regex.CharacterSet charSet
                      |> Choice1Of2
              else
                  return
                      ["Unicode characters may not be used in patterns unless the 'Unicode' compiler option is set."]
                      |> Choice2Of2
  
          | Pattern.UnicodeCategory abbrev ->
              if options.Unicode then
                  match UnicodeCharSet.ofAbbreviation abbrev with
                  | None ->
                      return
                          [ sprintf "Unknown or invalid Unicode category specified. (Category = %s)" abbrev ]
                          |> Choice2Of2
                  | Some categoryCharSet ->
                      return
                          Regex.CharacterSet categoryCharSet
                          |> Choice1Of2
              else
                  return
                      ["Unicode category patterns may not be used unless the 'Unicode' compiler option is set."]
                      |> Choice2Of2
  
          (* Wildcard pattern *)
          | Pattern.Any ->
              // Macros are not allowed to use the wildcard pattern.
              return
                  ["The wildcard pattern cannot be used within macro definitions."]
                  |> Choice2Of2
          }
  
      /// Contains an error if a macro has already been defined with this name; otherwise, None.
      let duplicateNameError =
  