language-ext v3.3.32 Release Notes

Release Date: 2019-11-09 // over 4 years ago
  • ๐Ÿš€ Following on from last night's discriminated union feature release, I have added some additional features to the code-gen. The full-set of features available now are:

    • Structural equality (via lhs.Equals(rhs) - due to the base-type being an interface)
    • GetHashCode() implementation
    • ToString() implementation
    • Deconstructor method implemented for all union case types
    • With implemented for all union case types
    • Lenses for all fields within a case type
    • ๐Ÿ‘Œ Improved error reporting for the code-gen system as a whole

    And so, now this:

     [Union] public interface Shape { Shape Rectangle(float width, float length); Shape Circle(float radius); Shape Prism(float width, float height); }
    

    Will generate this:

    public partial class Rectangle : LanguageExt.Record\<Rectangle\>, Shape { public readonly float Width; public readonly float Length; public Rectangle(float width, float length) { this.Width = width; this.Length = length; } public void Deconstruct(out float Width, out float Length) { Width = this.Width; Length = this.Length; } public Rectangle With(float? Width = null, float? Length = null) =\> new Rectangle(Width ?? this.Width, Length ?? this.Length); public static readonly Lens\<Rectangle, float\> width = Lens\<Rectangle, float\>.New(\_x =\> \_x.Width, \_x =\> \_y =\> \_y.With(Width: \_x)); public static readonly Lens\<Rectangle, float\> length = Lens\<Rectangle, float\>.New(\_x =\> \_x.Length, \_x =\> \_y =\> \_y.With(Length: \_x)); Shape Shape.Rectangle(float width, float length) =\> throw new System.NotSupportedException(); Shape Shape.Circle(float radius) =\> throw new System.NotSupportedException(); Shape Shape.Prism(float width, float height) =\> throw new System.NotSupportedException(); } public partial class Circle : LanguageExt.Record\<Circle\>, Shape { public readonly float Radius; public Circle(float radius) { this.Radius = radius; } public void Deconstruct(out float Radius) { Radius = this.Radius; } public Circle With(float? Radius = null) =\> new Circle(Radius ?? this.Radius); public static readonly Lens\<Circle, float\> radius = Lens\<Circle, float\>.New(\_x =\> \_x.Radius, \_x =\> \_y =\> \_y.With(Radius: \_x)); Shape Shape.Rectangle(float width, float length) =\> throw new System.NotSupportedException(); Shape Shape.Circle(float radius) =\> throw new System.NotSupportedException(); Shape Shape.Prism(float width, float height) =\> throw new System.NotSupportedException(); } public partial class Prism : LanguageExt.Record\<Prism\>, Shape { public readonly float Width; public readonly float Height; public Prism(float width, float height) { this.Width = width; this.Height = height; } public void Deconstruct(out float Width, out float Height) { Width = this.Width; Height = this.Height; } public Prism With(float? Width = null, float? Height = null) =\> new Prism(Width ?? this.Width, Height ?? this.Height); public static readonly Lens\<Prism, float\> width = Lens\<Prism, float\>.New(\_x =\> \_x.Width, \_x =\> \_y =\> \_y.With(Width: \_x)); public static readonly Lens\<Prism, float\> height = Lens\<Prism, float\>.New(\_x =\> \_x.Height, \_x =\> \_y =\> \_y.With(Height: \_x)); Shape Shape.Rectangle(float width, float length) =\> throw new System.NotSupportedException(); Shape Shape.Circle(float radius) =\> throw new System.NotSupportedException(); Shape Shape.Prism(float width, float height) =\> throw new System.NotSupportedException(); } public static partial class ShapeCon { public static Shape Rectangle(float width, float length) =\> new Rectangle(width, length); public static Shape Circle(float radius) =\> new Circle(radius); public static Shape Prism(float width, float height) =\> new Prism(width, height); }