Skip to content

Update for purescript-effect #14

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 3 commits into from
Apr 15, 2018
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
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"package.json"
],
"dependencies": {
"purescript-eff": "^3.0.0"
"purescript-effect": "^0.1.0"
}
}
16 changes: 0 additions & 16 deletions src/Control/Monad/Eff/Ref/Unsafe.purs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,29 @@
-- | _Note_: The `Control.Monad.ST` provides a _safe_ alternative
-- | to global mutable variables when mutation is restricted to a
-- | local scope.
module Control.Monad.Eff.Ref where
module Control.Monad.Effect.Ref where

import Control.Monad.Effect (Effect)
import Prelude (Unit, unit)
import Control.Monad.Eff (Eff, kind Effect)

-- | The effect associated with the use of global mutable variables.
foreign import data REF :: Effect

-- | A value of type `Ref a` represents a mutable reference
-- | which holds a value of type `a`.
foreign import data Ref :: Type -> Type

-- | Create a new mutable reference containing the specified value.
foreign import newRef :: forall s r. s -> Eff (ref :: REF | r) (Ref s)
foreign import newRef :: forall s. s -> Effect (Ref s)

-- | Read the current value of a mutable reference
foreign import readRef :: forall s r. Ref s -> Eff (ref :: REF | r) s
foreign import readRef :: forall s. Ref s -> Effect s

-- | Update the value of a mutable reference by applying a function
-- | to the current value.
foreign import modifyRef' :: forall s b r. Ref s -> (s -> { state :: s, value :: b }) -> Eff (ref :: REF | r) b
foreign import modifyRef' :: forall s b. Ref s -> (s -> { state :: s, value :: b }) -> Effect b

-- | Update the value of a mutable reference by applying a function
-- | to the current value.
modifyRef :: forall s r. Ref s -> (s -> s) -> Eff (ref :: REF | r) Unit
modifyRef :: forall s. Ref s -> (s -> s) -> Effect Unit
modifyRef ref f = modifyRef' ref (\s -> { state: f s, value: unit })

-- | Update the value of a mutable reference to the specified value.
foreign import writeRef :: forall s r. Ref s -> s -> Eff (ref :: REF | r) Unit
foreign import writeRef :: forall s. Ref s -> s -> Effect Unit