Created
July 3, 2017 11:40
-
-
Save leonderijke/18f04f991a5f1945876e285249f5c8ad to your computer and use it in GitHub Desktop.
EverySet: Set wrapper for using union types in a Set, using `toString` as a hashing function. Can only be used on type that can be stringified.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module EverySet | |
exposing | |
( EverySet | |
, empty | |
, insert | |
, isEmpty | |
, member | |
, remove | |
) | |
import Set exposing (Set) | |
type alias EverySet = | |
Set String | |
hash : a -> String | |
hash = | |
toString | |
empty : EverySet | |
empty = | |
Set.empty | |
isEmpty : EverySet -> Bool | |
isEmpty everySet = | |
Set.isEmpty everySet | |
insert : a -> EverySet -> EverySet | |
insert item everySet = | |
Set.insert (hash item) everySet | |
member : a -> EverySet -> Bool | |
member item everySet = | |
Set.member (hash item) everySet | |
remove : a -> EverySet -> EverySet | |
remove item everySet = | |
Set.remove (hash item) everySet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment