Idris2/tests/node/node012/array.idr
Stiopa Koltsov c80a502627 Return Bool from IOArray.writeArray
As suggested in #1677.

Crashing on out-of-bounds might be more practical, but we can
reconsider it later.
2021-07-15 22:16:22 +01:00

23 lines
574 B
Idris

import Data.IOArray
import System
main : IO ()
main
= do x <- newArray 20
True <- writeArray x 10 "Hello"
| False => do putStrLn "should success 1"
exitFailure
True <- writeArray x 11 "World"
| False => do putStrLn "should success 2"
exitFailure
False <- writeArray x 20 "World"
| True => do putStrLn "should fail"
exitFailure
printLn !(toList x)
y <- fromList (map Just [1,2,3,4,5])
printLn !(toList y)