mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 20:23:11 +03:00
c80a502627
As suggested in #1677. Crashing on out-of-bounds might be more practical, but we can reconsider it later.
23 lines
574 B
Idris
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)
|