I'd like a function that takes a ByteString and replaces newlines \n and \n\r with commas, but can't think of a nice way to do it.
import qualified Data.ByteString as BS
import Data.Char (ord)
import Data.Word (Word8)
endlWord8 = fromIntegral $ ord '\n' :: Word8
replace :: BS.ByteString -> BS.ByteString
I thought of using BS.map but can't see how since I can't pattern match on Word8's. Another option would be BS.split and then join with Word8 commas, but that sounds slow and inelegant. Any ideas?