1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 21:47:07 +03:00

Define a Diffable instance for NonEmpty.

This commit is contained in:
Rob Rix 2017-09-19 12:46:24 -04:00
parent 6e29ab8234
commit 708dd429e4

View File

@ -134,6 +134,10 @@ instance Apply Diffable fs => Diffable (Union fs) where
instance Diffable [] where
algorithmFor a b = byRWS a b
-- | Diff two non-empty lists using RWS.
instance Diffable NonEmpty where
algorithmFor (a:|as) (b:|bs) = (\ (d:ds) -> d:|ds) <$> byRWS (a:as) (b:bs)
-- | A generic type class for diffing two terms defined by the Generic1 interface.
class GDiffable f where
galgorithmFor :: f (term ann1) -> f (term ann2) -> Algorithm term (diff ann1 ann2) (f (diff ann1 ann2))