File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
semialign/src/Data/Semialign Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ import Data.Semigroup (Option (..))
8080
8181import Data.These
8282import Data.These.Combinators
83+ import Control.Monad.Trans.Reader (ReaderT (.. ))
8384
8485oops :: String -> a
8586oops = error . (" Data.Align: internal error: " ++ )
@@ -454,6 +455,12 @@ instance SemialignWithIndex Int ZipList
454455instance ZipWithIndex Int ZipList
455456instance 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-------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ alignProps = testGroup "Align"
9191#ifdef MIN_VERSION_lattice
9292 -- note: with e.g. N5 (which isn't distributive lattice) distributivity laws fail!
9393 , semialignLaws (CZip :: CSemialign (Const M2 ))
94+ , semialignLaws (CAlign :: CSemialign (ReaderT Int [] ))
9495#endif
9596 ]
9697
You can’t perform that action at this time.
0 commit comments