Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As other answers indicate, the question "Why is there no Set data type in Haskell?" is misguided: <a href="http://hackage.haskell.org/packages/archive/containers/latest/doc/html/Data-Set.html">there is a Set data type</a>.</p> <p>If you'd like to know why <code>Set</code> isn't "built in" to Haskell, you could be asking one of two things.</p> <ul> <li>Why is <code>Set</code> not part of the <a href="http://www.haskell.org/onlinereport/haskell2010/">language specification</a>?</li> <li>Why is <code>Set</code> not in <a href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html">Prelude</a> (the functions and data types that are imported by default)?</li> </ul> <p>To answer the former, it is because the language is powerful enough to express the idea of a set without needing to bake it in. Being a language with a high emphasis on functional programming, special syntax for tuples and lists is built in, but even simple data types like <code>Bool</code> are defined in Prelude.</p> <p>To answer the latter, well, again, with the emphasis on functional programming, most Haskellers tend to use lists. The list monad represents nondeterministic choice, and by allowing duplicates, you can sort of represent weighted choices.</p> <p>Note <a href="http://learnyouahaskell.com/starting-out#im-a-list-comprehension">how similar list comprehension syntax is to set notation</a>. You can always use <code>Set.fromList</code> to convert a list into a "real" set, if necessary. As a begrudging shout out to Barry, this would be similar to using Python's <code>set()</code> method; Python has list comprehensions as well.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload