mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Add an Alternative instance over Adjoined.
This commit is contained in:
parent
47c1a47715
commit
a23fcf204e
@ -1,6 +1,7 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
module Data.Adjoined where
|
||||
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import Data.Align
|
||||
import Data.Bifunctor.These
|
||||
@ -38,6 +39,10 @@ instance Applicative Adjoined where
|
||||
pure = return
|
||||
(<*>) = ap
|
||||
|
||||
instance Alternative Adjoined where
|
||||
empty = Adjoined mempty
|
||||
Adjoined a <|> Adjoined b = Adjoined (a >< b)
|
||||
|
||||
instance Monad Adjoined where
|
||||
return = Adjoined . return
|
||||
Adjoined a >>= f = case viewl a of
|
||||
|
Loading…
Reference in New Issue
Block a user