thank you tom,
in fact reading doc as i saw i never used return read in monad doc i already put it in my code this gives this that compiles:
let lstNamesBD = Prelude.map (\(Only name) ->
do
let strName = Text.unpack name
getBD conn strName >>= (\bd ->
return (strName,bd)))
names
but sticked now for displaying it because it is now an IO tuple of 2 and i can not display it with some functions like this , it fails to compile:
-- putStr "lstNamesBD ="
-- putStrLn $ show lstNamesBD
forM_ lstNamesBD $ \t2 ->
do
n <- fst t2
b <- snd t2
putStrLn $ (show n) ++ " " ++ maybe "NULL" show b
or with that tested first:
forM_ lstNamesBD $ \(name,bd) ->
putStrLn $ (show name) ++ " " ++ maybe "NULL" show bd
Prelude> :load UpdateSidonie
[1 of 1] Compiling Main ( UpdateSidonie.hs, interpreted )
UpdateSidonie.hs:207:22: error:
• Couldn't match expected type ‘(IO a1, b0)’
with actual type ‘IO (String, Maybe Float)’
• In the first argument of ‘fst’, namely ‘t2’
In a stmt of a 'do' block: n <- fst t2
In the expression:
do n <- fst t2
b <- snd t2
putStrLn $ (show n) ++ " " ++ maybe "NULL" show b
|
207 | n <- fst t2
| ^^
UpdateSidonie.hs:208:22: error:
• Couldn't match expected type ‘(a0, IO (Maybe a2))’
with actual type ‘IO (String, Maybe Float)’
• In the first argument of ‘snd’, namely ‘t2’
In a stmt of a 'do' block: b <- snd t2
In the expression:
do n <- fst t2
b <- snd t2
putStrLn $ (show n) ++ " " ++ maybe "NULL" show b
|
208 | b <- snd t2
| ^^
UpdateSidonie.hs:211:25: error:
• Couldn't match expected type ‘IO (String, Maybe Float)’
with actual type ‘(a3, Maybe a4)’
• In the pattern: (name, bd)
In the second argument of ‘($)’, namely
‘\ (name, bd)
-> putStrLn $ (show name) ++ " " ++ maybe "NULL" show bd’
In a stmt of a 'do' block:
forM_ lstNamesBD
$ \ (name, bd)
-> putStrLn $ (show name) ++ " " ++ maybe "NULL" show bd
|
211 | forM_ lstNamesBD $ \(name,bd) ->
| ^^^^^^^^^
Failed, no modules loaded.
Prelude>