Skip to content

LanguageExt.HashSet<A> clashes with System.Collections.Generic.HashSet<T> #1408

Closed Answered by louthy
ThomasBarnekow asked this question in Q&A
Discussion options

You must be logged in to vote

The difference between Fin and HashSet is that HashSet is part of four types that are related:

  • HashMap and Map
  • HashSet and Set

Calling HashSet something else to avoid the name clash would lead to inconsistent naming across the library, so it's a special case.

To solve it:

  1. Add two global-using aliases:
global using G = System.Collections.Generic;
global using L = LanguageExt;
  1. Whenever you need a HashSet (and you have both namespaces included), just prefix with L. or G.:
var xs = new G.HashSet<int>();

Another approach -- the one I take -- is to never use the System collection types as they're all mutable types and against the principles of pure functional programming. The only type I …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ThomasBarnekow
Comment options

Answer selected by ThomasBarnekow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #1407 on November 09, 2024 21:08.