Please note that you can use signature files to emulate a friend.
If you want to Abe a friend B, so you Acan access internal elements Bthat others cannot see, you can do, for example,
type B() =
let x = 42
member this.X = x
type A() =
member this.PeekInto(b : B) =
b.X
but also have
type B =
new : unit -> B
type A =
new : unit -> A
PeekInto : B -> int
and now the Aimplementation can see B.X, but the sequel to the program cannot see B.X.
Signature files are pretty impressive for creating arbitrary encapsulation boundaries.
source
share