i have this function:

-- this function will return th N°BD from Sidonie for a given name
-- note: names have been standardized between Sidonie and WDS
getBD :: Connection -> String -> IO Float
getBD conn name = trace "Entering getBD" noBDfp
  where qry_head = "select `N° BD` from Coordonnées where Nom = ?" :: Query
        bd_rows :: IO [Only Text]
        bd_rows = query conn qry_head (Only (name::String))
--        noBDtxt :: [Text]
--        noBDtxt = fromOnly (Prelude.head bd_rows)
--        noBDtxt :: IO [Text]
--        lg = fmap Prelude.length bd_rows
--        lg2 = fmap show lg
        noBDtxt :: IO Text
--        noBDtxt = trace "lg " (fmap (fromOnly . Prelude.head) bd_rows)
        noBDtxt = trace "assigning noBDtxt" (fmap (fromOnly . Prelude.head) bd_rows)
--        noBDstr :: String
--        noBDstr = Text.unpack noBDtxt
        noBDstr :: IO String
        noBDstr = trace "assigning noBDstr" (fmap Text.unpack noBDtxt)
--        noBDfp = read $ noBDstr :: Float
        noBDfp :: IO Float
        noBDfp = fmap read noBDstr


call by :

let lstBD = Prelude.map (\elem ->
                                  getBD conn (Text.unpack (fst elem)))
                            rows

it works ok, in fact at some point it fails due to NULL sql value not again handle correctly , i have inserted trace statement that output variable, i understand it's not really good becaus it breaks the purity of haskell function, perheaps for this reason i have strange behavior of output:
...
Entering getBD
assigning noBDstr
assigning noBDtxt
Entering getBD
assigning noBDstr
assigning noBDtxt
Entering getBD
assigning noBDstr
assigning noBDtxt
*** Exception: UnexpectedNull {errSQLType = "VarString", errHaskellType = "Text", errFieldName = "N\194\176 BD", errMessage = "unexpected null in table Coordonn\195\169es of database sidonie"}
*Main>
you will notice noBDstr seems to be assigned before noBDtxt, but in the code i have the statements in this order:
        noBDtxt = trace "assigning noBDtxt" (fmap (fromOnly . Prelude.head) bd_rows)
        noBDstr :: IO String
        noBDstr = trace "assigning noBDstr" (fmap Text.unpack noBDtxt)

i just want to understand wht's happening, this is not critical for code as it works...
any idea?

Damien