Hello
I have this kind of property
myProperty :: Conf -> RevertableProperty NoInfo
now I have a [Conf] and I want to create also a RevertableProperty NoInfo which apply myProperty for each Conf
I tried to find an equivalent of mapM for properties but I found nothing which works as expected.
I tried with combineProperties but it failed also with a "cryptic message" mpoints is the [Conf]
src/config.hs:250:17:
Couldn't match type `CInfo
(PropertyListType (Property [NoInfo]))
(PropertyListType (Property [NoInfo]))'
with `NoInfo'
Expected type: RevertableProperty NoInfo
Actual type: RevertableProperty
(CInfo
(PropertyListType (Property [NoInfo]))
(PropertyListType (Property [NoInfo])))
In the expression: mount <!> umount
In an equation for `mountExp':
mountExp b
= mount <!> umount
where
mount
= combineProperties
"mount nfs files" (mapM mount'' mpoints)
umount
= combineProperties
"umount nfs files" (mapM umount'' mpoints)
mpoints
= [MountConf
"nfs"
("ruche-"
++
beamline ++ ".mydomain.org:/" ++ beamline ++ "-users")
("/nfs/ruche-" ++ beamline ++ "/" ++ beamline ++ "-users"),
....]
beamline = show b
What is the right way to create a RevertableProperty from a list of RevertableProperty
thanks
Frederic
combineProperties takes a list of PropertyListType, which is a type family consisting of [Property NoInfo] and [Property HasInfo]. So, you need to get from RevertableProperty NoInfo to one of those.
toProp
can do that.But! I had a look and it was easy to make [RevertableProperty i] an instance of PropertyListType, which makes what you already tried type check too. I've done so in git.
It would perhaps be nice to make lists of various sorts of properties instances of Traversable, so that mapM etc could be used over them. That would need some kind of monad for combining properties though, which does not currently exist. Might make more sense to make an instance of Foldable or just Monoid for properties. Any improvements in this area would be appreciated!
Thanks a lot joey
I am learning haskell for now and I am not very confortable yet with the haskell Monoid, functor, applicative and monad.
So what you are saying is that it would be great to do something like
in order to combine properties. my question is why did you choose to create combineProperty instead of a Monoid at first ?
thanks
Frederic
Would probably be better to use
before
, sincecombineProperties
needs a description of the combined properties.Using
doNothing
is kind of a hack, it would make propellor say it was running "noop property". Perhaps better to use a SemiGroup than a Monoid.