Skip to content

Commit 42baee9

Browse files
author
Manuel Bärenz
committed
ReaderT instances for Semialign and Align
1 parent 5ba75bf commit 42baee9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

semialign/src/Data/Semialign/Internal.hs

+7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import Data.Semigroup (Option (..))
8080

8181
import Data.These
8282
import Data.These.Combinators
83+
import Control.Monad.Trans.Reader (ReaderT (..))
8384

8485
oops :: String -> a
8586
oops = error . ("Data.Align: internal error: " ++)
@@ -454,6 +455,12 @@ instance SemialignWithIndex Int ZipList
454455
instance ZipWithIndex Int ZipList
455456
instance RepeatWithIndex Int ZipList
456457

458+
instance Semialign m => Semialign (ReaderT r m) where
459+
align ma mb = ReaderT $ getCompose $ align (Compose (runReaderT ma)) (Compose (runReaderT mb))
460+
461+
instance Align m => Align (ReaderT r m) where
462+
nil = ReaderT $ Prelude.const nil
463+
457464
-------------------------------------------------------------------------------
458465
-- semigroups
459466
-------------------------------------------------------------------------------

0 commit comments

Comments
 (0)