[Haskell-cafe] 1p function for NonEmpty

Yitzchak Gale gale at sefer.org
Tue Nov 15 14:19:40 CET 2011

Hi Edward,

I started @telling you on #haskell, but it has become
too long for that. :)

The following functions would be nice additions
to Data.List.NonEmpty in the semigroups package:

replicate1p :: Whole n => n -> a -> NonEmpty a
take1p :: Whole n => n -> NonEmpty a -> NonEmpty a
splitAt1p :: Whole n => n -> NonEmpty a -> (NonEmpty a, [a])

Also, your warnings in the haddocks about blowing up on negative
arguments don't seem to be needed for take, drop, and splitAt.

We could avoid the problem with negative arguments for (!!)
too by providing an alternative for Whole numbers. But in
that case the function would still be partial, so I'm not sure
if it's worth it.

I wish there were some way to get Whole to default
to Natural.


More information about the Haskell-Cafe mailing list