1
1
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:
Rob Rix 2016-03-14 18:30:44 -04:00
parent 47c1a47715
commit a23fcf204e

View File

@ -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