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

Line’s Applicative instance preserves closedness.

This commit is contained in:
Rob Rix 2016-03-10 17:48:13 -05:00
parent 186337fd4d
commit 572819b683

View File

@ -50,7 +50,8 @@ coalesceLines line nextLine | isOpen line = [line `mappend` nextLine]
instance Applicative Line where
pure = Line . pure
a <*> b = Line (unLine a <*> unLine b)
as <*> bs | isOpen as && isOpen bs = Line (unLine as <*> unLine bs)
| otherwise = Closed (unLine as <*> unLine bs)
instance Monoid (Line a) where
mempty = Line []