store PropList reversed to optimise &

PropList is now an opaque type, to prevent misuse.

Note that the PropAccum Host instance cannot use reversed order.
This commit is contained in:
Joey Hess 2015-01-25 15:40:38 -04:00
parent 62c093de30
commit 7da64306a0
1 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,13 @@
{-# LANGUAGE PackageImports #-}
module Propellor.PropAccum where
module Propellor.PropAccum
( host
, props
, PropAccum(..)
, (!)
, PropList
, propigateContainer
) where
import Data.Monoid
@ -47,9 +54,9 @@ instance PropAccum Host where
data PropList = PropList [Property HasInfo]
instance PropAccum PropList where
PropList l & p = PropList (l ++ [toProp p])
PropList l &^ p = PropList ([toProp p] ++ l)
getProperties (PropList l) = l
PropList l & p = PropList (toProp p : l)
PropList l &^ p = PropList (l ++ [toProp p])
getProperties (PropList l) = reverse l
-- | Adds a property in reverted form.
(!) :: PropAccum h => h -> RevertableProperty -> h