From afd67dbbd9030e5fedd50f587da7018f1701ba3d Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 22 Jul 2016 17:51:57 -0400 Subject: [PATCH] Define a merge method in Mergeable which generalizes sequenceAlt. --- src/Data/Mergeable.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Data/Mergeable.hs b/src/Data/Mergeable.hs index 5c48c888c..ed3cd7627 100644 --- a/src/Data/Mergeable.hs +++ b/src/Data/Mergeable.hs @@ -8,6 +8,10 @@ import Prologue -- Classes class Functor t => Mergeable t where + merge :: Alternative f => (a -> f b) -> t a -> f (t b) + default merge :: (Generic1 t, GMergeable (Rep1 t), Alternative f) => (a -> f b) -> t a -> f (t b) + merge = genericMerge + sequenceAlt :: Alternative f => t (f a) -> f (t a) default sequenceAlt :: (Generic1 t, GMergeable (Rep1 t), Alternative f) => t (f a) -> f (t a) sequenceAlt = genericSequenceAlt