summaryrefslogtreecommitdiff
path: root/doc/forum/functions_that_yield_properties.mdwn
diff options
context:
space:
mode:
authorspwhitton2016-06-02 06:15:47 +0000
committeradmin2016-06-02 06:15:47 +0000
commit941b0513d6bf4d9c78764e9f3efad3174c5c0846 (patch)
treee858dede4db3db16cfabb981ba87b529d01bcfd2 /doc/forum/functions_that_yield_properties.mdwn
parentba6db6e4f63efdbcd9a07648430dda977e1e0ac4 (diff)
post puzzle
Diffstat (limited to 'doc/forum/functions_that_yield_properties.mdwn')
-rw-r--r--doc/forum/functions_that_yield_properties.mdwn21
1 files changed, 21 insertions, 0 deletions
diff --git a/doc/forum/functions_that_yield_properties.mdwn b/doc/forum/functions_that_yield_properties.mdwn
new file mode 100644
index 00000000..eb4b4a45
--- /dev/null
+++ b/doc/forum/functions_that_yield_properties.mdwn
@@ -0,0 +1,21 @@
+I have a bunch of properties that need to know what my login name is on a host. I have a pure info property `SPW.myAccountIs` to set this as host info. I have a function
+
+ getMyAcc :: Propellor User
+
+which looks up this info or returns the default value 'spwhitton' if I didn't set a username on a host. It's easy to use `getMyAcc` in writing my own properties, but I want to use it with existing properties. I'd like to write
+
+ withMyAcc :: IsProp p => (User -> p) -> p
+
+so that for example I could say
+
+ & (withMyAcc $ \u -> User.accountFor u)
+
+Even better, I'd like to be able to say
+
+ stdMachine = propertyListWithAcc "standard Debian setup" $ \u -> props
+ & User.accountFor u
+ & Sudo.enabledFor u
+
+It seems like this ought to be possible; a property is something that does some stuff in the `Propellor` monad and has a few other attributes, and those monadic actions can be conditional on some data not yet provided. However, I can't figure out how to do this with propellor's type system. If it's possible, I'd welcome hints.
+
+--spwhitton