News for hackers. Stuff that matters.
Re:How do I modify a variable in Haskell? by jordigh on Tuesday August 15, 2017 @10:05AM (#15018251)

    Prelude> let x = [1, 2, 3]
    Prelude> x
    [1,2,3]
    Prelude> x // [(2,42)]

    <interactive>:5:3:
        Not in scope: `//'
        Perhaps you meant one of these:
          `/' (imported from Prelude), `/=' (imported from Prelude)
So, how canonical is this if it's not in Prelude?
Re:How do I modify a variable in Haskell? by mitchty on Tuesday August 15, 2017 @11:03AM (#15018849)
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.
Re:How do I modify a variable in Haskell? by tome on Tuesday August 15, 2017 @10:39AM (#15018560)
Further to the other answers given, `[1, 2, 3]` is not an array, but rather a list.
Re:How do I modify a variable in Haskell? by berdario on Tuesday August 15, 2017 @10:23AM (#15018413)
The Prelude is just what's visible in the default namespace, it's not the whole language

Data.Array and // are also described in the Haskell 2010 report

https://www.haskell.org/onlinereport/haskell2010/haskellch14...

Re:How do I modify a variable in Haskell? by mej10 on Tuesday August 15, 2017 @10:16AM (#15018344)
I understand the source of your question -- not all languages provide arrays in the included-by-default namespace. Python for example requires you to import an array module. These are part of the standard library in both cases.

This makes it a little harder to get started but considering the kinds of things programmers put up with on a daily basis is extremely mild.