
26 Jun
2007
26 Jun
'07
10:07 p.m.
Ian Lynagh wrote:
The definition is:
dropPrefix :: Eq a => [a] -> [a] -> Maybe [a] dropPrefix [] ys = Just ys dropPrefix (x:xs) (y:ys) | x == y = dropPrefix xs ys dropPrefix _ _ = Nothing
Hmm. That would replace a function I write today if only it were: 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 don't know if you'd consider this desire common enough to do the standard library that way, but I noticed this, so I figured I'd mention something. -- Chris Smith