gdritter repos config-ini / 2d52a44
Add lens for access to underlying Ini value Getty Ritter 6 years ago
1 changed file(s) with 8 addition(s) and 0 deletion(s). Collapse all Expand all
144144 Ini
145145 , ini
146146 , getIniValue
147 , iniValueL
147148 , getRawIni
148149 -- ** Parsing INI files
149150 , parseIni
278279 -- | Get the underlying Haskell value associated with the 'Ini'.
279280 getIniValue :: Ini s -> s
280281 getIniValue = iniCurr
282
283 mkLens :: (a -> b) -> (b -> a -> a) -> Lens a a b b
284 mkLens get' set' f a = (`set'` a) `fmap` f (get' a)
285
286 -- | The lens equivalent of 'getIniValue'
287 iniValueL :: Lens (Ini s) (Ini s) s s
288 iniValueL = mkLens iniCurr (\ i v -> v { iniCurr = i })
281289
282290 -- | Get the textual representation of an 'Ini' value. If this 'Ini'
283291 -- value is the result of 'parseIni', then it will attempt to retain