mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
🔥 the Coalescent instance over Both (Line a).
This commit is contained in:
parent
a93a99caa2
commit
ee91e6daef
@ -2,9 +2,7 @@
|
|||||||
module Line where
|
module Line where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.Align
|
|
||||||
import Data.Coalescent
|
import Data.Coalescent
|
||||||
import Data.Functor.Both
|
|
||||||
|
|
||||||
-- | A line of items or an empty line.
|
-- | A line of items or an empty line.
|
||||||
data Line a = Line [a] | Closed [a]
|
data Line a = Line [a] | Closed [a]
|
||||||
@ -55,6 +53,3 @@ instance Monoid (Line a) where
|
|||||||
instance Coalescent (Line a) where
|
instance Coalescent (Line a) where
|
||||||
coalesce a b | isOpen a = pure (a `mappend` b)
|
coalesce a b | isOpen a = pure (a `mappend` b)
|
||||||
| otherwise = pure a <|> pure b
|
| otherwise = pure a <|> pure b
|
||||||
|
|
||||||
instance Coalescent (Both (Line a)) where
|
|
||||||
coalesce as bs = tsequenceL (pure (Line [])) (coalesce <$> as <*> bs)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user