Not like that, no. The Set type is explicitly for *finite* sets only. fromList [1..] is bottom and will run out of memory. You'd need a *very* different implementation to be able to support infinite sets at all, and even then you'd only catch certain special cases.

On Sat, Dec 8, 2018, 7:46 PM Jeffrey Brown <jeffbrown.the@gmail.com wrote:
The following expressions both cause GHCI to hang:

> S.intersection (S.fromList [1,2]) (S.fromList [1..])
fromList ^CInterrupted.
> S.intersection (S.fromList [1..]) (S.fromList [1,2])
fromList ^CInterrupted.
>

Is there a smarter way to take the intersection of sets when at least one of them is small (but I don't know which one that is)?

--
Jeff Brown | Jeffrey Benjamin Brown
Website   |   Facebook   |   LinkedIn(spammy, so I often miss messages here)   |   Github   
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.