[Haskell-cafe] fmap use

Tom Ellis tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Fri Dec 14 11:45:44 UTC 2018

On Fri, Dec 14, 2018 at 11:22:38AM +0000, Tom Ellis wrote:
> 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:

And ultimately I think you wanted to do something with lg and tst:

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 lg = Prelude.length bd_rows

    putStrLn (if lg > 1 then "some" else "one or zero")

    let noBDtxt :: Text
        noBDtxt = fromOnly (Prelude.head bd_rows)
        noBDstr :: String
        noBDstr = Text.unpack noBDtxt

        noBDfp :: Float
        noBDfp = read noBDstr

    return noBDfp

More information about the Haskell-Cafe mailing list