From 8f8bf5dad9a551ffc64f1ea7b91ef9adaad7a756 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 22 Jul 2016 17:50:08 -0400 Subject: [PATCH] Define a genericMerge helper. --- src/Data/Mergeable/Generic.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Data/Mergeable/Generic.hs b/src/Data/Mergeable/Generic.hs index 25637d2ef..ab1dcb5e1 100644 --- a/src/Data/Mergeable/Generic.hs +++ b/src/Data/Mergeable/Generic.hs @@ -9,6 +9,9 @@ import Prologue class GMergeable t where gmerge :: Alternative f => (a -> f b) -> t a -> f (t b) +genericMerge :: (Generic1 t, GMergeable (Rep1 t), Alternative f) => (a -> f b) -> t a -> f (t b) +genericMerge f = fmap to1 . gmerge f . from1 + genericSequenceAlt :: (Generic1 t, GMergeable (Rep1 t), Alternative f) => t (f a) -> f (t a) genericSequenceAlt = fmap to1 . gmerge identity . from1