summaryrefslogtreecommitdiff
path: root/doc/forum/How_to_create_a_property_with_info.mdwn
diff options
context:
space:
mode:
Diffstat (limited to 'doc/forum/How_to_create_a_property_with_info.mdwn')
-rw-r--r--doc/forum/How_to_create_a_property_with_info.mdwn65
1 files changed, 65 insertions, 0 deletions
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 :)