嵌套的泛型接口

Nested generic types of interfaces

给定以下界面:

type A<'t> =
    abstract Scratch: 't

如何简单地创建这样的界面:

type X<A<'t>> =
    abstract f: A<'t>

我也试过这个:

type X<'t,'y when 'y:A<'t>> =
    abstract f: 'y

还有这个:

type X<'t,A<'t>> =
    abstract f: A<'t>

但是 none 对我有用。

如果你想把它作为界面来做,试试这个:

type IA<'a> =
    abstract Scratch: 'a

type IX<'a, 'b when 'a :> IA<'b>> = 
    abstract F: 'a

type RealA() = 
    interface IA<int> with
        member __.Scratch = 1

type RealX = 
    interface IX<RealA, int> with
        member __.F = RealA()

如果你想要摘要类:

[<AbstractClass>]
type A<'a>() = 
    abstract member Scratch: 'a

[<AbstractClass>]
type X<'a, 'b when 'a :> A<'b>>() = 
    abstract F: 'a

type RealA'() = 
    inherit A<int>()
    override __.Scratch = 1

type RealX'() = 
    inherit X<RealA', int>()
    override __.F = RealA'()