From a73a3597730eaf7cd92b5431e383ee602a2199c6 Mon Sep 17 00:00:00 2001 From: picca Date: Fri, 25 Aug 2017 14:20:21 +0000 Subject: --- doc/forum/How_to_create_a_property_with_info.mdwn | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 doc/forum/How_to_create_a_property_with_info.mdwn (limited to 'doc/forum/How_to_create_a_property_with_info.mdwn') diff --git a/doc/forum/How_to_create_a_property_with_info.mdwn b/doc/forum/How_to_create_a_property_with_info.mdwn new file mode 100644 index 00000000..ea8babe5 --- /dev/null +++ b/doc/forum/How_to_create_a_property_with_info.mdwn @@ -0,0 +1,65 @@ +Hello Joey, + +I try to setup a debomatic service on one of my computer. +So I created a data which will store on which host it was installed + + data DebOMaticHostMirror = DebOMaticHostMirror Url + deriving (Eq, Show, Typeable) + +So now I try to create a property which get the hostname and set the info, +BUT I did not find the right way to do this. Here an attempt + + debomaticHostMirror :: Property (HasInfo + UnixLike) + debomaticHostMirror = property' desc $ \w -> do + hostname <- asks hostName + ensureProperty $ pureInfoProperty desc (InfoVal (DebOMaticHostMirror hostname)) + where + desc = "setup the Deb-O-Matic host name for other properties" + +but I get this error message + + src/propellor-config.hs:935:3: error: + • Couldn't match expected type ‘Propellor Result’ + with actual type ‘Property + (Propellor.Types.MetaTypes.MetaTypes inner0) + -> Propellor Result’ + • In a stmt of a 'do' block: + ensureProperty + $ pureInfoProperty desc (InfoVal (DebOMaticHostMirror hostname)) + In the expression: + do { hostname <- asks hostName; + ensureProperty + $ pureInfoProperty desc (InfoVal (DebOMaticHostMirror hostname)) } + In the second argument of ‘($)’, namely + ‘\ w + -> do { hostname <- asks hostName; + ensureProperty + $ pureInfoProperty desc (InfoVal (DebOMaticHostMirror hostname)) }’ + + src/propellor-config.hs:935:20: error: + • Couldn't match expected type ‘OuterMetaTypesWitness outer0’ + with actual type ‘Property (HasInfo + UnixLike)’ + • In the second argument of ‘($)’, namely + ‘pureInfoProperty desc (InfoVal (DebOMaticHostMirror hostname))’ + In a stmt of a 'do' block: + ensureProperty + $ pureInfoProperty desc (InfoVal (DebOMaticHostMirror hostname)) + In the expression: + do { hostname <- asks hostName; + ensureProperty + $ pureInfoProperty desc (InfoVal (DebOMaticHostMirror hostname)) } + +the Idea after is to create a property which will take the DeboMatic Info and generate the +/etc/apt/sourses.list.d/debomatic.list on a bunch of hosts. + +Maybe we could have a + + typeclass Mirror a where + toSourceListDLines :: a -> [Line] + + instance Mirror DebOMaticHostMirror where + toSourceListDLines (DebOMaticHostMirror hostname) = ... + +then the stdSourceListD property should be change to use toSourceListDLines + +but this is another story :) -- cgit v1.2.3