Commit Graph

597 Commits

Author SHA1 Message Date
Joey Hess d08c98d8b3
propellor spin 2015-02-10 20:29:04 -04:00
Joey Hess 824ebdd76f
propellor spin 2015-02-10 19:57:18 -04:00
Joey Hess 057509c5cd
propellor spin 2015-02-10 15:09:57 -04:00
Joey Hess d1ebc7c145
propellor spin 2015-02-10 10:02:37 -04:00
Joey Hess 991249185c
propellor spin 2015-02-09 18:51:07 -04:00
Joey Hess 162df37da4
propellor spin 2015-02-01 17:38:05 -04:00
Joey Hess 8edc7ed3ae
propellor spin 2015-02-01 17:34:04 -04:00
Joey Hess 30c8621f5c
propellor spin 2015-02-01 17:01:32 -04:00
Joey Hess 2e2e30fc39
propellor spin 2015-02-01 16:58:32 -04:00
Joey Hess b3bdb95ed0
propellor spin 2015-02-01 16:51:55 -04:00
Joey Hess 8ff2b77385
propellor spin 2015-02-01 16:40:03 -04:00
Joey Hess db7a9aa9f6
propellor spin 2015-02-01 16:19:37 -04:00
Joey Hess 0ea9794324
propellor spin 2015-02-01 15:08:30 -04:00
Joey Hess 3c7c40dd67
propellor spin 2015-02-01 14:50:54 -04:00
Joey Hess bcdc5754fc
propellor spin 2015-02-01 14:48:13 -04:00
Joey Hess f276466cf2
propellor spin 2015-02-01 13:36:58 -04:00
Joey Hess 1b7a00372b
propellor spin 2015-02-01 13:14:45 -04:00
Joey Hess 3585f14d4e
propellor spin 2015-01-29 01:37:53 -04:00
Joey Hess d7697a4b25
propellor spin 2015-01-29 01:04:59 -04:00
Joey Hess 7da64306a0 store PropList reversed to optimise &
PropList is now an opaque type, to prevent misuse.

Note that the PropAccum Host instance cannot use reversed order.
2015-01-25 15:40:38 -04:00
Joey Hess e9d5d9aff1 remove toSimpleProp
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-25 14:47:57 -04:00
Joey Hess 334abae312 fix combines instance
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-25 13:28:04 -04:00
Joey Hess f4fc24aa5c avoid needing to define Show twice 2015-01-25 13:04:39 -04:00
Joey Hess f5da1c2b23 improve docs 2015-01-25 01:26:38 -04:00
Joey Hess a780cae441 fix typo 2015-01-24 23:43:24 -04:00
Joey Hess 0ee04ecc43 GADT properties seem to work (untested)
* 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-24 22:38:51 -04:00
Joey Hess 141a7c028b use type level functions to fix type inference for `require` 2015-01-24 19:40:43 -04:00
Joey Hess 45c94ffdd7 moving to using the GADT
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-24 16:54:49 -04:00
Joey Hess 414ee7eee6 added GADT to determine between a property with info and without
Not yet used
2015-01-24 16:53:59 -04:00
Joey Hess 38eec6fc37 OS.preserveNetwork finally written 2015-01-23 01:30:50 -04:00
Joey Hess d156a1e9ba Added more network interface configuration properties. 2015-01-23 01:18:47 -04:00
Joey Hess bbac845900
propellor spin 2015-01-22 16:10:22 -04:00
Joey Hess 4d34b837d2 reorg 2015-01-21 23:28:47 -04:00
Joey Hess a37e0a6bc3
propellor spin 2015-01-21 23:22:42 -04:00
Joey Hess fa66cb49d6 Added journald configuration properties. 2015-01-21 23:21:24 -04:00
Joey Hess 88082c7293 Added systemd configuration properties. 2015-01-21 22:49:03 -04:00
Joey Hess 0a2a553d31 add back a warning aboit info propigation to ensureProperty 2015-01-19 16:14:01 -04:00
Joey Hess c8153ff0bd fix haddock 2015-01-19 15:55:02 -04:00
Joey Hess e28b1ab92b clean up exports 2015-01-19 15:20:12 -04:00
Joey Hess a738a20d79 export 2015-01-19 15:15:22 -04:00
Joey Hess e583c40c65 more reorg 2015-01-19 15:11:10 -04:00
Joey Hess 603e6d3406 split out types to improve haddock for Propellor.Types 2015-01-19 15:09:03 -04:00
Joey Hess 04d4d0d6c4 Fix info propigation from fallback combinator's second Property. 2015-01-19 14:43:25 -04:00
Joey Hess a2a97cbeb2 avoid haddock warnings 2015-01-19 14:26:18 -04:00
Joey Hess 1ae21965aa rename HostLike to PropAccum
This is more general; it doesn't need to contain a Host.
It would, for example, be possible to make Property itself be an instance
of PropAccum.
2015-01-19 14:15:49 -04:00
Joey Hess afee550e70 Property tree
Properties now form a tree, instead of the flat list used before.

This simplifies propigation of Info from the Properties used inside a
container to the outer host; the Property that docks the container on the
host can just have as child properties all the inner Properties, and their
Info can then be gathered recursively. (Although in practice it still needs
to be filtered, since not all Info should propigate out of a container.)

Note that there is no change to how Properties are actually satisfied.
Just because a Property lists some child properties, this does not mean
they always have their propertySatisfy actions run. It's still up to the
parent property to run those actions.

That's necessary so that a container's properties can be satisfied inside
it, not outside. It also allows property combinators to
add the combined Properties to their childProperties list, even if,
like onChange, they don't always run the child properties at all.

Testing: I tested that the exact same Info is calculated before and after
this change, for every Host in my config file.
2015-01-18 18:46:38 -04:00
Joey Hess c7609c824b Add descriptions of how to set missing fields to --list-fields output. (Minor API changes) 2015-01-15 20:15:01 -04:00
Joey Hess 042b3bee01
propellor spin 2015-01-09 21:21:06 -04:00
Joey Hess 2e2f8b4fdd
propellor spin 2015-01-08 23:08:16 -04:00
Joey Hess 4d0a732a30 make both lines pastable together 2015-01-08 23:03:57 -04:00