From 47059b7358a94e06dadc44b76b5b81d560dadd80 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 20 Aug 2015 10:13:18 -0400 Subject: layout --- src/Propellor/Property/ConfFile.hs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/Propellor/Property/ConfFile.hs') diff --git a/src/Propellor/Property/ConfFile.hs b/src/Propellor/Property/ConfFile.hs index 72996c74..b2d96d29 100644 --- a/src/Propellor/Property/ConfFile.hs +++ b/src/Propellor/Property/ConfFile.hs @@ -5,17 +5,17 @@ import Propellor.Property.File import Data.List (isPrefixOf, foldl') -type SectionStart = Line -> Bool -- ^ find the line that is the start of the - -- wanted section (eg, == "") -type SectionPast = Line -> Bool -- ^ find a line that indicates we are past - -- the section (eg, a new section header) -type AdjustSection = [Line] -> [Line] -- ^ run on all lines in the section, - -- including the SectionStart line and any - -- SectionEnd line; can add/delete/modify - -- lines, or even delete entire section -type InsertSection = [Line] -> [Line] -- ^ if SectionStart does not find the - -- section in the file, this is used to - -- insert the section somewhere within it +-- | find the line that is the start of the wanted section (eg, == "") +type SectionStart = Line -> Bool +-- | find a line that indicates we are past the section +-- (eg, a new section header) +type SectionPast = Line -> Bool +-- | run on all lines in the section, including the SectionStart line; +-- can add/delete/modify lines, or even delete entire section +type AdjustSection = [Line] -> [Line] +-- | if SectionStart does not find the section in the file, this is used to +-- insert the section somewhere within it +type InsertSection = [Line] -> [Line] adjustSection :: String @@ -29,9 +29,9 @@ adjustSection desc start past adjust insert f = fileProperty desc go f where go ls = let (pre, wanted, post) = foldl' find ([], [], []) ls - in if null wanted - then insert ls - else pre ++ (adjust wanted) ++ post + in if null wanted + then insert ls + else pre ++ (adjust wanted) ++ post find (pre, wanted, post) l | null wanted && null post && (not . start) l = (pre ++ [l], wanted, post) -- cgit v1.2.3