[Haskell-cafe] Using streams to clarify (?) the signature of Data.Text.replace

Daniel Díaz diaz.carrete at gmail.com
Sun Jun 26 14:39:28 UTC 2016


In the "text" package, the signature of Data.Text.replace 
<http://hackage.haskell.org/package/text-1.2.2.1/docs/Data-Text.html#v:replace> 
always sends me looking into the haddocks:

replace :: Text -> Text -> Text -> Text  


Which argument is the text to replace, which is the replacement and which 
is the text that should be scanned?

Imagine a generalized version of replace that 1) works on streams, and 2) 
allows replacing a sequence of texts (like, say, chapter headers) instead 
of replacing the same text repeatedly. It could have the following 
signature:

replace' :: Stream (Stream (Of Text) m) m ()
>             -> Stream (Stream (Of Text) m) m Void
>             -> Stream (Of Text) m r
>             -> Stream (Of Text) m r


Do you find easy to intuit, just by looking at that signature, which is the 
function of each argument?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160626/13c43c26/attachment.html>


More information about the Haskell-Cafe mailing list