Idris2/libs/base/Data/Ref.idr
Edwin Brady 28855088c2 Split HasIO into HasIO and MonadIO
For things which don't require (>>=), HasIO is fine, otherwise MonadIO
gives access to the monad interface.
2020-06-21 14:46:14 +01:00

23 lines
418 B
Idris

module Data.Ref
import public Data.IORef
import public Control.Monad.ST
public export
interface Ref m (r : Type -> Type) | m where
newRef : a -> m (r a)
readRef : r a -> m a
writeRef : r a -> a -> m ()
export
MonadIO io => Ref io IORef where
newRef = newIORef
readRef = readIORef
writeRef = writeIORef
export
Ref (ST s) (STRef s) where
newRef = newSTRef
readRef = readSTRef
writeRef = writeSTRef