Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nub type family #27

Closed
3noch opened this issue Aug 3, 2016 · 1 comment
Closed

Fix Nub type family #27

3noch opened this issue Aug 3, 2016 · 1 comment
Labels

Comments

@3noch
Copy link
Contributor

3noch commented Aug 3, 2016

I don't think it works on non-consecutive duplicates.

@3noch 3noch added the bug label Aug 3, 2016
@fizruk
Copy link
Contributor

fizruk commented Aug 5, 2016

Here's efficient and correct Nub implementation (from servant-swagger):

-- | Remove duplicates from a type-level list.
type family Nub xs where
  Nub '[] = '[]
  Nub (x ': xs) = x ': Nub (Remove x xs)

-- | Remove element from a type-level list.
type family Remove x xs where
  Remove x '[]       = '[]
  Remove x (x ': ys) =      Remove x ys
  Remove x (y ': ys) = y ': Remove x ys

3noch added a commit that referenced this issue Aug 5, 2016
Fixes #27
@3noch 3noch mentioned this issue Aug 5, 2016
@dmjio dmjio closed this as completed in #33 Aug 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants