title: Folding a list of elements into a set of elements
body: <p>I want to fold a list into a set, but my implementation seems to require that the list is already a set. <code>Element</code> has an <code>Ord</code> instance. Imports are correct.</p>
  
  <pre><code>listToSet :: [Element] -&gt; Set Element
  listToSet d = foldl' insert empty d
  </code></pre>
  
  <p><code>d</code> should already be a set here, so this of course gives a type error, can I use <code>foldl'</code> to create a set from a list? Do I first need to "cast" the list of <code>Element</code>s to a list of sets of length one with each one of the <code>Element</code>s?</p>
  
  <p>Error:</p>
  
  <pre><code>Assignment3.hs:201:39: error:
      * Couldn't match type `Element' with `Set Element'
        Expected type: [Set Element]
          Actual type: [Element]
      * In the third argument of foldl', namely `d'
        In the expression: foldl' insert empty d
        In an equation for `listToSet':
            listToSet d = foldl' insert empty d
      |
  201 | listToSet d = foldl' insert empty d
      |     
  </code></pre>