AshleyYakeley / Truth

Changes and Pinafore projects. Pull requests not accepted.
https://pinafore.info/
GNU General Public License v2.0
32 stars 0 forks source link

Extensible Record Constructors #196

Closed AshleyYakeley closed 1 year ago

AshleyYakeley commented 1 year ago

Something like:

datatype A of
    MkA of
        m1: T1;
        m2: T2;
    end;
end;

datatype B <: A of
    MkB of
        MkA;
        m3: T3;
        m4: T4;
    end;
end;

This would give B <: A. (Nothing special with GDS.)

To create a B:

mkB: A -> T3 -> T4 -> B =
    fn MkA, m3, m4 => MkB;

Conditions:

Multiple inheritance with diamonds

Broken diamond looks like this:

datatype A of
    MkA1 of end;
    MkA2 of end;
end;

datatype B <: A of
    MkB of MkA1 end;
end;

datatype C <: A of
    MkC of MkA2 end;
end;

datatype D <: B & C of
    MkD of MkB; MkC; end;
end;
AshleyYakeley commented 1 year ago

Done.