Some style changes for bidir example
Getty Ritter
8 years ago
| 27 | 27 | , _confConfigFile = Nothing |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | parseConfig :: IniSpec Config () | |
| 31 | parseConfig = section "NETWORK" $ do | |
| 30 | configSpec :: IniSpec Config () | |
| 31 | configSpec = section "NETWORK" $ do | |
| 32 | 32 | confUsername .= field "user" text |
| 33 | 33 | & comment [ "your username" ] |
| 34 | 34 | confPort .= field "port" number |
| 51 | 51 | |
| 52 | 52 | main :: IO () |
| 53 | 53 | main = do |
| 54 |
let s = parseIniFile sampleConfig |
|
| 54 | let s = parseIniFile sampleConfig configSpec example | |
| 55 | 55 | print s |
| 56 | 56 | case s of |
| 57 | 57 | Left err -> putStrLn err |
| 58 | 58 | Right p -> do |
| 59 | 59 | putStrLn "------------------------" |
| 60 |
putStr |
|
| 60 | putStr (unpack (emitIniFile sampleConfig configSpec)) | |
| 61 | 61 | putStrLn "------------------------" |
| 62 | 62 | putStrLn "\n" |
| 63 | 63 | let p' = p { _confPort = 9191 |
| 69 | 69 | [ "value added by application" ] |
| 70 | 70 | , updateIgnoreExtraneousFields = False |
| 71 | 71 | } |
| 72 |
let up = updateIniFile p' |
|
| 72 | let up = updateIniFile p' configSpec example pol | |
| 73 | 73 | case up of |
| 74 | 74 | Left err -> putStrLn err |
| 75 | 75 | Right up' -> do |
| 76 | 76 | putStrLn "------------------------" |
| 77 |
putStr |
|
| 77 | putStr (unpack up') | |
| 78 | 78 | putStrLn "------------------------" |