<div dir="ltr">The type of "SP.mapM_ putStrLn str" is IO (), so I don't think "SP.length_ (SP.mapM_ putStrLn str)" type checks, unless I'm somehow misreading your code.<br><div><br></div><div>Anyway, I just realized I can use SP.copy:</div><div><br></div><div> do</div><div> l <- SP.mapM_ putStrLn $ SP.length_ $ SP.copy str</div><div> print l</div><div><br></div><div>"l <- SP.length_ $ SP.mapM_ putStrLn $ SP.copy str" also works.<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 3, 2020 at 3:23 PM Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2017@jaguarpaw.co.uk">tom-lists-haskell-cafe-2017@jaguarpaw.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Jun 03, 2020 at 03:04:59PM +0800, ☂Josh Chia (謝任中) wrote:<br>
> I want to putStrLn each element and then print the length of str<br>
[...]<br>
> doit :: Stream (Of String) IO () -> IO ()<br>
> doit str =<br>
> do<br>
> SP.mapM_ putStrLn str<br>
> SP.length_ str >>= print<br>
<br>
Isn't it<br>
<br>
SP.length_ (SP.mapM_ putStrLn str) >>= print<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>