[Haskell-beginners] XML output

Manfred Lotz manfred.lotz at arcor.de
Wed Sep 5 06:34:36 CEST 2012


On Tue, 04 Sep 2012 22:33:56 +0200
"Torsten Otto" <T-Otto-News at gmx.de> wrote:

> Hi, all!
> 
> I'm struggling with a strange phenomenon.
> If I read a file containing
> 
> __
> a
> b
> c
> __
> 
> the program below works as expected. If I read a svg file
> __
> <?xml version="1.0"?>
> <svg xmlns="http://www.w3.org/2000/svg">
> <rect x="0" y="0" width="180" height="180" fill="white"/> 
> </svg>
> ___
> the first two lines are not processed.
> 
> Program:
> __
> module SVG()
> where
> 
> import IO
> 
> main :: IO ()
> main = do
>  s <- readFile "sierpinski1.svg"
>  putStrLn s
>  writeFile "sierpinski1_.svg" s
> __
> 
> Results of putStrLn:
> __
> *SVG> main
> a
> b
> c
> *SVG> main
> <rect x="0" y="0" width="180" height="180" fill="white"/> 
> </svg>
> *SVG> 
> __
> 
> File Output lists the whole file, though.
> 
> I don't understand this, why is GHCi stripping the output this way?
> 
> Thanks,
> regards,
> Torsten
> 


I got a compile error, and had to change 
  import IO
to
  import System.IO

Then it worked fine, i.e. all lines of were printed to stdout as well as
written to the output file.


What is you ghci version?



-- 
Manfred





More information about the Beginners mailing list