File tree 2 files changed +8
-0
lines changed
semialign/src/Data/Semialign
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 (..))
80
80
81
81
import Data.These
82
82
import Data.These.Combinators
83
+ import Control.Monad.Trans.Reader (ReaderT (.. ))
83
84
84
85
oops :: String -> a
85
86
oops = error . (" Data.Align: internal error: " ++ )
@@ -454,6 +455,12 @@ instance SemialignWithIndex Int ZipList
454
455
instance ZipWithIndex Int ZipList
455
456
instance RepeatWithIndex Int ZipList
456
457
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
+
457
464
-------------------------------------------------------------------------------
458
465
-- semigroups
459
466
-------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ alignProps = testGroup "Align"
91
91
#ifdef MIN_VERSION_lattice
92
92
-- note: with e.g. N5 (which isn't distributive lattice) distributivity laws fail!
93
93
, semialignLaws (CZip :: CSemialign (Const M2 ))
94
+ , semialignLaws (CAlign :: CSemialign (ReaderT Int [] ))
94
95
#endif
95
96
]
96
97
You can’t perform that action at this time.
0 commit comments