purescript/purescript-lists

Add Data.List.NonEmpty.deleteAt

jamesdbrock opened this issue · 4 comments

https://pursuit.purescript.org/packages/purescript-lists/5.4.1/docs/Data.List.NonEmpty

Data.List.NonEmpty.deleteAt function doesn't exist, but

do exist. Seems like we should add Data.List.NonEmpty.deleteAt ?

deleteAt :: forall a. Int -> NonEmptyList a -> Maybe (List a)

deleteAt :: forall a. Int -> NonEmptyList a -> Maybe (List a)
deleteAt i (NonEmptyList (x :| xs))
  | i == 0 = Just xs
  | otherwise = L.Cons x <$> L.deleteAt (i - 1) xs

Also alterAt?

garyb commented

Adding these sounds good to me!