@@ -10,11 +10,11 @@ module Control.Monad.Eff.Ref where
1010import Control.Monad.Eff
1111
1212-- | The effect associated with the use of global mutable variables.
13- foreign import data Ref :: !
13+ foreign import data REF :: !
1414
15- -- | A value of type `RefVal a` represents a mutable reference
15+ -- | A value of type `Ref a` represents a mutable reference
1616-- | which holds a value of type `a`.
17- foreign import data RefVal :: * -> *
17+ foreign import data Ref :: * -> *
1818
1919-- | Create a new mutable reference containing the specified value.
2020foreign import newRef " " "
@@ -23,7 +23,7 @@ foreign import newRef """
2323 return { value: val };
2424 };
2525 }
26- " " " :: forall s r . s -> Eff (ref :: Ref | r ) (RefVal s )
26+ " " " :: forall s r . s -> Eff (ref :: REF | r ) (Ref s )
2727
2828-- | Read the current value of a mutable reference
2929foreign import readRef " " "
@@ -32,7 +32,7 @@ foreign import readRef """
3232 return ref.value;
3333 };
3434 }
35- " " " :: forall s r . RefVal s -> Eff (ref :: Ref | r ) s
35+ " " " :: forall s r . Ref s -> Eff (ref :: REF | r ) s
3636
3737-- | Update the value of a mutable reference by applying a function
3838-- | to the current value.
@@ -41,17 +41,17 @@ foreign import modifyRef' """
4141 return function(f) {
4242 return function() {
4343 var t = f(ref.value);
44- ref.value = t.newState ;
45- return t.retVal ;
44+ ref.value = t.state ;
45+ return t.value ;
4646 };
4747 };
4848 }
49- " " " :: forall s b r . RefVal s -> (s -> { newState :: s , retVal :: b } ) -> Eff (ref :: Ref | r ) b
49+ " " " :: forall s b r . Ref s -> (s -> { state :: s , value :: b } ) -> Eff (ref :: REF | r ) b
5050
5151-- | Update the value of a mutable reference by applying a function
5252-- | to the current value.
53- modifyRef :: forall s r . RefVal s -> (s -> s ) -> Eff (ref :: Ref | r ) Unit
54- modifyRef ref f = modifyRef' ref (\s -> {newState : f s, retVal : unit})
53+ modifyRef :: forall s r . Ref s -> (s -> s ) -> Eff (ref :: REF | r ) Unit
54+ modifyRef ref f = modifyRef' ref (\s -> { state : f s, value : unit })
5555
5656-- | Update the value of a mutable reference to the specified value.
5757foreign import writeRef " " "
@@ -63,4 +63,4 @@ foreign import writeRef """
6363 };
6464 };
6565 }
66- " " " :: forall s r . RefVal s -> s -> Eff (ref :: Ref | r ) Unit
66+ " " " :: forall s r . Ref s -> s -> Eff (ref :: REF | r ) Unit
0 commit comments