Proposal #1464: add dropPrefix to Data.List

Tomasz Zielonka tomasz.zielonka at gmail.com
Wed Jun 27 01:44:23 EDT 2007


On Tue, Jun 26, 2007 at 10:00:02PM -0700, Iavor Diatchki wrote:
> I can see how this function can be useful.  However, I am strongly
> opposed to adding the general monadic version---not all monads support
> graceful failure, and for monads that do not support it, the only
> option is to throw a run-time exception, which is at odds with the
> purity of Haskell (which leads to headaches when you try to write
> robust code).  I think that the "Maybe" version is perfectly adequate
> but if we have to have an overloaded version, then we should use
> "MonadPlus".

Also, no functions in Data.List work with Monads right now, so this
one would be an exception. If dropPrefix is to use Monad interface, so
should find, findIndex, lookup and elemIndex.

$ echo ':b Data.List' | ghci | grep Monad

$ echo ':b Data.List' | ghci | grep Maybe
lookup :: (Eq a) => a -> [(a, b)] -> Maybe b
elemIndex :: (Eq a) => a -> [a] -> Maybe Int
find :: (a -> Bool) -> [a] -> Maybe a
findIndex :: (a -> Bool) -> [a] -> Maybe Int
unfoldr :: (b -> Maybe (a, b)) -> b -> [a]

Best regards
Tomek


More information about the Libraries mailing list