logoalt Hacker News

dasyatidprimeyesterday at 5:41 PM1 replyview on HN

The NonEmptyList in Cats is a product (struct/tuple) type, though; I assume the Haskell version is the same. The type shown in the blog post is a sum (union) type which can contain an empty enumerable, which contradicts the name OneOrMore. The use described for the type in the post (basically a convenience conversion funnel) is different and makes sense in its own right (though it feels like kind of a weak use case). I'm not sure what a good name would've been illustratively that would've been both accurate and not distracting, though.


Replies

merbyesterday at 6:56 PM

Well you are right of course, I just wanted to explain what they wanted to show. Of course the type would be wrong if the second entry in itself is an empty list. I just wanted to explain the reasoning what they tried to accomplish

They could’ve done the Either type which would’ve been more correct or maybe EitherT (if the latter is even possible)

show 1 reply