From cca039badec3240c72a6b773802f3a17aceda001 Mon Sep 17 00:00:00 2001 From: michaelt Date: Sat, 6 Feb 2016 17:47:51 -0500 Subject: remarks in pipes-prelude-text --- Pipes/Prelude/Text.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Pipes/Prelude/Text.hs b/Pipes/Prelude/Text.hs index be5b502..29ade4d 100644 --- a/Pipes/Prelude/Text.hs +++ b/Pipes/Prelude/Text.hs @@ -55,7 +55,17 @@ THREE The point of view is very much that of @Pipes.Prelude@. It would still be the same even if we did something more sophisticated, like run an ordinary attoparsec 'Text' parser on - each line, as if frequently reasonable. + each separate line with @Pipes.Prelude.map ()* , as is frequently reasonable. Here we admit + three values from standard input that pass the standard attoparsec @scientific@ number parser, + dropping bad parses with @P.concat@: + +>>> P.toListM $ stdinLn >-> P.map (A.parseOnly A.scientific) >-> P.concat >-> P.take 3 +1 +2 +bad +3 +[1.0,2.0,3.0] + The line-based operations are, however, subject to a number of caveats. First, where they read from a handle, they will of course happily -- cgit v1.2.3