Is it possible to write a Generated Type Provider that provides types equivalent to the following F# code?
[<ProvidedTypeFlag("myTypeA")>]
type A(x:int) =
inherit ValueType(x)
member __.X = x+1
[<ProvidedTypeFlag("myTypeB")>]
type B(value:ValueType) =
member __.Raw = value
member __.toA = A(value.X)
interface IComparable with
member this.CompareTo obj =
match obj with
| :? B as other -> this.Raw.X.CompareTo (other.Raw.X)
| _ -> invalidArg "obj" "not a B"
[<ProvidedTypeFlag("myTypeC")>]
type C() =
static member Process(a:A) =
seq {
for x in [1..a.X] do
yield B(ValueType(x))
} |> Set.ofSeq
assume that I have following types in the same assembly
// Value type that hold some data from 3rd party system
type ValueType (x:int) =
member __.X = x
// Custom attribute that I want to have on provided types
[<AttributeUsage(AttributeTargets.Class, AllowMultiple=false)>]
type ProvidedTypeFlagAttribute(originName:string) =
inherit System.Attribute()
member __.OriginName = originName
If it is possible, please provide a sample of how to do it using ProvidedTypes.fs