Thanks Aditya...I think that is what I am looking for.
On Mon, Jul 19, 2010 at 10:40 PM, aditya siram aditya.si...@gmail.comwrote:
Sorry, the previous code does not compile. It should be:
replace :: Int - [IORef (Int,Int,Int)] - (Int,Int,Int) - IO ()
replace index pixels new_val = do
C K Kashyap ckkash...@gmail.com writes:
I looked at State Monad yesterday and this question popped into my mind.
From what I gather State Monad essentially allows the use of Haskell's do
notation to invisibly pass around a state. So, does the use of Monadic
style fetch us more than syntactic
Okay...I think I am beginning to understand.
Is it right to assume that magic is backed by FFI and cannot be done in
pure Haskell?
On Mon, Jul 19, 2010 at 1:47 PM, Ketil Malde ke...@malde.org wrote:
C K Kashyap ckkash...@gmail.com writes:
I looked at State Monad yesterday and this question
Also, Claude ... If I am correct, in your example, there is no in-place
replacement happening.
On Mon, Jul 19, 2010 at 2:36 PM, C K Kashyap ckkash...@gmail.com wrote:
Okay...I think I am beginning to understand.
Is it right to assume that magic is backed by FFI and cannot be done in
pure
On Mon, Jul 19, 2010 at 10:17 AM, Ketil Malde ke...@malde.org wrote:
At it's heart, monads are just syntactic convenience, but like many
other syntactic conveniences, allows you to structure your code better.
Thus it's more about programmer efficiency than program efficiency.
(The do notation
Do you want a solution like this?
import Data.IORef
replace :: Int - [IORef (Int,Int,Int)] - (Int,Int,Int) - IO ()
replace index pixels new_val = do
old_val - return $ pixels !! index
writeIORef old_val new_val
print_pixels = mapM (\p - readIORef p = print)
test_data :: [(Int,Int,Int)]
Sorry, the previous code does not compile. It should be:
replace :: Int - [IORef (Int,Int,Int)] - (Int,Int,Int) - IO ()
replace index pixels new_val = do
old_val - return $ pixels !! index
writeIORef old_val new_val
print_pixels = mapM_ (\p - readIORef p = print)
test_data :: [(Int,Int,Int)]
Thanks Wren,
Thanks Dave ... a quick question though could you point me to an example
where I could build up my own in place modifiable data structure in Haskell
without using any standard library stuff?
For example, if I wanted an image representation such as this
[[(Int,Int.Int)]] - basically
Hi,
On 16/07/10 07:35, C K Kashyap wrote:
Haskell without using any standard library stuff?
For example, if I wanted an image representation such as this
[[(Int,Int.Int)]] - basically a list of lists of 3 tuples (rgb) and
wanted to do in place replacement to set the pixel values, how could I
Hi Claude,
Thanks a lot for the example.
Btw, is this where you are trying in-place replacement?
modifyAtIndex :: (a - a) - Nat - List a - List a
modifyAtIndex f i as =
let ias = zip nats as
g (Tuple2 j a) = case i `eq` j of
False - a
Hi,
I looked at State Monad yesterday and this question popped into my mind.
From what I gather State Monad essentially allows the use of Haskell's do
notation to invisibly pass around a state. So, does the use of Monadic
style fetch us more than syntactic convenience?
Again, if I understand
On Thursday 15 July 2010 18:02:47, C K Kashyap wrote:
Hi,
I looked at State Monad yesterday and this question popped into my mind.
From what I gather State Monad essentially allows the use of Haskell's
do
notation to invisibly pass around a state. So, does the use of Monadic
style fetch
On Thu, Jul 15, 2010 at 9:02 AM, C K Kashyap ckkash...@gmail.com wrote:
Hi,
I looked at State Monad yesterday and this question popped into my mind.
From what I gather State Monad essentially allows the use of Haskell's do
notation to invisibly pass around a state. So, does the use of Monadic
Thanks Daniel,
Better refactorability.
If you're using monadic style, changing from, say,
State Thing
to
StateT Thing OtherMonad
or from
StateT Thing FirstMonad
to
StateT Thing SecondMonad
typically requires only few changes. Explicit state-passing usually
requires more changes.
So,
Thanks David for the detailed explanation.
A couple of quick clarifications -
1. Even the invisible state that gets modified during the monadic
evaluation is referred to as side effect right?
2. I am a little unclear about in-place - does pure Haskell let one do
such a thing- or does it need
On Thu, Jul 15, 2010 at 10:34 AM, C K Kashyap ckkash...@gmail.com wrote:
Thanks David for the detailed explanation.
A couple of quick clarifications -
1. Even the invisible state that gets modified during the monadic
evaluation is referred to as side effect right?
If the state is free of
C K Kashyap wrote:
Thanks Daniel,
Better refactorability.
If you're using monadic style, changing from, say,
State Thing
to
StateT Thing OtherMonad
or from
StateT Thing FirstMonad
to
StateT Thing SecondMonad
typically requires only few changes. Explicit state-passing usually
requires more
17 matches
Mail list logo