Skip to content

Implemented MonadST Aff #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
Breaking changes:

New features:
- MonadST instance for Aff

Bugfixes:

Expand Down
3 changes: 2 additions & 1 deletion packages.dhall
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
let upstream =
https://raw.githubusercontent.com/purescript/package-sets/prepare-0.15/src/packages.dhall
https://github.com/purescript/package-sets/releases/download/psc-0.15.4-20220725/packages.dhall
sha256:e56fbdf33a5afd2a610c81f8b940b413a638931edb41532164e641bb2a9ec29c

in upstream
1 change: 1 addition & 0 deletions spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
, "partial"
, "prelude"
, "refs"
, "st"
, "tailrec"
, "transformers"
, "unsafe-coerce"
Expand Down
5 changes: 5 additions & 0 deletions src/Effect/Aff.purs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import Control.Lazy (class Lazy)
import Control.Monad.Error.Class (class MonadError, class MonadThrow, throwError, catchError, try)
import Control.Monad.Error.Class (try, throwError, catchError) as Exports
import Control.Monad.Rec.Class (class MonadRec, Step(..))
import Control.Monad.ST.Class (class MonadST, liftST)
import Control.Monad.ST.Global (Global)
import Control.Parallel (parSequence_, parallel)
import Control.Parallel.Class (class Parallel)
import Control.Parallel.Class (sequential, parallel) as Exports
Expand Down Expand Up @@ -115,6 +117,9 @@ instance monadEffectAff :: MonadEffect Aff where
instance lazyAff :: Lazy (Aff a) where
defer f = pure unit >>= f

instance monadSTAff :: MonadST Global Aff where
liftST = liftST >>> liftEffect

-- | Applicative for running parallel effects. Any `Aff` can be coerced to a
-- | `ParAff` and back using the `Parallel` class.
foreign import data ParAff :: Type -> Type
Expand Down