1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Define the Mergeable instance for NonEmpty recursively.

This prevents failure in the first element precluding success later on.
This commit is contained in:
Rob Rix 2017-10-23 10:58:13 -04:00
parent 6a0321c401
commit 293731e71b

View File

@ -37,7 +37,8 @@ instance Mergeable [] where
merge _ [] = pure []
instance Mergeable NonEmpty where
merge f (x:|xs) = (:|) <$> f x <*> merge f xs
merge f (x:|[]) = (:|) <$> f x <*> pure []
merge f (x1:|x2:xs) = (:|) <$> f x1 <*> merge f (x2 : xs) <|> merge f (x2:|xs)
instance Mergeable Maybe where
merge f (Just a) = Just <$> f a