Proposal #1464: add dropPrefix to Data.List
stefan at cs.uu.nl
Wed Jun 27 01:11:40 EDT 2007
> dropPrefix :: (Monad m, Eq a) => [a] -> [a] -> m [a]
> dropPrefix  ys = return ys
> dropPrefix (x:xs) (y:ys)
> | x == y = dropPrefix xs ys
> dropPrefix _ _ = fail "parse error"
I also would like a monadic variant better (cf. Data.Map.lookup).
However, I'd name it differently---not sure how, though---and reserve
dropPrefix :: (Eq a) => [a] -> [a] -> [a]
dropPrefix prefix l = go prefix l where
go (x : xs) (y : ys) | x == y = go xs ys
go  ys = ys
go _ _ = l
which, to me, at least, seems more in line with drop and dropWhile.
Just my two cents, though.
More information about the Libraries