From a23fcf204e3ceaf2f21092b8efc4b43e0f33659c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Mar 2016 18:30:44 -0400 Subject: [PATCH] Add an Alternative instance over Adjoined. --- src/Data/Adjoined.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Data/Adjoined.hs b/src/Data/Adjoined.hs index 4bc955acf..6a7c81d23 100644 --- a/src/Data/Adjoined.hs +++ b/src/Data/Adjoined.hs @@ -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