]> git.immae.eu Git - github/fretlink/text-pipes.git/commitdiff
remarks in pipes-prelude-text
authormichaelt <what_is_it_to_do_anything@yahoo.com>
Sat, 6 Feb 2016 22:47:51 +0000 (17:47 -0500)
committermichaelt <what_is_it_to_do_anything@yahoo.com>
Sat, 6 Feb 2016 22:47:51 +0000 (17:47 -0500)
Pipes/Prelude/Text.hs

index be5b502002c1496aa281abfaf35e035cc514ee0c..29ade4d1c0a3a10910864ed38e04486792f53075 100644 (file)
@@ -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<Enter>
+2<Enter>
+bad<Enter>
+3<Enter>
+[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