@@ -1,6 +1,6 @@
2-- This module implements the desugaring pass which replaces do-notation statements with
2-- This module implements the desugaring pass which replaces do-notation statements with
3−-- appropriate calls to bind from the Prelude.Monad type class.
3+-- appropriate calls to bind.
5module Language.PureScript.Sugar.DoNotation (desugarDoModule) where
5module Language.PureScript.Sugar.DoNotation (desugarDoModule) where
@@ -17,12 +17,16 @@ import Language.PureScript.Names
17import qualified Language.PureScript.Constants as C
17import qualified Language.PureScript.Constants as C
20−-- Replace all @DoNotationBind@ and @DoNotationValue@ constructors with applications of the Prelude.bind function,
20+-- Replace all @DoNotationBind@ and @DoNotationValue@ constructors with
21+-- applications of the bind function in scope, and all @DoNotationLet@
21−-- and all @DoNotationLet@ constructors with let expressions.
22+-- constructors with let expressions.
23desugarDoModule :: forall m. (MonadSupply m, MonadError MultipleErrors m) => Module -> m Module
24desugarDoModule :: forall m. (MonadSupply m, MonadError MultipleErrors m) => Module -> m Module
24desugarDoModule (Module ss coms mn ds exts) = Module ss coms mn <$> parU ds desugarDo <*> pure exts
25desugarDoModule (Module ss coms mn ds exts) = Module ss coms mn <$> parU ds desugarDo <*> pure exts
28+-- Desugar a single do statement
26desugarDo :: forall m. (MonadSupply m, MonadError MultipleErrors m) => Declaration -> m Declaration
30desugarDo :: forall m. (MonadSupply m, MonadError MultipleErrors m) => Declaration -> m Declaration
27desugarDo (PositionedDeclaration pos com d) = PositionedDeclaration pos com <$> rethrowWithPosition pos (desugarDo d)
31desugarDo (PositionedDeclaration pos com d) = PositionedDeclaration pos com <$> rethrowWithPosition pos (desugarDo d)
28desugarDo d =
32desugarDo d =