diff options
Diffstat (limited to 'compiler/GHC/Utils/Monad.hs')
-rw-r--r-- | compiler/GHC/Utils/Monad.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/GHC/Utils/Monad.hs b/compiler/GHC/Utils/Monad.hs index da415ba44c..d775f30530 100644 --- a/compiler/GHC/Utils/Monad.hs +++ b/compiler/GHC/Utils/Monad.hs @@ -322,6 +322,17 @@ The trick is very similar to the built-in "state hack" (see Note [The state-transformer hack] in "GHC.Core.Opt.Arity") but is applicable on a monad-by-monad basis under programmer control. +Do note, however, that each 'oneShot' only applies to a single lambda. +Consequently, it may be necessary to apply it more than once. For instance, in +the case of a monad that takes multiple arguments, e.g. + + newtype M a = M (Env -> UniqSupply -> IO (a, UniqSupply)) + +we have would have the following smart constructor, + + mkM :: Env -> UniqSupply -> IO (a, UniqSupply) + mkM env us = M $ oneShot $ \env -> oneShot $ \us -> f env us + Using pattern synonyms ~~~~~~~~~~~~~~~~~~~~~~ Using a smart constructor is fine, but there is no way to check that we |