I'm giving my tensor operations a notion of sharing, using a monadic context Shared
(implemented as State Nat
), so
(+) : Tensor F64 -> Tensor F64 -> Tensor F64
becomes
(+) : Tensor F64 -> Tensor F64 -> Shared $ Tensor F64
If I do this, (+)
can't be used in my semigroup. Is there a more general notion of a semigroup (and monoid) that allows for context such as this, so
Semigroup (Tensor F64) where
(<+>) = (+)
becomes e.g.
SemigroupM Shared (Tensor F64) where
(<+>) = (+)
and is it implemented in the Idris stdlib?
Tagged Haskell because, and correct me if I'm wrong, the question is essentially the same there.