anchor.diff:          Gen.frequency 
               [ 
                   1, Gen.map (fun c -> SynExpr.Const(c, zero)) genSubSynConst
  -                1, Gen.map2 (fun expr typ -> SynExpr.Typed(expr, typ, zero)) genSubSynExpr genSubSynType
  -                2, Gen.map (fun exprs -> SynExpr.Tuple(exprs, exprs |> List.map (fun _ -> zero), zero)) genSubSynExprList
  -                2, Gen.map2 (fun b exprs -> SynExpr.ArrayOrList(b, exprs, zero)) Arb.generate<_> genSubSynExprList
  -                1, Gen.map3 (fun b typ expr -> SynExpr.New(b, typ, SynExpr.Paren(expr, zero, None, zero), zero)) Arb.generate<_> genSubSynType genSubSynExpr
  -                1, Gen.map2 (fun expr1 expr2 -> SynExpr.While(NoSequencePointAtWhileLoop, expr1, expr2, zero)) genSubSynExpr genSubSynExpr
  -                1, Gen.map2 (fun b expr -> SynExpr.ArrayOrListOfSeqExpr(b, expr, zero)) Arb.generate<_> genSubSynExpr
  -                1, Gen.map2 (fun b expr -> SynExpr.CompExpr(b, ref true, expr, zero)) Arb.generate<_> genSubSynExpr
  -                1, Gen.map (fun expr -> SynExpr.Do(expr, zero)) genSubSynExpr
  -                1, Gen.map (fun expr -> SynExpr.Assert(expr, zero)) genSubSynExpr
  -                1, Gen.map (fun expr -> SynExpr.Paren(expr, zero, None, zero)) genSubSynExpr
  +                1, Gen.map2 (fun expr typ -> SynExpr.Typed(expr, typ, zero)) genSubBasicExpr genSubSynType
  +                2, Gen.map (fun exprs -> SynExpr.Tuple(exprs, exprs |> List.map (fun _ -> zero), zero)) genSubBasicExprList
  +                2, Gen.map2 (fun b exprs -> SynExpr.ArrayOrList(b, exprs, zero)) Arb.generate<_> genSubBasicExprList
  +                1, Gen.map3 (fun b typ expr -> SynExpr.New(b, typ, SynExpr.Paren(expr, zero, None, zero), zero)) Arb.generate<_> genSubSynType genSubBasicExpr
  +                1, Gen.map2 (fun expr1 expr2 -> SynExpr.While(NoSequencePointAtWhileLoop, expr1, expr2, zero)) genSubBasicExpr genSubBasicExpr
  +                1, Gen.map2 (fun b expr -> SynExpr.ArrayOrListOfSeqExpr(b, expr, zero)) Arb.generate<_> genSubBasicExpr
  +                1, Gen.map2 (fun b expr -> SynExpr.CompExpr(b, ref true, expr, zero)) Arb.generate<_> genSubBasicExpr
  +                1, Gen.map (fun expr -> SynExpr.Do(expr, zero)) genSubBasicExpr
  +                1, Gen.map (fun expr -> SynExpr.Assert(expr, zero)) genSubBasicExpr
  +                1, Gen.map (fun expr -> SynExpr.Paren(expr, zero, None, zero)) genSubBasicExpr
                   1, genSubIdentExpr
                   1, Gen.map2 (fun b expr -> SynExpr.AddressOf(b, expr, zero, zero)) Arb.generate<_> genSubIdentExpr
                   1, Gen.constant (SynExpr.Null zero)
  
positive.code: open Fantomas.CodeFormatter
  open Fantomas.FormatConfig
  open FsCheck
  open FsCheck.NUnit
  open Microsoft.FSharp.Compiler.Ast
  open Microsoft.FSharp.Compiler.Range
  
  let generateSynMeasure =
      Gen.constant SynMeasure.One
  
  let zero = range.Zero
  
  let rec generateSynConst size =
      Gen.oneof 
          [ 
              Gen.constant SynConst.Unit
  
negative.code: let generateInput = 
      Gen.map (fun ast -> Input (tryFormatAST ast None formatConfig)) generateParsedInput
  
  let fromSynExpr expr =
      let ast =
          let ident = Ident("Tmp", zero)
          ParsedInput.ImplFile
              (ParsedImplFileInput
                 ("/tmp.fs", false,
                  QualifiedNameOfFile ident, [], [],
                  [SynModuleOrNamespace
                     ([ident], true,
                      [SynModuleDecl.DoExpr(NoSequencePointAtDoBinding, expr, zero)], PreXmlDocEmpty, [], None,
                      zero)], false))
      Input (tryFormatAST ast None formatConfig)
  
  let toSynExpr (Input s) =
      match parse false s with
      | ParsedInput.ImplFile
          (ParsedImplFileInput
              ("/tmp.fs", false,
              QualifiedNameOfFile _, [], [],
              [SynModuleOrNamespace
                  (_, true, exprs, _, _, _, _)], false)) -> 
                  List.tryPick(function (SynModuleDecl.DoExpr(_, expr, _)) -> Some expr | _ -> None) exprs
      | ast -> 
          //stdout.WriteLine("Can't convert {0}", sprintf "%A" ast)
          None
  
  let rec shrinkSynExpr = function
      | SynExpr.LongIdentSet(_, expr, _)
      | SynExpr.DotIndexedGet(expr, _, _, _)
      | SynExpr.DotGet(expr, _, _, _)
      | SynExpr.DotSet(expr, _, _, _)
      | SynExpr.TypeTest(expr, _, _)
      | SynExpr.Upcast(expr, _, _)
      | SynExpr.Downcast(expr, _, _)
      | SynExpr.InferredUpcast(expr, _)
      | SynExpr.InferredDowncast(expr, _) 
      | SynExpr.Lazy(expr, _)
      | SynExpr.TypeApp(expr, _, _, _, _, _, _)
      | SynExpr.Do(expr, _)
      | SynExpr.Assert(expr, _)
      | SynExpr.Lambda(_, _, _, expr, _)
      | SynExpr.CompExpr(_, _, expr, _)
      | SynExpr.ArrayOrListOfSeqExpr(_, expr, _)
      | SynExpr.New(_, _, expr, _)
      | SynExpr.Typed(expr, _, _)
      | SynExpr.Paren(expr, _, _, _)
      | SynExpr.AddressOf(_, expr, _, _) -> 
          collectSynExpr expr
      
      | SynExpr.IfThenElse(expr1, expr2, None, _, _, _, _)
      | SynExpr.DotIndexedSet(expr1, _, expr2, _, _, _)
      | SynExpr.NamedIndexedPropertySet(_, expr1, expr2, _)
      | SynExpr.Sequential(_, _, expr1, expr2, _)
      | SynExpr.TryFinally(expr1, expr2, _, _, _)
      | SynExpr.App(_, _, expr1, expr2, _)
      | SynExpr.ForEach(_, _, _, _, expr1, expr2, _)
      | SynExpr.While(_, expr1, expr2, _)
      | SynExpr.Quote(expr1, _, expr2, _, _) -> 
          seq { yield! collectSynExpr expr1; yield! collectSynExpr expr2 }
      | SynExpr.Const(_, _) -> Seq.empty
      | SynExpr.ArrayOrList(_, exprs, _)
      | SynExpr.Tuple(exprs, _, _) ->
          seq { yield! Seq.collect collectSynExpr exprs }
      | SynExpr.Record(_, _, _, _) -> Seq.empty
      | SynExpr.ObjExpr(_, _, _, _, _, _) -> Seq.empty
  
      | SynExpr.IfThenElse(expr1, expr2, Some expr3, _, _, _, _)
      | SynExpr.DotNamedIndexedPropertySet(expr1, _, expr2, expr3, _)
      | SynExpr.For(_, _, expr1, _, expr2, expr3, _) -> 
          seq { yield! collectSynExpr expr1; yield! collectSynExpr expr2; yield! collectSynExpr expr3 }
      | SynExpr.MatchLambda(_, _, clauses, _, _) -> 
          seq { yield! Seq.collect collectSynMatchClause clauses }
      | SynExpr.TryWith(expr, _, clauses, _, _, _, _)
      | SynExpr.Match(_, expr, clauses, _, _) -> 
          seq { yield! collectSynExpr expr; yield! Seq.collect collectSynMatchClause clauses }
      | SynExpr.LetOrUse(_, _, bindings, expr, _) -> 
          seq { yield! Seq.collect collectSynBinding bindings; yield! collectSynExpr expr }
      | SynExpr.Ident(_) -> Seq.empty
      | SynExpr.LongIdent(_, _, _, _) -> Seq.empty
      | SynExpr.Null(_) -> Seq.empty
      | SynExpr.TraitCall(_, _, _, _) -> Seq.empty
      | SynExpr.JoinIn(_, _, _, _) -> Seq.empty
      | SynExpr.ImplicitZero(_) -> Seq.empty
      | SynExpr.YieldOrReturn(_, _, _) -> Seq.empty
      | SynExpr.YieldOrReturnFrom(_, _, _) -> Seq.empty
      | SynExpr.LetOrUseBang(_, _, _, _, _, _, _) -> Seq.empty
      | SynExpr.DoBang(_, _) -> Seq.empty
      | SynExpr.LibraryOnlyILAssembly(_, _, _, _, _) -> Seq.empty
      | SynExpr.LibraryOnlyStaticOptimization(_, _, _, _) -> Seq.empty
      | SynExpr.LibraryOnlyUnionCaseFieldGet(_, _, _, _) -> Seq.empty
      | SynExpr.LibraryOnlyUnionCaseFieldSet(_, _, _, _, _) -> Seq.empty
      | SynExpr.ArbitraryAfterError(_, _) -> Seq.empty
      | SynExpr.FromParseError(_, _) -> Seq.empty
      | SynExpr.DiscardAfterMissingQualificationAfterDot(_, _) -> Seq.empty
  
  and collectSynExpr expr =
      seq { yield expr 
            yield! shrinkSynExpr expr }
  
  and collectSynMatchClause (SynMatchClause.Clause(_, exprOpt, expr, _, _)) =
      seq { yield! exprOpt |> Option.map collectSynExpr |> fun arg -> defaultArg arg Seq.empty
            yield! collectSynExpr expr }
  
  and collectSynBinding (SynBinding.Binding(_, _, _, _, _, _, _, _, _, expr, _, _)) =
      collectSynExpr expr
  
  let shrinkInput input = 
      match toSynExpr input with
      | None -> 
          stdout.WriteLine("Can't shrink {0}", sprintf "%A" input)
          Seq.empty
      | Some expr -> 
          shrinkSynExpr expr |> Seq.map fromSynExpr
  
  type Generators = 
      static member range() =
          Arb.fromGen generateRange
      static member Input() = 
          Arb.fromGenShrink (generateInput, shrinkInput)
          // Temporarily filter out bad generated inputs
          |> Arb.filter (fun input -> (toSynExpr input).IsSome)
  
  [<TestFixtureSetUp>]
  let registerFsCheckGenerators() =
  