1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00

Use splitAt to bind & clarify the roles of the portions of bs.

This commit is contained in:
Rob Rix 2016-03-11 13:08:21 -05:00
parent 1ecff8e9b1
commit 0f2c693294

View File

@ -15,8 +15,8 @@ class Functor f => Align f where
instance Align [] where
nil = []
align as bs | la < lb = (That <$> take (lb - la) bs) ++ zipWith These as (drop (lb - la) bs)
| la > lb = (This <$> take (la - lb) as) ++ zipWith These (drop (la - lb) as) bs
align as bs | la < lb, (prefix, overlap) <- splitAt (lb - la) bs = (That <$> prefix) ++ zipWith These as overlap
| la > lb, (prefix, overlap) <- splitAt (la - lb) as = (This <$> prefix) ++ zipWith These overlap bs
| otherwise = zipWith These as bs
where (la, lb) = (length as, length bs)