❮❮❮ ❮❮❮   ❯❯❯ ❯❯❯
Configuration of optimisation models in F#
Composition with interface inheritance.

Tags: fs opt config
Reading time: 2 min.

Context

Flexible Records

Interfaces

Example

// Layer 1
type IndexA =
  abstract member IndexA : array<int>
type IndexB<'a when 'a : comparison> =
  abstract member IndexB : Set<'a>
type IndexC<'a when 'a : comparison> =
  inherit IndexSetA<string> # base set of elements in IndexC
  abstract member IndexC : Set<'a * 'a>

// Layer 2
type ParamA =
  abstract member ParamA : int
type ParamB =
  inherit ParamA # length of ParamB
  abstract member ParamB : array<int>
type ParamC =
  inherit ParamA # length of ParamC
  abstract member ParamC : array<int>
type ParamD<'a when 'a : comparison> =
  inherit ParamA # length of arrays in ParamD
  inherit IndexA<'a> # keys of ParamD
  abstract member ParamD : Map<'a, array<float>
type ParamE<'a when 'a : comparison> =
  inherit IndexC<'a> # keys of ParamE
  abstract member ParamE: Map<'a, Map<'a, bool>>

// Layer 3
type Version1 =
  inherit ParamB
  inherit ParamD<string>
  inherit ParamE<string> 
type Version2 =
  inherit ParamB
  inherit ParamC
  inherit ParamD<string>
  inherit ParamE<string>