{-# LANGUAGE
UnicodeSyntax,
MultiParamTypeClasses,
FlexibleInstances,
FunctionalDependencies,
TypeSynonymInstances,
NoImplicitPrelude
#-}moduleData.SetOps(Member(member),(∈),(∉),(∋),(∌),ProperSubsetOf(isProperSubsetOf),(⊂),(⊄),(⊃),(⊅),SubsetOf(isSubsetOf),(⊆),(⊈),(⊇),(⊉),Union(union),(∪),Intersection(intersection),(∩),Empty(empty),(∅),Singleton(singleton),Insert(insert))whereimportqualifiedData.ListasListimportqualifiedData.SetasSetimportqualifiedData.MapasMapimportqualifiedData.IntSetasIntSetimportqualifiedData.IntMapasIntMapimportData.Set(Set)importData.Map(Map)importData.IntSet(IntSet)importData.IntMap(IntMap)importPrelude(Eq,Ord,Bool,Int,flip,uncurry,not,(.))classMemberab|b→awheremember::a→b→BoolclassProperSubsetOfawhereisProperSubsetOf::a→a→BoolclassSubsetOfawhereisSubsetOf::a→a→BoolclassUnionawhereunion::a→a→aclassIntersectionawhereintersection::a→a→aclassEmptyawhereempty::aclassSingletonab|b→awheresingleton::a→bclassInsertab|b→awhereinsert::a→b→b(∈),(∉)::Memberab⇒a→b→Bool(∈)=member(∉)x=not.(x∈)(∋),(∌)::Memberab⇒b→a→Bool(∋)=flip(∈)(∌)=flip(∉)(⊂),(⊄),(⊃),(⊅)::ProperSubsetOfa⇒a→a→Bool(⊂)=isProperSubsetOf(⊄)x=not.(x⊂)(⊃)=flip(⊂)(⊅)=flip(⊄)(⊆),(⊈),(⊇),(⊉)::SubsetOfa⇒a→a→Bool(⊆)=isSubsetOf(⊈)x=not.(x⊆)(⊇)=flip(⊆)(⊉)=flip(⊈)(∪)::Uniona⇒a→a→a(∪)=union(∩)::Intersectiona⇒a→a→a(∩)=intersection-- | .-- The above is a workaround; without at least one Haddock-commented-- function, Haddock does not generate a synopsis.(∅)::Emptya⇒a(∅)=empty{- We don't let ∉ be specialized independently, because it does not make sense to
have a ∉ that is faster than ∈. After all, in that case, one should have defined ∈ as
the negation of ∉ and have it be as fast. The same argument applies to ⊄ and ⊈. -}-- Fixities:infix4∈infix4∉infix4∋infix4∌infix4⊆infix4⊈infix4⊇infix4⊉infix4⊂infix4⊄infix4⊃infix4⊅infixl6∪infixr6∩-- Instances:instanceEqa⇒Membera[a]wheremember=List.eleminstanceOrda⇒Membera(Seta)wheremember=Set.memberinstanceOrdk⇒Memberk(Mapkv)wheremember=Map.memberinstanceMemberIntIntSetwheremember=IntSet.memberinstanceMemberIntMap.Key(IntMapv)wheremember=IntMap.memberinstanceOrda⇒ProperSubsetOf(Seta)whereisProperSubsetOf=Set.isProperSubsetOfinstance(Ordk,Eqv)⇒ProperSubsetOf(Mapkv)whereisProperSubsetOf=Map.isProperSubmapOfinstanceProperSubsetOfIntSetwhereisProperSubsetOf=IntSet.isProperSubsetOfinstanceEqv⇒ProperSubsetOf(IntMapv)whereisProperSubsetOf=IntMap.isProperSubmapOfinstanceOrda⇒SubsetOf(Seta)whereisSubsetOf=Set.isSubsetOfinstance(Ordk,Eqv)⇒SubsetOf(Mapkv)whereisSubsetOf=Map.isSubmapOfinstanceSubsetOfIntSetwhereisSubsetOf=IntSet.isSubsetOfinstanceEqv⇒SubsetOf(IntMapv)whereisSubsetOf=IntMap.isSubmapOfinstanceEqa⇒Union[a]whereunion=List.unioninstanceOrda⇒Union(Seta)whereunion=Set.unioninstanceOrdk⇒Union(Mapkv)whereunion=Map.unioninstanceUnionIntSetwhereunion=IntSet.unioninstanceUnion(IntMapv)whereunion=IntMap.unioninstanceEqa⇒Intersection[a]whereintersection=List.intersectinstanceOrda⇒Intersection(Seta)whereintersection=Set.intersectioninstanceOrdk⇒Intersection(Mapkv)whereintersection=Map.intersectioninstanceIntersectionIntSetwhereintersection=IntSet.intersectioninstanceIntersection(IntMapv)whereintersection=IntMap.intersectioninstanceOrda⇒Inserta[a]whereinsert=List.insertinstanceOrda⇒Inserta(Seta)whereinsert=Set.insertinstanceOrdk⇒Insert(k,v)(Mapkv)whereinsert=uncurryMap.insertinstanceInsertIntIntSetwhereinsert=IntSet.insertinstanceInsert(IntMap.Key,v)(IntMapv)whereinsert=uncurryIntMap.insertinstanceEmpty[a]whereempty=[]instanceEmpty(Seta)whereempty=Set.emptyinstanceEmpty(Mapkv)whereempty=Map.emptyinstanceEmptyIntSetwhereempty=IntSet.emptyinstanceEmpty(IntMapv)whereempty=IntMap.emptyinstanceSingletona[a]wheresingleton=(:[])instanceOrda⇒Singletona(Seta)wheresingleton=Set.singletoninstanceOrdk⇒Singleton(k,v)(Mapkv)wheresingleton=uncurryMap.singletoninstanceSingletonIntIntSetwheresingleton=IntSet.singletoninstanceSingleton(IntMap.Key,v)(IntMapv)wheresingleton=uncurryIntMap.singleton