# Remove duplicates from list

I have datatype:

```data SidesType = Sides Int Int Int deriving (Show)
```

And I need a function which get a list of SidesType and remove duplicates from it.

```*Main> let a = [Sides 3 4 5,Sides 3 4 5,Sides 5 12 13,Sides 6 8 10,Sides 6 8 10,Sides 8 15 17,Sides 9 12 15,Sides 5 12 13,Sides 9 12 15,Sides 12 16 20,Sides 8 15 17,Sides 15 20 25,Sides 12 16 20,Sides 15 20 25]
*Main> removeDuplicateFromList [] a
[Sides 3 4 5,Sides 5 12 13,Sides 6 8 10,Sides 6 8 10,Sides 8 15 17,Sides 9 12 15,Sides 5 12 13,Sides 9 12 15,Sides 12 16 20,Sides 8 15 17,Sides 15 20 25,Sides 12 16 20,Sides 15 20 25]
```

Here is my solution:

```removeElementFromList :: [SidesType] -> SidesType -> [SidesType]
removeElementFromList lst element  =
let (Sides a b c) = element
in [(Sides x y z) | (Sides x y z) <- lst, (x /= a) || (y /= b)]

removeDuplicateFromList :: [SidesType] -> [SidesType] -> [SidesType]
removeDuplicateFromList inlist outlist
| (length outlist) == 0 = inlist
| otherwise =
b = tail outlist
filtered = removeElementFromList b element
in removeDuplicateFromList (inlist ++ [element]) filtered
```

I am just wondering if there is any other way to write this code in more haskell-way ?

As usual there is "By" function which adds flexibility:

```nubBy :: (a -> a -> Bool) -> [a] -> [a]
```

PS Although it's O(n^2)