It seems that these two functions in Data.Attoparsec.Combinator might have had NonEmpty a rather than [a] in their return types, since they are never supposed to yield an empty list.
many1 :: Alternative f => f a -> f [a]
sepBy1 :: Alternative f => f a -> f s -> f [a]
Perhaps we might introduce additional combinators?
manyNE :: Alternative f => f a -> f (NonEmpty a)
sepByNE :: Alternative f => f a -> f s -> f (NonEmpty a)
The code I'm writing at the moment applies Data.List.last to the result of sepBy1, and I believe being able to instead apply Data.List.NonEmpty.last to the result of sepByNE would bring me happiness.
It seems that these two functions in
Data.Attoparsec.Combinator
might have hadNonEmpty a
rather than[a]
in their return types, since they are never supposed to yield an empty list.Perhaps we might introduce additional combinators?
The code I'm writing at the moment applies
Data.List.last
to the result ofsepBy1
, and I believe being able to instead applyData.List.NonEmpty.last
to the result ofsepByNE
would bring me happiness.