[Haskell-beginners] Can't cast an IO String to s Astring

chanti houda houdachanti at yahoo.fr
Fri Oct 23 15:32:50 UTC 2015

Hello, I'm writing a Haskell code which consists to read a text file, parse it and thansform the parsing result on a specific language.I have a function affiche which takes a data type Ctrl and returns a String. This is the transformation funtion.I have also anothe function parsctrl, which parse the contents of a text file ("ctrl.txt") and after looks for a specific value ("A01") in the parse result (function cherchectrl). 
I need to use the result of the parsectrl function in another function fc.  
The code is composed of three functions 

parsectrl = do
 f <- readFile "ctrl.txt"
 let Right r = parse  parseCtrl  " " f let rez =cherchectrl ( r) "A01"
 return (rez)
fc[]  =[] 
fc((door,[(all,v1),(alt,v2),(lint,v3),(w,v4),(r,v5),(loc,v6),( etat,v7),(ruin,v8)]):ls ) = ("&OUV ID='"++door ++"', ALLEGE="++show((moi v1)/1000)++", LINTEAU="++show((moi v3)/1000)++", LARGEUR="++show((moi v4)/1000)++", COEF=0.7, ALT="++show((moi v2)/1000)++", LOCIDS='"++v6++"', CTRLID='"++ v7++"', CTRLID_RUIN='"++ v8++" /" ++"\n" ++"&CTRL ID='"++v7++"', " ++ "ON_INI=.FALSE., DURATION=0 / \n"++"&CTRL ID='"++v8++"', LOCID='"++  ((parses("'"++v6++"'"))!!0) ++affiche(parsectrl)++ " / \n\n"  )++fc(ls)

The parsectrl returns an IO String, but the function affiche needs a String as input and even when I tried to adapt the affiche function to take an  IO String -> String I can't.the result of fc must be a String too.
The IO String comes from the parsectrl function.
Can you help me to solve this problem: how can I transform an IO String to a String.
Thank you by advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151023/be951e9e/attachment-0001.html>

More information about the Beginners mailing list