anchor.diff:              type private EquivalenceRelation = class end
               type private PartialEquivalenceRelation = class end
   
  +            module mos =
  +                let makeEquatableType ty =
  +                    let equatableTypedef = typedefof<IEquatable<_>>
  +                    equatableTypedef.MakeGenericType [|ty|]
  +
  +                let makeComparableType ty =
  +                    let comparableTypedef = typedefof<IComparable<_>>
  +                    comparableTypedef.MakeGenericType [|ty|]
  +
  +                // TODO: Copy to a Comparable version
  +                let rec tryFindObjectsInterfaceMethod (objectType:Type) (interfaceType:Type) (methodName:string) (methodArgTypes:array<Type>) =
  +                    if not (interfaceType.IsAssignableFrom objectType) then null
  +                    else
  +                        let methodInfo = interfaceType.GetMethod (methodName, methodArgTypes) 
  +                        let interfaceMap = objectType.GetInterfaceMap interfaceType
  +                        let rec findTargetMethod index =
  +                            if index = interfaceMap.InterfaceMethods.Length then null
  +                            elif methodInfo.Equals (get interfaceMap.InterfaceMethods index) then (get interfaceMap.TargetMethods index)
  +                            else findTargetMethod (index+1)
  +                        findTargetMethod 0
  +
  +                let rec isCompilerGeneratedInterfaceMethod objectType interfaceType methodName methodArgTypes =
  +                    match tryFindObjectsInterfaceMethod objectType interfaceType methodName methodArgTypes with
  +                    | null -> false
  +                    | m -> 
  +                        match m.GetCustomAttribute typeof<CompilerGeneratedAttribute> with
  +                        | null -> false
  +                        | _ -> true
  +
  +                let rec isCompilerGeneratedMethod (objectType:Type) (methodName:string) (methodArgTypes:array<Type>) =
  +                    match objectType.GetMethod (methodName, methodArgTypes) with
  +                    | null -> false
  +                    | m ->
  +                        match m.GetCustomAttribute typeof<CompilerGeneratedAttribute> with
  +                        | null -> false
  +                        | _ -> true
  +
  +                let hasFSharpCompilerGeneratedEquality (ty:Type) =
  +                    match ty.GetCustomAttribute typeof<CompilationMappingAttribute> with
  +                    | :? CompilationMappingAttribute as m when (m.SourceConstructFlags.Equals SourceConstructFlags.ObjectType(*struct*)) || (m.SourceConstructFlags.Equals SourceConstructFlags.RecordType) ->
  +                        isCompilerGeneratedInterfaceMethod ty (makeEquatableType ty) "Equals" [|ty|]
  +                        && isCompilerGeneratedInterfaceMethod ty typeof<IStructuralEquatable> "Equals" [|typeof<obj>; typeof<IEqualityComparer>|]
  +                        && isCompilerGeneratedMethod ty "Equals" [|typeof<obj>|] 
  +                    | _ -> false
  +
  +                let hasFSharpCompilerGeneratedComparison (ty:Type) =
  +                    match ty.GetCustomAttribute typeof<CompilationMappingAttribute> with
  +                    | :? CompilationMappingAttribute as m when (m.SourceConstructFlags.Equals SourceConstructFlags.ObjectType(*struct*)) || (m.SourceConstructFlags.Equals SourceConstructFlags.RecordType) ->
  +                        isCompilerGeneratedInterfaceMethod ty (makeComparableType ty) "CompareTo" [|ty|]
  +                        && isCompilerGeneratedInterfaceMethod ty typeof<IStructuralComparable> "CompareTo" [|typeof<obj>; typeof<IComparer>|]
  +                        && isCompilerGeneratedInterfaceMethod ty typeof<IComparable> "CompareTo" [|typeof<obj>|]
  +                    | _ -> false
  +
  +                let makeGenericType<'a> tys =
  +                    let typedef = typedefof<'a>
  +                    typedef.MakeGenericType tys
  +
  +
               module GenericSpecializeCompareTo =
  +
                   let standardTypes (t:Type) : obj =
                       if   t.Equals typeof<bool>       then box (Func<IComparer,bool      ,bool      ,int>(fun _ x y -> if (# "clt" x y : bool #) then (-1) else (# "cgt" x y : int #)))
                       elif t.Equals typeof<sbyte>      then box (Func<IComparer,sbyte     ,sbyte     ,int>(fun _ x y -> if (# "clt" x y : bool #) then (-1) else (# "cgt" x y : int #)))
  
positive.code:                         let make = makeEquatableDelegate t nt 
                          
                          if typeof<IStructuralEquatable>.IsAssignableFrom nt               then make typedefof<NullableStructualEquality<DummyStructInterfaces>>
                          elif (makeEquatableType nt).IsAssignableFrom nt                   then make typedefof<NullableEquatable<DummyStructInterfaces>>
                          else                                                                   make typedefof<NullableEquals<DummyStructInterfaces>>
  
                      elif t.IsValueType && typeof<IStructuralEquatable>.IsAssignableFrom t then make typedefof<StructStructualEquality<DummyStructInterfaces>>
  
negative.code:                     | t when t.Equals typeof<decimal>    -> upcast Func<IEqualityComparer,decimal   ,decimal   ,bool>(fun _ x y -> System.Decimal.op_Equality((# "" x:decimal #), (# "" y:decimal #)))
                      | _ -> null
  
                  let makeEqualsReturnType ty =
                      mos.makeGenericType<Func<_,_,_,_>> [| typeof<IEqualityComparer>; ty; ty; typeof<bool> |]
  
                  let makeEquatableDelegate (ty:Type) (ct:Type) (def:Type) : obj =
                      let concrete = def.MakeGenericType [|ct|]
                      let instance = Activator.CreateInstance concrete
                      upcast Delegate.CreateDelegate (makeEqualsReturnType ty, instance, "Equals")
  
                  type Calls =
                      static member StructualEqualityEquals<'a when 'a :> IStructuralEquatable> (ec, x:'a, y:'a) = x.Equals (box y, ec) 
  