Skip to content

Instantly share code, notes, and snippets.

@AphonicChaos
Created February 11, 2016 04:51
Show Gist options
  • Save AphonicChaos/6663f5a89af9de56c296 to your computer and use it in GitHub Desktop.
Save AphonicChaos/6663f5a89af9de56c296 to your computer and use it in GitHub Desktop.
module Main where
import Data.Set hiding (foldr)
fromFoldable :: (Foldable f, Ord a) => f a -> Set a
fromFoldable = foldr insert empty
someSet = fromList [1, 2, 2, 3]
main = do
-- the first fromList could have been fromFoldable, but I wanted to show compatibility with the builtin functions
print $ intersection someSet (fromFoldable [2, 3, 4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment