Scala / Cats: How to unzip an NonEmptyList
You don't have to do it all in one traversal, and often you don't even want to use one of the parts. I would write it like:
(nel.map(_._1), nel.map(_._2))
This avoids the awkward conversion away from an NEL and back.
You could simply call nel.toList
and use the standard l.unzip
and then NonEmptyList.fromList(unziped_list)
on the result.
Edit: As @Dylan said, you could also use .fromListUnsafe
to get rid of the option.