summaryrefslogtreecommitdiff
path: root/src/Propellor/Types.hs
AgeCommit message (Collapse)Author
2019-07-02use ConstraintKindsJoey Hess
This is just a bit prettier code than manually needing to use constraint ~ True
2019-07-02use DelayErrorJoey Hess
Syrak looked at this branch and said: Cool! I'd suggest that if it's working, that's an accident! You probably want IfStuck e (DelayError err1) (DelayErrorFcf err2) rather than IfStuck e (TypeError err1) (TypeError err2)
2019-07-02Revert "Revert "custom type error messages""Joey Hess
This reverts commit 665ea0d3d9e1b0e90278fd659dee0ef8642030da.
2019-07-02Revert "custom type error messages"Joey Hess
This reverts commits 14f6ae30809d8bbdb10b91cc59757e865a365df8 de21ef26861db458b0dfb0212cf501f9f8ed459b e20662e6a8881db55394a6366be17ca4e509bc2a Until this bug is resolved, these custom error types hide more basic errors. https://gitlab.haskell.org/ghc/ghc/issues/16894
2019-07-01optionally use type-errors to detect stucknessJoey Hess
Use the type-errors library to detect when the type checker gets stuck unable to reduce type-level operations on MetaTypes, and avoid displaying massive error messages in such a case. But, since type-errors is a new library not available in eg Debian yet, added a WithTypeErrors build flag. When the library is not available, cabal will automatically disable that build flag, and it will build without the type-errors library. This is most often used when combining properties of different types. If the MetaTypes don't have an OS in common, the error message used to be "Property " followed by pages of MetaTypes operations. Now it looks like this: • Cannot combine Properties: Property <unknown> Property HasInfo + Debian + Buntish + ArchLinux + FreeBSD (Property <unknown> is often due to a partially applied Property constructor, or due to passing the wrong type to a Property constructor.) Also it's used in ensureProperty to detect a case where the outer MetaTypes need to be inferred in order to check if the inner MetaTypes match, but the type checker is unable to infer it: • ensureProperty outer Property type is not able to be inferred here. Consider adding a type annotation. • When checking the inferred type writeConfig :: forall (outer :: [Propellor.Types.MetaTypes.MetaType]) t. And it's used in tightenTargets to detect when ghc is unable to infer the desired type of Property: • Unable to infer desired Property type in this use of tightenTargets. Consider adding a type annotation. • When checking the inferred type mk :: forall (tightened :: [Propellor.Types.MetaTypes.MetaType]).
2019-07-01custom type error messagesJoey Hess
* Avoid displaying an excessive amount of type error messages when many properties have been combined in a props list. * Added custom type error messages when Properties don't combine due to conflicting metatypes. * Added custom type error messages for ensureProperty and tightenTargets. * ensureProperty: The constraints have been simplified to EnsurePropertyAllowed. (API change) * ensureProperty: The contraints have been simplified to TightenTargetsAllowed. (API change) * CheckCombinable generates a Bool. (API change) This commit was sponsored by Jake Vosloo on Patreon.
2018-12-30Fix build with ghc 8.6.3Joey Hess
Ghc started complaining that the SingI constraints needs UndecidableInstances. I'm not clear why, when it used to work without that extension. UndecidableInstances were already used in MetaTypes..
2018-05-18modernized and simplified the MetaTypes implementationJoey Hess
now that compatability with ghc 7 is no longer needed. Data.Type.Bool contains effectively the same stuff that was implemented here, so removed my code. Tried to use Data.Type.Equality instead of my EqT, but it seems to be some other type of (type level) equality, and didn't compile. Instead went with the simpler EqT implementation that newer ghc versions allow. The rest of the changes are simply better syntax for defining type families. And upon using that syntax, ghc noticed that `type family a + b` does not have kind "ab" like I wrote before, but is kind *. Tested on debian stable with ghc 8.0.1. This commit was sponsored by John Pellman on Patreon.
2018-04-30fix broken SemigroupMonoid transition <<loop>>Joey Hess
Turns out that with ghc 8.2.2, the instructions given on the page don't work. And the cppless variant that I had compiles, but into effectively mappend = mappend so it loops. The only way I can see to make it work without cpp is to use mappend = (Sem.<>) which is ugly and a land mine waiting to explode if someone changes it to a nicer mappend = (<>) with a newer version of ghc which will compile it and work ok, while breaking it with 8.2.2. Sigh. I posted to haskell-cafe about this.
2018-04-30fix build with ghc 8.2Joey Hess
Seems newer ghc can figure out that metatypes is SingI, but not this one?
2018-04-23more ghc 8.4 build fixesJoey Hess
Tested build with ghc 8.4 now.
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)