diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-06-10 14:59:40 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-06-10 14:59:40 -0400 |
| commit | 5608ab99f3aa058a196a7dfaf2b5ec123b5dad70 (patch) | |
| tree | 36fe833d85386ae8a4637e1956b4f2feba4687a0 /doc/forum/functions_that_yield_properties | |
| parent | e9a09eed901fc8ff40c7debef02fb6b0ed48b165 (diff) | |
| parent | e56d193951672bc13aca88b17704160703fcad8b (diff) | |
Merge branch 'master' into joeyconfig
Diffstat (limited to 'doc/forum/functions_that_yield_properties')
3 files changed, 78 insertions, 0 deletions
diff --git a/doc/forum/functions_that_yield_properties/comment_3_76f4a92cf26ae2fcc3152a0f1a19f516._comment b/doc/forum/functions_that_yield_properties/comment_3_76f4a92cf26ae2fcc3152a0f1a19f516._comment new file mode 100644 index 00000000..7b1954bb --- /dev/null +++ b/doc/forum/functions_that_yield_properties/comment_3_76f4a92cf26ae2fcc3152a0f1a19f516._comment @@ -0,0 +1,17 @@ +[[!comment format=mdwn + username="spwhitton" + subject="comment 3" + date="2016-06-05T06:13:05Z" + content=""" +> The type of this will be somewhat more complex than the one you gave, but it should work. + +GHC's inferred type is not something I can understand, and I suspect that it is far more general than it needs to be. In this sort of situation, are their strategies one can employ to write a sensible type signature? I think that the only thing I need to restrict is avoiding trying to ensure properties with info. + +> You might be able to finesse this by using a monoidial value and get the description of mkp mempty. + +Could you expand a little on this suggestion, please? I want to be able to use unmodified core properties like `User.accountFor`, and that takes a non-monoidal `User`. + +> 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. + +This seems to work! +"""]] diff --git a/doc/forum/functions_that_yield_properties/comment_4_886daf04a0fa9e6d0dd1e9ef4cc9b63f._comment b/doc/forum/functions_that_yield_properties/comment_4_886daf04a0fa9e6d0dd1e9ef4cc9b63f._comment new file mode 100644 index 00000000..aab4f6ed --- /dev/null +++ b/doc/forum/functions_that_yield_properties/comment_4_886daf04a0fa9e6d0dd1e9ef4cc9b63f._comment @@ -0,0 +1,23 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 4""" + date="2016-06-06T20:58:37Z" + content=""" +`Maybe a` is a Monoid, so something along that line was what I was +thinking. + +---- + + withMyAcc + :: (SingI outer, Cannot_ensureProperty_WithInfo inner ~ 'True, + NotSuperset (Targets inner) (Targets outer) ~ 'CanCombine) + => Desc + -> (User -> Property (MetaTypes inner)) + -> Property (MetaTypes outer) + +The complicated constraints there are inherited from the use of `ensureProperty`. + +A less general form of that is: + + withMyAcc :: Desc -> (User -> Property DebianLike) -> Property DebianLike +"""]] diff --git a/doc/forum/functions_that_yield_properties/comment_5_922e9e20c5326ceb695f7593d8bd72f5._comment b/doc/forum/functions_that_yield_properties/comment_5_922e9e20c5326ceb695f7593d8bd72f5._comment new file mode 100644 index 00000000..7cbcdd84 --- /dev/null +++ b/doc/forum/functions_that_yield_properties/comment_5_922e9e20c5326ceb695f7593d8bd72f5._comment @@ -0,0 +1,38 @@ +[[!comment format=mdwn + username="spwhitton" + subject="comment 5" + date="2016-06-07T07:32:49Z" + content=""" +Unfortunately, the more general type doesn't seem to work: + + withMyAcc + :: (SingI outer, Cannot_ensureProperty_WithInfo inner ~ 'True, + NotSuperset (Targets inner) (Targets outer) ~ 'CanCombine) + => Desc + -> (User -> Property (MetaTypes inner)) + -> Property (MetaTypes outer) + withMyAcc desc mkp = property' desc $ \w -> do + u <- getMyAcc + ensureProperty w (mkp u) + + accountForSean :: Property DebianLike + accountForSean = withMyAcc \"account for Sean\" User.accountFor + +yields + + src/Propellor/Property/SiteSpecific/SPW/Account.hs:85:18: + Couldn't match kind ‘*’ with ‘MetaType’ + Expected type: Property DebianLike + Actual type: Property (MetaTypes outer0) + In the expression: withMyAcc \"account for Sean\" User.accountFor + In an equation for ‘accountForSean’: + accountForSean = withMyAcc \"account for Sean\" User.accountFor + + src/Propellor/Property/SiteSpecific/SPW/Account.hs:85:47: + Couldn't match kind ‘MetaType’ with ‘*’ + Expected type: User -> Property (MetaTypes inner0) + Actual type: User -> Property DebianLike + In the second argument of ‘withMyAcc’, namely ‘User.accountFor’ + In the expression: withMyAcc \"account for Sean\" User.accountFor + +"""]] |
