haskell - Data.ConfigFile not using the Bool instance of get -


according https://hackage.haskell.org/package/configfile-1.0.5/docs/data-configfile.html, package convert value in config. file bool. following code:

{-# language flexiblecontexts #-}   import qualified data.configfile dc import qualified control.monad.except cme   -- | foundation object data jrstate = jrstate {         secureonly :: bool  -- ^ restrict connections https     }   main :: io () main = (cme.runexceptt $ pipe (jrstate false)) >>= estate   estate :: show t => either t jrstate -> io () estate (right state) = return () estate (left err) =     putstrln $ "<<" ++ show err ++ ">>"     return ()   pipe :: (cme.monaderror dc.cperror m, cme.monadio m) => jrstate -> m jrstate pipe site =     cp <- cme.join $ cme.liftio $ return $ dc.readstring dc.emptycp{dc.optionxform=id} "securesession = true\n"     dc.get cp "default" "securesession" >>= return . nubb         nubb (left err) = error err         nubb (right value) = site{secureonly = value} 

when run, produces

<<(parseerror "couldn't parse value true (default/securesession)","genericget")>>

which has come putstrln in estate. expect extraction of value, in pipe , nubb (silly names, know) force boolean context , force conversion of true string bool. i've tried 1 , yes same result. what's going on?

here more minimal program problematic behavior:

import qualified data.configfile dc import qualified control.monad.except cme  main = cme.runexceptt pipe >>= print pipe =     cp <- dc.readstring dc.emptycp{dc.optionxform=id} "securesession = true\n"     dc.get cp "default" "securesession" >>= nubb  nubb :: either string bool -> m bool nubb = undefined 

when it's stripped down bare-bones form, it's obvious has gone wrong: asking dc.get return either string bool when in fact should asking return bool. simple fix stripped-down version eliminate >>= nubb part of line entirely; should easy translate fix bigger context.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -