@@ -35,6 +35,7 @@ module TypeFun.Data.List
3535 , UnionList
3636 , AppendUniq
3737 , Intersect
38+ , Substract
3839 -- * Uniqueness checking
3940 , ElementIsUniq
4041 , UniqElements
@@ -195,6 +196,12 @@ type family AppendUniq (a :: k) (s :: [k]) :: [k] where
195196-- taken from first list
196197type Intersect a b = (Indices (CatMaybes (IndicesOfMay a b)) b)
197198
199+-- | Removes from first list all elements occured in second
200+type family Substract (a :: [k]) (b :: [k]) :: [k] where
201+ Substract '[] b = '[]
202+ Substract a '[] = a
203+ Substract a (b ': bs) = Substract (Delete b a) bs
204+
198205-- | Checks that element 'a' occurs in a list just once
199206type ElementIsUniq a s = If (Equal (S Z) (Count a s))
200207 (() :: Constraint)