@@ -9,7 +9,6 @@ module TypeFun.Data.List
99 , Drop
1010 , Take
1111 , Delete
12− , Remove
1312 , (:++:)
1413 -- * Elements lookup
1514 , IndexOf
@@ -35,14 +34,10 @@ module TypeFun.Data.List
3534 , UnionList
3635 , AppendUniq
3736 , Intersect
38− , Substract
3937 -- * Uniqueness checking
4038 , ElementIsUniq
4139 , UniqElements
4240 , UniqElements'
43− -- * Unsafe helpers
44− , appendId
45− , subListId
4641 ) where
4742
4843import Data.Type.Bool
@@ -51,7 +46,6 @@ import GHC.TypeLits
5146import TypeFun.Data.Eq
5247import TypeFun.Data.Maybe
5348import TypeFun.Data.Peano
54−import Unsafe.Coerce
5549
5650------------------------------------------------------------------------
5751-- NOTE: Errors type classes. These type classes are not in separate --
@@ -98,23 +92,10 @@ type family Delete (a :: k) (s :: [k]) :: [k] where
9892 Delete a (a ': as) = Delete a as
9993 Delete a (b ': as) = b ': (Delete a as)
10094
101−-- | Remove index from the list
102−type family Remove (i :: N) (a :: [k]) :: [k] where
103− Remove i '[] = '[]
104− Remove 'Z (a ': as) = as
105− Remove ('S i) (a ': as) = a ': (Remove i as)
106−
10795type family (:++:) (a :: [k]) (b :: [k]) :: [k] where
10896 '[] :++: b = b
10997 (a ': as) :++: b = a ': (as :++: b)
11098
111−appendId
112− :: forall proxy l r
113− . proxy l
114− -> (l ~ (l :++: '[]) => r)
115− -> r
116−appendId = unsafeCoerce id
117−
11899type IndexOf a s = FromJust (IndexOfMay a s)
119100
120101type IndexOfMay a s = IndexOfMay' Z a s
@@ -168,12 +149,6 @@ type family SubList (a :: [k]) (b :: [k]) :: Constraint where
168149 SubList '[] bs = ()
169150 SubList (a ': as) bs = (Elem a bs, SubList as bs)
170151
171−subListId
172− :: forall proxy l r
173− . proxy l
174− -> (SubList l l => r) -> r
175−subListId _ = unsafeCoerce id
176−
177152type family NotSubList (a :: [k]) (b :: [k]) :: Constraint where
178153 NotSubList '[] bs = ()
179154 NotSubList (a ': as) bs = (NotElem a bs, NotSubList as bs)
@@ -213,12 +188,6 @@ type family AppendUniq (a :: k) (s :: [k]) :: [k] where
213188-- taken from first list
214189type Intersect a b = (Indices (CatMaybes (IndicesOfMay a b)) b)
215190
216−-- | Removes from first list all elements occured in second
217−type family Substract (a :: [k]) (b :: [k]) :: [k] where
218− Substract '[] b = '[]
219− Substract a '[] = a
220− Substract a (b ': bs) = Substract (Delete b a) bs
221−
222191-- | Checks that element 'a' occurs in a list just once
223192type ElementIsUniq a s = If (Equal (S Z) (Count a s))
224193 (() :: Constraint)