@@ -1,13 +1,13 @@
1{-# LANGUAGE GADTs, DataKinds, KindSignatures, TypeOperators, TypeFamilies,
1{-# LANGUAGE GADTs, DataKinds, KindSignatures, TypeOperators, TypeFamilies,
2 MultiParamTypeClasses, FlexibleInstances, PolyKinds,
2 MultiParamTypeClasses, FlexibleInstances, PolyKinds,
3 FlexibleContexts, UndecidableInstances, ConstraintKinds,
3 FlexibleContexts, UndecidableInstances, ConstraintKinds,
4− ScopedTypeVariables, TypeInType #-}
4+ ScopedTypeVariables #-}
6module Data.Type.Set (Set(..), Union, Unionable, union, quicksort, append,
6module Data.Type.Set (Set(..), Union, Unionable, union, quicksort, append,
7 Sort, Sortable, (:++), Split(..), Cmp, Filter, Flag(..),
7 Sort, Sortable, (:++), Split(..), Cmp, Filter, Flag(..),
8 Nub, Nubable(..), AsSet, asSet, IsSet, Subset(..),
8 Nub, Nubable(..), AsSet, asSet, IsSet, Subset(..),
9 Delete(..), Proxy(..), remove, Remove, (:\),
9 Delete(..), Proxy(..), remove, Remove, (:\),
10− Member(..), NonMember, MemberP(..)) where
10+ Member) where
12import GHC.TypeLits
12import GHC.TypeLits
13import Data.Type.Bool
13import Data.Type.Bool
@@ -16,7 +16,7 @@ import Data.Type.Equality
16data Proxy (p :: k) = Proxy
16data Proxy (p :: k) = Proxy
18-- Value-level 'Set' representation, essentially a list
18-- Value-level 'Set' representation, essentially a list
19−data Set (n :: [k]) where
19+data Set (n :: [k]) :: * where
20 {--| Construct an empty set -}
20 {--| Construct an empty set -}
21 Empty :: Set '[]
21 Empty :: Set '[]
22 {--| Extend a set with an element -}
22 {--| Extend a set with an element -}
@@ -77,7 +77,7 @@ append (Ext e xs) ys = Ext e (append xs ys)
77{-| Delete elements from a set -}
77{-| Delete elements from a set -}
78type family (m :: [k]) :\ (x :: k) :: [k] where
78type family (m :: [k]) :\ (x :: k) :: [k] where
79 '[] :\ x = '[]
79 '[] :\ x = '[]
80− (x ': xs) :\ x = xs :\ x
80+ (x ': xs) :\ x = xs
81 (y ': xs) :\ x = y ': (xs :\ x)
81 (y ': xs) :\ x = y ': (xs :\ x)
83class Remove s t where
83class Remove s t where
@@ -86,8 +86,8 @@ class Remove s t where
86instance Remove '[] t where
86instance Remove '[] t where
87 remove Empty Proxy = Empty
87 remove Empty Proxy = Empty
89−instance {-# OVERLAPS #-} Remove xs x => Remove (x ': xs) x where
89+instance {-# OVERLAPS #-} Remove (x ': xs) x where
90− remove (Ext _ xs) x@Proxy = remove xs x
90+ remove (Ext _ xs) Proxy = xs
92instance {-# OVERLAPPABLE #-} (((y : xs) :\ x) ~ (y : (xs :\ x)), Remove xs x)
92instance {-# OVERLAPPABLE #-} (((y : xs) :\ x) ~ (y : (xs :\ x)), Remove xs x)
93 => Remove (y ': xs) x where
93 => Remove (y ': xs) x where
@@ -227,10 +227,3 @@ instance {-# OVERLAPS #-} Member a (a ': s) where
228instance {-# OVERLAPPABLE #-} Member a s => Member a (b ': s) where
228instance {-# OVERLAPPABLE #-} Member a s => Member a (b ': s) where
229 member a (Ext _ xs) = member a xs
229 member a (Ext _ xs) = member a xs
231−type family MemberP a s :: Bool where
232− MemberP a '[] = False
233− MemberP a (a ': s) = True
234− MemberP a (b ': s) = MemberP a s
236−type NonMember a s = MemberP a s ~ False