1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 04:41:47 +03:00

Define a genericMerge helper.

This commit is contained in:
Rob Rix 2016-07-22 17:50:08 -04:00
parent 1d7645cafe
commit 8f8bf5dad9

View File

@ -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