Making a single function work on lists, ByteStrings and Texts (and perhaps other similar representations)
问题 I'm writing a function that does some searching in a sequence of arbitrary symbols. I'd like to make it generic enough so that it works on lists, Foldable s as well on ByteString s and Text s. Generalizing it to Foldable is simple. But how to include ByteString s and Text s? Sure I could convert ByteString into a list and then call my function, but I'd lose all the advantages ByteString s. To have a concrete example let's say we want to make a histogram function: import Control.Monad.State