Skip to content

Commit

Permalink
Simplify Unit implementation via record (#34)
Browse files Browse the repository at this point in the history
* Simplify "Unit" implementation via record

* Update src/Eff/Unit.cs

* Remove dangling comment

---------

Co-authored-by: Eirik Tsarpalis <[email protected]>
  • Loading branch information
atifaziz and eiriktsarpalis authored Jul 26, 2024
1 parent 473c941 commit f68d315
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/Eff/Unit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@ namespace Nessos.Effects
/// While similar to <see cref="Void"/>, the unit type is inhabited
/// by a single materialized value and can be used as a generic parameter.
/// </remarks>
public readonly struct Unit : IEquatable<Unit>
public readonly record struct Unit
{
/// <summary>
/// Gets the Unit instance.
/// </summary>
public static Unit Value => new();
/// Implements unit hashcode
public override int GetHashCode() => 1;
/// Implements unit equality
public override bool Equals(object? obj) => obj is Unit;
/// Implements unit equality
public bool Equals(Unit other) => true;
/// Implements unit equality
public static bool operator ==(Unit x, Unit y) => true;
/// Implements unit inequality
public static bool operator !=(Unit x, Unit y) => false;
/// Implements string representation of unit
public override string ToString() => "()";
}
}

0 comments on commit f68d315

Please sign in to comment.