2 ms·
The prelude isn't everything in Haskell. Just like you need to import sys or do import re in python to get at things less used here too you have to do the same.
by mitchty 9y ago
The prelude isn't everything in Haskell. Just like you need to import sys or do import re in python to get at things less used here too you have to do the same.
λ :m Data.Array
λ let x = array (1,3) [(1,1), (2,2), (3,3)]
x :: (Num e, Num i, Ix i) => Array i e
λ x
array (1,3) [(1,1),(2,2),(3,3)]
it :: (Ix i, Num i, Num e) => Array i e
λ x // [(2,42)]
array (1,3) [(1,1),(2,42),(3,3)]
it :: (Num i, Num e, Ix i) => Array i e
λ x
array (1,3) [(1,1),(2,2),(3,3)]
it :: (Ix i, Num i, Num e) => Array i e
Note however that this isn't mutating x directly, to do mutation would require state or a monad.