Subscribe to
Posts
Comments

8 Responses to “What’s in a find function?”

  1. on 02 Jul 2010 at 23:00increpare

    that looks significantly more straight-forward to me type- and behaviour- wise : )

  2. on 02 Jul 2010 at 23:51Conor

    It’s the right functionality, and at the list level it’s the right interface. Go for it.

    How the differential calculus ends up in the prelude is destined to be a longer story.

  3. on 02 Jul 2010 at 23:58Karl

    Don’t you mean:
    find :: Text -> Text -> [(Text,Text,Text)]

  4. on 03 Jul 2010 at 08:30Dougal Stanton

    Since the middle element is always going to be the same, and identical to whatever the user passed in, is there any reason to include it in the output? Apart from the symmetry reasons I suppose. But returning a list of 3-tuples means we can’t use the standard `fst` and `snd` functions for extracting results.

  5. on 03 Jul 2010 at 10:34jtra

    > Since the middle element is always going to be the same, and identical to whatever the user passed in, is there any reason to include it in the output?

    Once you start to do pattern matching instead of just substring search, the actually matched part may be different.

  6. on 03 Jul 2010 at 14:22Alessandro Stamatto

    Yes, i ‘find’ the new version of ‘find’ a lot more intuitive!

  7. on 04 Jul 2010 at 00:21Dan P

    I’ve used a version of this function when computing symbolic derivatives. D(fgh) = D(f) g h + f D(g) h + f g D(h) etc. It’s curious (but not completely surprising) that computing derivatives of functions makes use of one of the standard functions attached to derivatives of types.

  8. on 06 Jul 2010 at 19:52Duncan Coutts

    Yes, we discussed revising find yet again on the #ghc channel a month or so ago. Despite having pushed you towards the one with type Text -> Text -> (Text, [(Text, Text)]), I realised I still was not happy with it either.

    The one we discussed more recently is similar to what you are proposing now. I think the difference was that in what I suggested, the middle component of the tuple went to the end of the text, i.e. it was a prefix of the last component.

    I think the rationale for that was that you already know what you searched for and we can save time and space by providing the full tail rather than making new texts by recomposing the search term with the trailing string.

Leave a Reply