Would you guys be interested in a PR adding a Semigroup for modular arithmetic?
Something like this:
data Mod (k :: Nat) (f :: * -> *) (a :: *) = Mod (f a)
instance (KnownNat k, Semigroup (f a), Applicative f, Integral a) => Semigroup (Mod k f a) where
(<>) (Mod fx) (Mod fy) = Mod $
mod <$> (fx <> fy) <*> (pure $ fromIntegral $ natVal $ Proxy @k)
Would you guys be interested in a PR adding a
Semigroupfor modular arithmetic?Something like this: