[Haskell-cafe] Re: Write Haskell as fast as C.

Ketil Malde ketil at malde.org
Fri May 16 18:31:25 EDT 2008

Dan Weston <westondan at imageworks.com> writes:

>>> mkAnn :: ByteString -> Annotation
>>> mkAnn = pick . B.words
>>>     where pick (_db:up:rest) = pick' up $ getGo rest
>>>           pick' up' (go:_:ev:_) = Ann (B.copy up') (read $ B.unpack go) (read $ B.unpack ev)
>>>           getGo = dropWhile (not . B.isPrefixOf (pack "GO:"))

> It seems at first face miraculously coincidental that the dropWhile in
> the getGo definition knows to stop dropping when there are exactly 4
> elements, in order to match the pattern in the second parameter of the
> pick' definition, whose argument is provided by (getGo Rest).

> What magic makes this true? Just curious...

You want the long story? :-)

This is for parsing the GOA file format, which contains links between
proteins from the UniProt database to Gene Onthology (GO) terms.  The
format is not quite as regular as one would wish, but the second word
is always the protein id, and whenever the GO term turns up, it is
followed by something I forget (an InterPro reference perhaps) and
then the evidence code - which I want.

You feel happier now, I can tell.

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list