Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 8d08b1a

Browse files
authored
Merge branch 'master' into sequence-values-in-the-abstract-domain
2 parents d600246 + 7482c84 commit 8d08b1a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

semantic-core/src/Control/Monad/Module.hs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ module Control.Monad.Module
88

99
import Control.Effect.Carrier
1010

11+
-- | Modules over monads allow lifting of a monad’s product (i.e. 'Control.Monad.join') into another structure composed with the monad. A right-module @f m@ over a monad @m@ therefore allows one to extend @m@’s '>>=' operation to values of @f m@ using the '>>=*' operator.
12+
--
13+
-- In practical terms, this means that we can describe syntax which cannot itself bind or be substituted for variables, but which can be substituted inside when containing a substitutable expression monad. For example, we might not want to allow variables in a declaration context, but might still want to be able to substitute for e.g. globally-bound variables inside declarations; a 'RightModule' instance expresses this relationship nicely.
14+
--
15+
-- Note that we are calling this a right-module following Maciej Piróg, Nicolas Wu, & Jeremy Gibbons in _Modules Over Monads and their Algebras_; confusingly, other sources refer to this as a left-module.
16+
--
17+
-- Laws:
18+
--
19+
-- Right-identity:
20+
--
21+
-- @
22+
-- m >>=* return = m
23+
-- @
24+
--
25+
-- Associativity:
26+
--
27+
-- @
28+
-- m >>=* (k >=> h) = (m >>=* k) >>=* h
29+
-- @
1130
class (forall g . Functor g => Functor (f g), HFunctor f) => RightModule f where
1231
(>>=*) :: Monad m => f m a -> (a -> m b) -> f m b
1332
infixl 1 >>=*

0 commit comments

Comments
 (0)