1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 22:01:46 +03:00

Simplify mapAnnotations with the Bifunctor instance.

This commit is contained in:
Rob Rix 2017-05-08 11:53:23 -04:00
parent d1c9c69ed8
commit 4fe2a4cec1

View File

@ -44,7 +44,7 @@ mapAnnotations :: (Functor f, Functor g)
=> (annotation -> annotation') => (annotation -> annotation')
-> Free (TermF f (g annotation)) (Patch (Term f annotation)) -> Free (TermF f (g annotation)) (Patch (Term f annotation))
-> Free (TermF f (g annotation')) (Patch (Term f annotation')) -> Free (TermF f (g annotation')) (Patch (Term f annotation'))
mapAnnotations f = iter (\ (h :< functor) -> wrap (fmap f h :< functor)) . fmap (pure . fmap (fmap f)) mapAnnotations f = iter (wrap . first (fmap f)) . fmap (pure . fmap (fmap f))
-- | Map a function over the annotations of a single diff node, if it is in Free. -- | Map a function over the annotations of a single diff node, if it is in Free.
modifyAnnotations :: (Functor f, Functor g) => (annotation -> annotation) -> Free (TermF f (g annotation)) a -> Free (TermF f (g annotation)) a modifyAnnotations :: (Functor f, Functor g) => (annotation -> annotation) -> Free (TermF f (g annotation)) a -> Free (TermF f (g annotation)) a