mirror of
https://github.com/github/semantic.git
synced 2024-12-23 23:11:50 +03:00
Add a Coalescent instance for Line.
This commit is contained in:
parent
ff8bd646e4
commit
a39a8229ee
@ -1,5 +1,7 @@
|
||||
module Line where
|
||||
|
||||
import Data.Coalescent
|
||||
|
||||
-- | A line of items or an empty line.
|
||||
data Line a = Line [a] | Closed [a]
|
||||
deriving (Eq, Foldable, Functor, Show, Traversable)
|
||||
@ -50,3 +52,7 @@ instance Monoid (Line a) where
|
||||
mempty = Line []
|
||||
mappend xs (Closed ys) = Closed (unLine xs `mappend` ys)
|
||||
mappend xs ys = Line (unLine xs `mappend` unLine ys)
|
||||
|
||||
instance Coalescent (Line a) where
|
||||
coalesce a b | isOpen a = Just (a `mappend` b)
|
||||
| otherwise = Nothing
|
||||
|
Loading…
Reference in New Issue
Block a user