summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2015-08-20 10:13:18 -0400
committerJoey Hess2015-08-20 10:13:18 -0400
commit47059b7358a94e06dadc44b76b5b81d560dadd80 (patch)
tree55e43e3cd9ac8bc5d03c81a69b7a891702cedc0e
parentf8dc9b294dbc114255129113f84fabde6dac46cc (diff)
layout
-rw-r--r--propellor.cabal2
-rw-r--r--src/Propellor/Property/ConfFile.hs28
2 files changed, 15 insertions, 15 deletions
diff --git a/propellor.cabal b/propellor.cabal
index 640d0293..317f30d8 100644
--- a/propellor.cabal
+++ b/propellor.cabal
@@ -73,7 +73,7 @@ Library
Propellor.Property.Apt
Propellor.Property.Cmd
Propellor.Property.Hostname
- Propellor.Property.Chroot
+ Propellor.Property.Chroot
Propellor.Property.ConfFile
Propellor.Property.Cron
Propellor.Property.Debootstrap
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, == "<Foo>")
-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, == "<Foo>")
+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)