[Haskell-cafe] fmap use
Tom Ellis
tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Fri Dec 14 11:22:38 UTC 2018
On Fri, Dec 14, 2018 at 11:49:45AM +0100, Damien Mattei wrote:
> another question with Haskell, again with my database but that is again
> related to Monads:
Damien, it's very hard to read your posts because they consist of snippets
of code interspersed with commentary. You'll probably get much better
responses if you post single, very small, well-formatted examples of sample
code.
Anyway, the ultimate answer to your query is "use do-notation". Your
getBS_WDS would be clearer written something like:
```
getBD_WDS :: Connection -> String -> IO Float
getBD_WDS conn name = do
let qry_head = "select DNUM from WDS where DISC = ?" :: Query
bd_rows <- query conn qry_head (Only name)
let noBDtxt :: Text
noBDtxt = fromOnly (Prelude.head bd_rows)
noBDstr :: String
noBDstr = Text.unpack noBDtxt
noBDfp :: Float
noBDfp = read noBDstr
return noBDfp
```
Tom
More information about the Haskell-Cafe
mailing list