POV-Ray : Newsgroups : povray.off-topic : Try Haskell Server Time
4 Sep 2024 19:22:34 EDT (-0400)
  Try Haskell (Message 1 to 10 of 62)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Invisible
Subject: Try Haskell
Date: 1 Mar 2010 06:50:09
Message: <4b8ba9f1@news.povray.org>
Yesterday, this came into existence:

http://tryhaskell.org/

It gives you a window with a command prompt. Type any valid Haskell 
expression and it'll execute it and display the result (and the type 
signature of the result).

There used to be another site like this powered by LambdaBot, but it 
stopped working years ago. Finally we have a working site again.

Of course, it's still alpha quality. The command history is screwier 
than a squirrel. I/O operations fail with a perplexing error message. 
(OK, there's no obvious way for I/O operations to work - and we don't 
want random Internet users deleting files off the server! - but the 
error could be better.) Most seriously, you can only enter 1-liners. You 
can't define variables and then use them later; the entire thing you 
want to execute must be a single, giant, line.

Actually, I have a question. How is a site like this even physically 
possible in the first place? How can you send a request to the server 
and receive a response without reloading the entire page? I've seen 
several sites do this, but I have no idea how it's possible.

Anyway, the site has a small (OK tiny) tutorial which will teach you 
about 0.1% of Haskell. (Type "help" to start it.) Here's a few cryptic 
1-liners for producing "interesting" results:

product [1..100]
(Calculate 100!, which is really, really big by the way.)

let f = 1 : 1 : zipWith (+) f (tail f) in f
(Infinite list of Fibonacci numbers.)

let p = [1] : map (\r -> zipWith (+) ([0] ++ r) (r ++ [0])) p in p
(Infinite Pascal's triangle.)

scanl (*) 1 [1..]
(Infinite list of factorials.)

[ (x,y) | x <- ['A'..'Z'], y <- [1..10] ]
(Cartesian product of two lists.)

filterM (const [True, False]) "ABC"
(All sublists of a list.)

Obviously the "infinite" results get truncated to be finite. Also if you 
ask the server to do anything really slow, it terminates the calculation 
after a second or so and just says "terminated".


Post a reply to this message

From: Darren New
Subject: Re: Try Haskell
Date: 1 Mar 2010 12:34:10
Message: <4b8bfa92@news.povray.org>
Invisible wrote:
> Actually, I have a question. How is a site like this even physically 
> possible in the first place? How can you send a request to the server 
> and receive a response without reloading the entire page? 

The term you're looking for is AJAX, which is a method of programming web 
pages that uses the XMLHttpRequest function. If you understand generally how 
XMLHttpRequest works, you'll understand how this works.

-- 
Darren New, San Diego CA, USA (PST)
   The question in today's corporate environment is not
   so much "what color is your parachute?" as it is
   "what color is your nose?"


Post a reply to this message

From: Invisible
Subject: Re: Try AJAX
Date: 2 Mar 2010 05:19:04
Message: <4b8ce618@news.povray.org>
>> Actually, I have a question. How is a site like this even physically 
>> possible in the first place? How can you send a request to the server 
>> and receive a response without reloading the entire page? 
> 
> The term you're looking for is AJAX, which is a method of programming 
> web pages that uses the XMLHttpRequest function. If you understand 
> generally how XMLHttpRequest works, you'll understand how this works.

Right, so... if I'm understanding this right, XMLHttpRequest allows a 
mere script to instruct the browser to send an HTTP request, and return 
the body of the response as data, which the script can then further 
manipulate? (Rather than, say, just nagivating to another page, in which 
case the script can't process the data because the script won't even 
*exist* any mroe...)

I had no idea that you can actually do that...

(Then again, Wikipedia's example code seems to show JavaScript doing 
exception handling too, which I had no idea was possible.)


Post a reply to this message

From: Invisible
Subject: Re: Try AJAX
Date: 2 Mar 2010 05:56:44
Message: <4b8ceeec$1@news.povray.org>
Invisible wrote:

> Right, so... if I'm understanding this right, XMLHttpRequest allows a 
> mere script to instruct the browser to send an HTTP request, and return 
> the body of the response as data, which the script can then further 
> manipulate?

http://www.w3.org/TR/XMLHttpRequest/#the-xmlhttprequest-interface

Seems reasonably clear...


Post a reply to this message

From: scott
Subject: Re: Try Haskell
Date: 2 Mar 2010 06:43:58
Message: <4b8cf9fe$1@news.povray.org>
> http://tryhaskell.org/

The tutorial was good up until step 7, then the line:

> let villain = (28,"chirs") in fst villain

Made no sense at all.  I get it returns 28, but it's confusing what's going 
on, why the need for a variable (I assume villain is a variable name?).  I 
would have thought that writing 'fst (28,"chirs")' would be the thing to do 
to return 28? (I guess that fst returns the first element of a list?)

A lot of guessing and confusing on my part without much explanation...


Post a reply to this message

From: Invisible
Subject: Re: Try Haskell
Date: 2 Mar 2010 06:48:19
Message: <4b8cfb03$1@news.povray.org>
scott wrote:
>> http://tryhaskell.org/
> 
> The tutorial was good up until step 7, then the line:
> 
>> let villain = (28,"chirs") in fst villain
> 
> Made no sense at all.

I agree. Several concepts introduced at once without much explanation.

(Apparently the author also agrees, and is looking at trying to do 
better...)


Post a reply to this message

From: Darren New
Subject: Re: Try AJAX
Date: 2 Mar 2010 11:56:28
Message: <4b8d433c$1@news.povray.org>
Invisible wrote:
> Right, so... if I'm understanding this right, XMLHttpRequest allows a 
> mere script to instruct the browser to send an HTTP request, and return 
> the body of the response as data, which the script can then further 
> manipulate? (Rather than, say, just nagivating to another page, in which 
> case the script can't process the data because the script won't even 
> *exist* any mroe...)

Exactly, yes.

> I had no idea that you can actually do that...

Well, there ya go. MS actually invented that technique with ActiveX for 
their Outlook web thing, and everyone else picked up on it and turned it 
into a standard.

> (Then again, Wikipedia's example code seems to show JavaScript doing 
> exception handling too, which I had no idea was possible.)

Huh. I don't remember ever doing that, but I guess if the browser can tell 
you about errors, then there's probably some way to catch them.

-- 
Darren New, San Diego CA, USA (PST)
   The question in today's corporate environment is not
   so much "what color is your parachute?" as it is
   "what color is your nose?"


Post a reply to this message

From: Invisible
Subject: Re: Try AJAX
Date: 2 Mar 2010 11:58:50
Message: <4b8d43ca$1@news.povray.org>
Darren New wrote:

>> I had no idea that you can actually do that...
> 
> Well, there ya go. MS actually invented that technique with ActiveX for 
> their Outlook web thing, and everyone else picked up on it and turned it 
> into a standard.

Looking at the W3C standard spec, there seems to be *huge* abouts of 
tricky processing and non-obvious behaviour which strongly looks as if 
it's only there for backwards compatibility (i.e., because this is the 
ad hoc way the first implementation happened to do it).

Man, web stuff is messy...


Post a reply to this message

From: Darren New
Subject: Re: Try AJAX
Date: 2 Mar 2010 12:06:24
Message: <4b8d4590$1@news.povray.org>
Invisible wrote:
> ad hoc way the first implementation happened to do it).

Yeah. You want to know who started the browser wars? Look at your agent 
string. :-)

There are also a lot of standards that got changed in subtle ways that broke 
a lot of stuff, because the first spec was basically "here's how we do it." 
For example, Netscape said "Here's how we do cookies.  Yadda yadda only save 
20 per site yadda yadda."  IE did the same thing.  W3C comes along and makes 
a standard that says any number of cookies per site. Lots of web sites that 
for some stupid reason depended on only having 20 cookies fail with 
W3C-compliant browsers, continuing to work with IE *because* MS won't follow 
the standards and instead wants the web pages to work right for their 
customers, even when the pages on the server are stupidly coded. Launch 
complaining in 3... 2... 1....

-- 
Darren New, San Diego CA, USA (PST)
   The question in today's corporate environment is not
   so much "what color is your parachute?" as it is
   "what color is your nose?"


Post a reply to this message

From: Warp
Subject: Re: Try AJAX
Date: 2 Mar 2010 12:17:52
Message: <4b8d4840@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> I had no idea that you can actually do that...

  You clearly haven't used gmail.

-- 
                                                          - Warp


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.