diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-06-02 17:30:06 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-06-02 17:30:06 -0400 |
| commit | 17f843b244df52c19542f0a0869f500ccadf4553 (patch) | |
| tree | 8c176d47ae36aa97abc6e13d1e90143e9215795a /doc/forum/functions_that_yield_properties | |
| parent | 65a7716a93960ea1418927bd9d4df22ad8fb9e21 (diff) | |
response
Diffstat (limited to 'doc/forum/functions_that_yield_properties')
| -rw-r--r-- | doc/forum/functions_that_yield_properties/comment_1_7de09397627186abda74d765f4194f79._comment | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/forum/functions_that_yield_properties/comment_1_7de09397627186abda74d765f4194f79._comment b/doc/forum/functions_that_yield_properties/comment_1_7de09397627186abda74d765f4194f79._comment new file mode 100644 index 00000000..c0310700 --- /dev/null +++ b/doc/forum/functions_that_yield_properties/comment_1_7de09397627186abda74d765f4194f79._comment @@ -0,0 +1,29 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2016-06-02T21:10:20Z" + content=""" +You can use `ensureProperty` to do this. + + withMyAcc desc mkp = property' desc $ \w -> + u <- getMyAcc + ensureProperty w (mkp u) + +The type of this will be somewhat more complex than the one you gave, +but it should work. + +Alas a description has to be provided to withMyAcc. It cannot reuse the +description of `mkp` because to get a property that it can introspect for its +description, a User has to be provided, and the User can only be determined by +running Propellor (IO) action getMyAcc. You might be able to finesse this +by using a monoidial value and get the description of `mkp mempty`. + +Or, you could do something like this to tie the knot. I don't know if this +is a good idea (it might even `<<loop>>`), but it illustrates the core +problem nicely; to get at the Info, we need a Host, but to get a Host, we +need to already know its properties. + + foo :: Host + foo = host "foo.example.com" $ props + & withMyAcc (hostInfo foo) User.accountFor +"""]] |
