Commit 4a4e841b authored by Petr Pudlak's avatar Petr Pudlak

Add a Monoid instance for FrozenSet

.. so that it's easier to combine the values together.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 68fed3b9
......@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
module Ganeti.ConstantUtils where
import Data.Char (ord)
import Data.Monoid (Monoid(..))
import Data.Set (Set)
import qualified Data.Set as Set (difference, fromList, toList, union)
......@@ -62,6 +63,10 @@ instance PyValue PythonNone where
newtype FrozenSet a = FrozenSet { unFrozenSet :: Set a }
deriving (Eq, Ord, Show)
instance (Ord a) => Monoid (FrozenSet a) where
mempty = FrozenSet mempty
mappend (FrozenSet s) (FrozenSet t) = FrozenSet (mappend s t)
-- | Converts a Haskell 'Set' into a Python 'frozenset'
--
-- This instance was supposed to be for 'Set' instead of 'FrozenSet'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment