summaryrefslogtreecommitdiff
path: root/src/Propellor/Types.hs
AgeCommit message (Collapse)Author
2017-07-15improve haddockJoey Hess
2017-03-18Fix build with pre-AMP ghc.Joey Hess
2017-03-15Added Monoid instances for Property and RevertableProperty.Joey Hess
* Added Monoid instances for Property and RevertableProperty. * Removed applyToList. Instead, use mconcat. (API change) Eg, if you had: applyToList accountFor [User "joey", User "root"] use instead: mconcat (map accountFor [User "joey", User "root"]) mappend x y is basically the same as x `before` y. In particular, if x fails to be ensured, it won't ensure y. This seems to make sense, since applyToList had that behavior, and so does the Monoid for Propellor Result. The alternative would be to try to ensure both and combine the results. However, I don't see any reason to do it that way. It would be nice if the description of both properties were displayed when ensuring the combination. But then, it would need to display eg: ensuring x..ok ensuring y..failed ensuring x and ensuring y..failed Without a way to get rid of that redundant last line, I don't want to do that. Note that the haddocks for the Monoid instances need a really wide screen to display! This is IMHO an infelicity in haddock, and I can't do anything about it really. This commit was sponsored by Fernando Jimenez on Patreon.
2017-03-15Property types changed to use a Maybe (Propellor Result). (API change)Joey Hess
* Property types changed to use a Maybe (Propellor Result). (API change) * When Nothing needs to be done to ensure a property, propellor will avoid displaying its description at all. The doNothing property is an example of such a property. This is mostly in preparation for Monoid instances for Property types, but is's also nice that anything that uses doNothing will avoid printing out any message at all. At least, I think it probably is. It might potentially be confusing for something that sometimes takes an action and sometimes resolves to doNothing and in either case has a description set to not always show the description. If this did turn out to be confusing, the change to doNothing could be reverted. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
2017-02-26Added ConfigurableValue type classJoey Hess
* 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.
2017-02-03add types for Arch LinuxZihao Wang
Signed-off-by: Zihao Wang <dev@wzhd.org>
2016-03-27improve haddocks and move code around to make them more clearJoey Hess
2016-03-27refactorJoey Hess
2016-03-26add back DeriveDataTypeableJoey Hess
needed for ghc 7.6.3
2016-03-26ported propagateContainerJoey Hess
Renamed several utility functions along the way.
2016-03-26got rid of the undefined in privdataJoey Hess
addInfoProperty' is like addInfoProperty but for when the input property is already known to HasInfo.
2016-03-25ported moreJoey Hess
Ssh is WIP and failing to compile quite badly
2016-03-25rename toProp to toChildPropertiesJoey Hess
and note that it's not meant to be used by regular users
2016-03-25continued portingJoey Hess
2016-03-25ported Property.AptJoey Hess
2016-03-25ported Property.ListJoey Hess
I wanted to keep propertyList [foo, bar] working, but had some difficulty making the type class approach work. Anyway, that's unlikely to be useful, since foo and bar probably have different types, or could easiy have their types updated breaking it.
2016-03-25fix CheckCombinableJoey Hess
Was wrong when there was a non-target in the MetaTypes list. Also, rework to improve type checker errors.
2016-03-25fix warningsJoey Hess
2016-03-25add type alias for Sing to be less confusing for usersJoey Hess
2016-03-24fix combineWith to only accept properties that have common targetsJoey Hess
2016-03-24ported most of PropAccumJoey Hess
2016-03-24pruneJoey Hess
2016-03-24convert ensurePropertyJoey Hess
Moved to its own module to keep everything related in one place.
2016-03-24converted PrivDataJoey Hess
Somewhat poorly; I don't like needing to export the Property constructor to use it here, and there's a use of undefined where it should be able to use sing. I got quite stuck on this, so am happy to have anything that works.
2016-03-24converted Propellor.InfoJoey Hess
2016-03-24simplifyJoey Hess
2016-03-24don't unify the two types of properties inside a RevertablePropertyJoey Hess
While it was ok to have RevertableProperty HasInfo even when the undo property did not have any info, and it would be ok to have RevertableProperty Debian even when the undo property targeted a wider set of OS's, type-level resource conflict detection needs to keep the two straight, as in RevertableProperty (Port 80 + Debian) Debian Without that, reverting a web server property and also including another property that uses port 80 would fail to compile, since the type system would not know if reverting RevertableProperty (Port 80 + Debian) continued using the resource or not. The downside is the need to write RevertableProperty Debian Debian ... Perhaps I'll add a type alias to avoid that or something.
2016-03-241st stage integrating MetaTypesJoey Hess
2016-03-07FreeBSD Support including:Evan Cofsky
- Propellor bootstrapping - Basic pkg - Basic ZFS datasets and properties - Simple Poudriere configuration (regular and ZFS) - Poudriere jail creation FIXME: - Cron.hs: runPropellor needs the System, but hasn't yet gotten it. Reorganizing: - Remove FreeBSD.Process - Move ZFS up to Property - Add Info for Pkg.update/Pkg.upgrade - Move FreeBSD.md to doc so it'll show up automatically. - Merge the FreeBSD config with the other sample config. - Use Info to check Pkg updated/upgraded and Poudriere configured. - Warnings clean-up, move ZFS types to Propellor.Types. - Maintainer and license statements.
2016-02-08Allow using combineProperties and propertyList with lists of RevertableProperty.Joey Hess
2015-12-19Clean build with ghc 7.10.Joey Hess
Import Prelude after modules that cause warnings due to AMP change
2015-11-24haddock improvementsJoey Hess
2015-11-17export for haddockJoey Hess
2015-10-27Explicit Info/NoInfo for RevertableProperty (API change)Joey Hess
RevertableProperty used to be assumed to contain info, but this is now made explicit, with RevertableProperty HasInfo or RevertableProperty NoInfo. Transition guide: - If you define a RevertableProperty, expect some type check failures like: "Expecting one more argument to ‘RevertableProperty’". - Change it to "RevertableProperty NoInfo" - The compiler will then tell you if it needs "HasInfo" instead. - If you have code that uses the RevertableProperty constructor that fails to type check, use the more powerful <!> operator
2015-10-24propellor spinJoey Hess
2015-10-24improve RevertableProperty combiningJoey Hess
* Various property combinators that combined a RevertableProperty with a non-revertable property used to yield a RevertableProperty. This was a bug, because the combined property could not be fully reverted in many cases. Fixed by making the combined property instead be a Property HasInfo. * combineWith now takes an addional parameter to control how revert actions are combined (API change).
2015-10-23generalize checkJoey Hess
Hmm, do I really need my own type class for LiftPropellor? This seems like a general problem so I am probably reinventing the wheel.
2015-10-10tighten focus of Propellor module, adding Propellor.Base for all the exportsJoey Hess
2015-10-10Improved documentation, particularly of the Propellor module.Joey Hess
This involved some code changes, including some renaming of instance methods. (ABI change)
2015-09-13Follow some hlint suggestions.Mario Lang
2015-09-06Added Propellor.Property.Rsync. WIP; untestedJoey Hess
Convert Info to use Data.Dynamic, so properties can export and consume info of any type that is Typeable and a Monoid, including data types private to a module. (API change) Thanks to Joachim Breitner for the idea.
2015-04-29propellor spinJoey Hess
2015-01-25remove toSimplePropJoey Hess
It didn't do what I thought it did with a RevertableProperty; it always returned Nothing because even if the input properties to <!> are NoInfo, it casts them to HasInfo. Even if it had worked, it lost type safety. Better to export the Property NoInfo that is used in a RevertableProperty, so it can be used directly.
2015-01-25fix combines instanceJoey Hess
The old one caused the actions to run in the right order, but with the wrong description. This problem was found by comparing the [Host] between this branch and current joeyconfig, and printing out their properties, info, and also their list of child properties. The only other difference found is that onChange orders the child property list differently. That does not have any real effect and would be difficult to change, so I've left it as-is.
2015-01-25avoid needing to define Show twiceJoey Hess
2015-01-24GADT properties seem to work (untested)Joey Hess
* Property has been converted to a GADT, and will be Property NoInfo or Property HasInfo. This was done to make sure that ensureProperty is only used on properties that do not have Info. Transition guide: - Change all "Property" to "Property NoInfo" or "Property WithInfo" (The compiler can tell you if you got it wrong!) - To construct a RevertableProperty, it is useful to use the new (<!>) operator - Constructing a list of properties can be problimatic, since Property NoInto and Property WithInfo are different types and cannot appear in the same list. To deal with this, "props" has been added, and can built up a list of properties of different types, using the same (&) and (!) operators that are used to build up a host's properties.
2015-01-24use type level functions to fix type inference for `require`Joey Hess
2015-01-24moving to using the GADTJoey Hess
The problem this exposes has to do with requires. As implemented, requires yields either a Property HasInfo or a Property NoInfo depending on its inputs. That works. But look what happens when it's used: *Propellor.Types> let foo = IProperty "foo" (return NoChange) mempty mempty *Propellor.Types> let bar = IProperty "bar" (return NoChange) mempty mempty *Propellor.Types> foo `requires` bar <interactive>:17:5: No instance for (Requires (Property HasInfo) (Property HasInfo) r0) arising from a use of `requires' The type variable `r0' is ambiguous Possible fix: add a type signature that fixes these type variable(s) Note: there is a potential instance available: instance Requires (Property HasInfo) (Property HasInfo) (Property HasInfo) -- Defined at Propellor/Types.hs:167:10 Possible fix: add an instance declaration for (Requires (Property HasInfo) (Property HasInfo) r0) In the expression: foo `requires` bar In an equation for `it': it = foo `requires` bar This can be avoided by specifying the result type: *Propellor.Types> (foo `requires` bar) :: Property HasInfo property "foo" But then when multiple `requires` are given, the result type has to be given each time: *Propellor.Types> (foo `requires` bar `requires` bar) :: Property HasInfo <interactive>:22:6: No instance for (Requires (Property HasInfo) (Property HasInfo) x0) arising from a use of `requires' The type variable `x0' is ambiguous Possible fix: add a type signature that fixes these type variable(s) Note: there is a potential instance available: instance Requires (Property HasInfo) (Property HasInfo) (Property HasInfo) -- Defined at Propellor/Types.hs:167:10 Possible fix: add an instance declaration for (Requires (Property HasInfo) (Property HasInfo) x0) In the first argument of `requires', namely `foo `requires` bar' In the expression: (foo `requires` bar `requires` bar) :: Property HasInfo In an equation for `it': it = (foo `requires` bar `requires` bar) :: Property HasInfo <interactive>:22:21: No instance for (Requires x0 (Property HasInfo) (Property HasInfo)) arising from a use of `requires' The type variable `x0' is ambiguous Possible fix: add a type signature that fixes these type variable(s) Note: there are several potential instances: instance Requires (Property NoInfo) (Property HasInfo) (Property HasInfo) -- Defined at Propellor/Types.hs:175:10 instance Requires (Property HasInfo) (Property HasInfo) (Property HasInfo) -- Defined at Propellor/Types.hs:167:10 Possible fix: add an instance declaration for (Requires x0 (Property HasInfo) (Property HasInfo)) In the expression: (foo `requires` bar `requires` bar) :: Property HasInfo In an equation for `it': it = (foo `requires` bar `requires` bar) :: Property HasInfo *Propellor.Types> (((foo `requires` bar) :: Property HasInfo) `requires` bar) :: Property HasInfo property "foo" Yuggh!
2015-01-24added GADT to determine between a property with info and withoutJoey Hess
Not yet used
2015-01-19more reorgJoey Hess