Is there a copy’n’paste error in
Prelude> dropPrefix “foolish” “football”
(“lish”, “ball”)
which should rather be
Prelude> dropPrefix “foolish” “football”
(“lish”, “tball”)
?
I don’t know about newer GHCs, but in 6.8.1, dropPrefix “foo” “foobar” gives a pattern match error (since left becomes [] after some time).
Also, what is the “after” function for?
Instead of writing your own ‘dropPrefix’, there is also the standard ‘stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]‘, which you can also use with view patterns:
{-# LANGUAGE ViewPatterns #-}
genbankHeader (stripPrefix “>gi|” -> Just rest) = muddle rest
Is there a copy’n’paste error in
Prelude> dropPrefix “foolish” “football”
(“lish”, “ball”)
which should rather be
Prelude> dropPrefix “foolish” “football”
(“lish”, “tball”)
?
I don’t know about newer GHCs, but in 6.8.1, dropPrefix “foo” “foobar” gives a pattern match error (since left becomes [] after some time).
Also, what is the “after” function for?
Marc: presumably ‘after’ was the original name of dropPrefix. Rename it, and the function starts working.
The ‘otherwise’ line is unnecessary, btw.
Oops, thanks for noticing those thinkos, gentlemen. That’s what I get for composing a post at midnight!
Instead of writing your own ‘dropPrefix’, there is also the standard ‘stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]‘, which you can also use with view patterns:
{-# LANGUAGE ViewPatterns #-}
genbankHeader (stripPrefix “>gi|” -> Just rest) = muddle rest