Search Haskell Channel Logs

Sunday, March 5, 2017

#haskell channel featuring c_wraith, ski, spatial, monochrom, angerman,

angerman 2017-03-05 16:11:22
So I don't have an alternative instance for Either a b ... oh.
spatial 2017-03-05 16:12:38
In imperative lang. I would store that array globally and read and write.
spatial 2017-03-05 16:13:06
I have multiple Haskell functions that have to read and write to that array. How is it done ?
monochrom 2017-03-05 16:13:15
Pass as parameter.
spatial 2017-03-05 16:13:39
Don't want to pass.
c_wraith 2017-03-05 16:13:45
close over it
spatial 2017-03-05 16:14:34
closure ? Treat me gently. I am learning.
spatial 2017-03-05 16:15:09
Struggled with State Monad for that. Didn't work.
c_wraith 2017-03-05 16:15:26
in general, "pass it as a parameter" is correct. Closing over it just means define all the functions that use it when the array is already in scope. It's awkward, but it's the only thing you can do other than pass it.
c_wraith 2017-03-05 16:16:30
State is just parameter-passing, by the way.
ski 2017-03-05 16:16:35
(a shorter way to define `createarray' is `createarray = newArray (512,512) 0')
spatial 2017-03-05 16:18:49
ski: Ok
ski 2017-03-05 16:20:15
a process-extent mutable variable is seldom the right thing to do. more commonly one would like different threads, if executing same code, to access different versions ("threadsafe" and all that)
ski 2017-03-05 16:30:28
use `liftIO' to be able to call ordinary `IO' actions inside the `ReaderT (...) IO' context
spatial 2017-03-05 16:34:37
Has someone created such an example ?
c_wraith 2017-03-05 16:34:59
ski just spelled out everything
spatial 2017-03-05 16:35:08
Let me search