Tomasz Zielonka wrote:
It's quite easy if you allow the indices to be put in a
single compound value.

Hmm. Well, I guess I don't need to insist on the exact
type that I gave in the statement of the puzzle - although
something like that would be the nicest.

This is actually a function that is useful quite often in
practice. But I would rather not be forced to write things
like

replace (I 0 $ I 2 $ I 3 $ ())

in my code. My first attempt was very similar to yours,
except I used

replace (0, (2, (3, ())))

instead of your Index type. I don't like my solution, either.

So I guess I would define a full solution as something
nice enough to be used in practice. Let's be more
concrete - it has to be nice enough that most people
who need, say, replace2 or replace3, in real life, would
actually use your function instead of writing it out by hand.

Maybe others would disagree, but so far, I personally
do not use either your solution or my solution. I write it
out by hand.

If you insist that each index should be given as a separate
function argument, it may be possible to achieve it using the tricks
that allow to write the variadic composition operator.

I am not familiar with that. Do you have a reference?
Is that the best way to do it? (Is that a way to do it at all?)

Thanks,
Yitz
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to