Re: Re[2]: Make it possible to evaluate monadic actions when assigning record fields

2007-07-12 Thread Neil Mitchell

Hi


> This extension seems like a great idea - my only concern would be
> about the order of computations. Clearly left-to-right makes sense,
> but this may break some natural intuition in Haskell:

i think that undefined order will be a best one


Using "undefined" does not make for great reading in a standard! You
just know that Hugs will pick right to left, Yhc will pick left to
right, and GHC will offer a flag to choose between them ;)

We have to pick, and there is only one logical choice - left to right.

Thanks

Neil
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re[2]: Make it possible to evaluate monadic actions when assigning record fields

2007-07-12 Thread Bulat Ziganshin
Hello Neil,

Thursday, July 12, 2007, 3:10:10 PM, you wrote:
> This extension seems like a great idea - my only concern would be
> about the order of computations. Clearly left-to-right makes sense,
> but this may break some natural intuition in Haskell:

i think that undefined order will be a best one


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re[2]: Make it possible to evaluate monadic actions when assigning record fields

2007-07-11 Thread Bulat Ziganshin
Hello Simon,

Wednesday, July 11, 2007, 11:38:31 AM, you wrote:

> So Greg's idea (or at least my understanding thereof) is to write it like 
> this:

> do { f $(stuff1) $(stuff2) }

Simon, it is thing i dreamed for a years! Haskell has serious drawback
for imperative programming compared to C - each action should be
written as separate statement and this makes program too wordy - just
try to rewrite something like x[i] += y[i]*z[i] in Haskell

i need a way to perform actions and read data values inside
calculations. there are two possible ways:

* write pure expressions like we do in C and let's ghc guess yourself
where evaluation should be added:

x <- newIORef 1
y <- newIORef 1
z <- newIORef 1
f x (y*z)

this means that any expression of type IORef a or IO a automatically
translated into evaluation. the same should work for arrays, hashes
and so on, so it probably should be a class. the problem, of course, is
that IO/IORef/.. is a first class values so it's hard to distinguish
where it should be evaluated and where used as is. another problem is
its interaction with type inference - we may not know which concrete
type this expression has


* add an explicit operation which evaluates data, as you suggests.
again, it should be a class which allows to add evaluation support for
hashes/...

actually, ML has something similar - it uses "." operation to evaluate
variable values


=
and, while we on this topic, another problem for imperative
programming style usability is control structures. how we can rewrite
the following:

delta=1000
while (delta>0.01)
  x = ...
  if (x<0) break
  delta = abs(n-x*x)

=
btw, proposal of "prefix expressions" also simplifies imperative
programs a bit: now we should write something like this:

when (a>0) $ do
  .

while this proposal allows to omit "$" and make program look a bit more
natural

=
one more complaint: the syntax

for list $ \item -> do
  

doesn't look too natural compared to other languages. it will be great to
write it as
  
for item in list do
  

- of course, with 'for' still a plain function defined by user


=
may be, i should collect all these ideas on "imperative programming"
page?


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime