removeDups :: V.Vector FieldInfo -> (FieldInfo -> FieldInfo -> Bool) -> V.Vector FieldInfo
removeDups fis pred = V.reverse $ V.fromList $ go fis []
    where
        go fis acc
            | V.null fis = acc
            | otherwise =
                let fi = V.head fis
                    tail = V.tail fis
                    dupInds = V.findIndices (pred fi) tail
                in if V.null dupInds
                    then go tail $ fi:acc
                    else let dups = V.cons fi $ V.map (\idx -> unsafeIndex tail idx) dupInds
                             tail' = V.ifilter (\idx _ -> not $ V.elem idx dupInds) tail
                         in go tail' $ fi:acc
removeDups :: V.Vector FieldInfo -> (FieldInfo -> FieldInfo -> Bool) -> V.Vector FieldInfo
removeDups fis pred = V.reverse $ V.fromList $ go fis []
    where
        go fis acc
            | V.null fis = acc
            | otherwise =
                let fi = V.head fis
                    tail = V.tail fis
                    dupInds = V.findIndices (pred fi) tail
                in if V.null dupInds
                    then go tail $ fi:acc
                    else let dups = V.cons fi $ V.map (\idx -> unsafeIndex tail idx) dupInds
                             tail' = V.ifilter (\idx _ -> not $ V.elem idx dupInds) tail
                         in go tail' $ fi:acc
removeDups fis pred = V.reverse $ V.fromList $ go fis []
    where
        go fis acc
            | V.null fis = acc
            | otherwise =
                let fi = V.head fis
                    tail = V.tail fis
                    dupInds = V.findIndices (pred fi) tail
                in if V.null dupInds
                    then go tail $ fi:acc
                    else let dups = V.cons fi $ V.map (\idx -> unsafeIndex tail idx) dupInds
                             tail' = V.ifilter (\idx _ -> not $ V.elem idx dupInds) tail
                         in go tail' $ fi:acc