diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-02-26 15:27:22 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-02-26 16:08:04 -0400 |
| commit | 2ba4b6fb3d29b2b65aa60f4bd591ed8cf6a63e27 (patch) | |
| tree | 873d0e3cd1582e68aa080ec032833f6a9a890407 /src/Propellor/Property/File.hs | |
| parent | d19bdf24ccce2556cf462d74335a8f131448da95 (diff) | |
Added ConfigurableValue type class
* Added ConfigurableValue type class, for values that can be used in a
config file, or to otherwise configure a program.
* The val function converts such values to String.
This was motivated by the bug caused by type Port = Int changing to
newtype Port = Port Int deriving Show
After that change, some things that used show port to generate config
files were broken. By using the ConfigurableValue type class instead,
such breakage can be prevented.
Diffstat (limited to 'src/Propellor/Property/File.hs')
| -rw-r--r-- | src/Propellor/Property/File.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Propellor/Property/File.hs b/src/Propellor/Property/File.hs index 869fa48b..459fe2c7 100644 --- a/src/Propellor/Property/File.hs +++ b/src/Propellor/Property/File.hs @@ -20,6 +20,12 @@ f `hasContent` newcontent = fileProperty (\_oldcontent -> newcontent) f -- | Ensures that a line is present in a file, adding it to the end if not. +-- +-- For example: +-- +-- > & "/etc/default/daemon.conf" `File.containsLine` ("cachesize = " ++ val 1024) +-- +-- The above example uses `val` to serialize a `ConfigurableValue` containsLine :: FilePath -> Line -> Property UnixLike f `containsLine` l = f `containsLines` [l] |
