mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-30 07:02:24 +03:00
21 lines
373 B
Idris
21 lines
373 B
Idris
module RefMonadState
|
|
|
|
import Control.Monad.State.Interface
|
|
|
|
import Data.Ref
|
|
|
|
%default total
|
|
|
|
fancy : MonadState Nat m => HasIO m => m String
|
|
fancy = do
|
|
n <- get
|
|
putStrLn "current n: \{show n}"
|
|
put $ 20 + n
|
|
pure "`\{show n}`"
|
|
|
|
main : IO ()
|
|
main = do
|
|
ref <- newRef 18
|
|
for_ [1..4] $ const $ fancy @{ForRef ref}
|
|
putStrLn "resulting value: \{show !(readRef ref)}"
|