caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] try ocaml website
@ 2011-12-23 18:00 Fabrice Le Fessant
  2011-12-23 18:40 ` Dominique Martinet
                   ` (6 more replies)
  0 siblings, 7 replies; 24+ messages in thread
From: Fabrice Le Fessant @ 2011-12-23 18:00 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1293 bytes --]

Dear ocamllers,

  We worked hard on our "Try OCaml" website, started by Çagdas, and we
managed to improve it enough, so that we think people can start using it
(and hopefully, improving it).

It is available here:

http://try.ocamlpro.com/

  There are 3 lessons, two lessons for "getting a taste of OCaml"
(totalling 10 steps), and the last one about some new features in 3.12.
You can use the "lessons()" command in the toplevel to get the current
list of lessons (in case we contribute more in the meantime !).

  We welcome any comment to improve it, bug reports, and new content.
The repository is on Github:

https://github.com/OCamlPro/tryocaml

  You can easily fork it, compile it, modify it, and send us pull
requests if you want your content published on our site.

We will probably continue to focus on the first lessons (the "getting a
taste of OCaml" virtual section), but we are also looking for
contributions on advanced topics : we plan to make them start around
lesson 10, and focus on particular issues (modules, functors, labels,
objects, classes, polymorphic variants, etc.). Send us a mail if you
want to volunteer !

  As the engine is translated from OCaml to Javascript by js_of_ocaml,
you can even play with it offline, when you are disconnected.

Have fun,
Fabrice

[-- Attachment #2: fabrice_le_fessant.vcf --]
[-- Type: text/x-vcard, Size: 380 bytes --]

begin:vcard
fn:Fabrice LE FESSANT
n:LE FESSANT;Fabrice
org:INRIA Saclay -- Ile-de-France;P2P & OCaml
adr;quoted-printable:;;Parc Orsay Universit=C3=A9 ;Orsay CEDEX;;91893;France
email;internet:fabrice.le_fessant@inria.fr
title;quoted-printable:Charg=C3=A9 de Recherche
tel;work:+33 1 74 85 42 14
tel;fax:+33 1 74 85 42 49 
url:http://fabrice.lefessant.net/
version:2.1
end:vcard


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:00 [Caml-list] try ocaml website Fabrice Le Fessant
@ 2011-12-23 18:40 ` Dominique Martinet
  2011-12-23 18:49   ` Çagdas Bozman
  2011-12-23 18:40 ` oliver
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Dominique Martinet @ 2011-12-23 18:40 UTC (permalink / raw)
  To: caml-list

Hi,

The website is really nice :) I'm a bit too used to ledit and find the
lack of ^w, ^u, ^k a bit annoying, but the experience is really smooth,
that's good!

The only "real" thing that it's missing is a way to reset the toplevel
without reloading the page. It's the same problem as with the real
toplevel now that I think about it, but I didn't think of reloading the
page directly!

Great work anyway :)

-- 
Asmadeus | Dominique Martinet

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:00 [Caml-list] try ocaml website Fabrice Le Fessant
  2011-12-23 18:40 ` Dominique Martinet
@ 2011-12-23 18:40 ` oliver
  2011-12-24  8:51   ` Stéphane Glondu
  2011-12-23 18:54 ` Török Edwin
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: oliver @ 2011-12-23 18:40 UTC (permalink / raw)
  To: Fabrice Le Fessant; +Cc: caml-list

On Fri, Dec 23, 2011 at 07:00:20PM +0100, Fabrice Le Fessant wrote:
> Dear ocamllers,
> 
>   We worked hard on our "Try OCaml" website, started by Çagdas, and we
> managed to improve it enough, so that we think people can start using it
> (and hopefully, improving it).
> 
> It is available here:
> 
> http://try.ocamlpro.com/
[...]


Hey, toplevel as shellwindow in the broswer.

I like it. :-)

The black background makes it also looking seriously.

I didn't looked at the lessons in detail,
just typing in some code by myself and clicking
on some  of the examples.

Just to have a web-based trial of Ocaml is a good thing.
So people can try around before they decide to install it.

But if this is planned as a course, when the first paragraph mentions
that "OCaml is a strongly typed functional language.", then
additionally to working examples it might also make sense to show
examples, where types mismatch, so that people can see, what meaning it has
if the types do conflict.

And an explanation of the advantages might also be good, because
most people prefer the convenience of automatic coercion over the
annoyance of a picky typesystem, when they decide to use a language.

Maybe something like commenting boxes could be added, which
explain the advantages/disadvantages of some certain properties
of the language and someting like a "background box", which explains
for example some conecptual issues of either functional programming,
like referential transparency, or some background on the type system.
Or for explaining design decisions of OCaml, for example the motivation
for mutable strings, as opposed to functional, as in other functional
languages (and tips&tricks how to make a functional implementation, just to
show, it could be done).


[...]
>   As the engine is translated from OCaml to Javascript by js_of_ocaml,
> you can even play with it offline, when you are disconnected.
[...]

js_of_ocaml ??

Hey, didn't knew that.

If it works fine, then it is a big, big pro to OCaml,
compared to some other languages which are used often for
web-development (like Python, Perl and so on).

From the js_of_ocaml page it looks like it's based on Ocsigen.
Maybe it's time to explore it. :-)

This all looks promising!

Maybe webprogramming can turn from ugly annoyance into a pleasure
this way....


Ciao,
   Oliver


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:40 ` Dominique Martinet
@ 2011-12-23 18:49   ` Çagdas Bozman
  2011-12-23 19:10     ` Dominique Martinet
  2011-12-26  8:09     ` Gabriel Scherer
  0 siblings, 2 replies; 24+ messages in thread
From: Çagdas Bozman @ 2011-12-23 18:49 UTC (permalink / raw)
  To: Dominique Martinet; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

>
> The only "real" thing that it's missing is a way to reset the toplevel
> without reloading the page. It's the same problem as with the real
> toplevel now that I think about it, but I didn't think of reloading the
> page directly!
>
>
You can clear the editor view by using the command "clear()".

-- 
Çagdas Bozman <cagdas.bozman@ocamlpro.com>

[-- Attachment #2: Type: text/html, Size: 739 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:00 [Caml-list] try ocaml website Fabrice Le Fessant
  2011-12-23 18:40 ` Dominique Martinet
  2011-12-23 18:40 ` oliver
@ 2011-12-23 18:54 ` Török Edwin
  2011-12-23 21:27   ` oliver
  2011-12-23 18:56 ` Ashish Agarwal
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Török Edwin @ 2011-12-23 18:54 UTC (permalink / raw)
  To: caml-list

On 12/23/2011 08:00 PM, Fabrice Le Fessant wrote:
> Dear ocamllers,
> 
>   We worked hard on our "Try OCaml" website, started by Çagdas, and we
> managed to improve it enough, so that we think people can start using it
> (and hopefully, improving it).
> 
> It is available here:
> 
> http://try.ocamlpro.com/
> 
>   There are 3 lessons, two lessons for "getting a taste of OCaml"
> (totalling 10 steps), and the last one about some new features in 3.12.
> You can use the "lessons()" command in the toplevel to get the current
> list of lessons (in case we contribute more in the meantime !).
> 
>   We welcome any comment to improve it, bug reports, and new content.

Would it be possible to provide the Nums module?
I think it'd look nice to show that you can do bignum ops using just the stdlib.

Best regards,
--Edwin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:00 [Caml-list] try ocaml website Fabrice Le Fessant
                   ` (2 preceding siblings ...)
  2011-12-23 18:54 ` Török Edwin
@ 2011-12-23 18:56 ` Ashish Agarwal
  2011-12-23 19:15   ` Philippe Strauss
  2011-12-23 21:32   ` oliver
  2011-12-26  8:50 ` Mihamina Rakotomandimby
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 24+ messages in thread
From: Ashish Agarwal @ 2011-12-23 18:56 UTC (permalink / raw)
  To: Fabrice Le Fessant; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 2114 bytes --]

This is really great!

One comment, it doesn't work on Safari. I see parts of the page, but the
dynamic parts don't work. This is a problem I already had on an
ocsigen.orgpage, and I reported on the Ocsigen list. When I turn on
the javascript
debugger in Safari and reload the page, it then works. However, without the
javascript console open, refreshing the page does nothing.


On Fri, Dec 23, 2011 at 1:00 PM, Fabrice Le Fessant <
Fabrice.Le_fessant@inria.fr> wrote:

> Dear ocamllers,
>
>  We worked hard on our "Try OCaml" website, started by Çagdas, and we
> managed to improve it enough, so that we think people can start using it
> (and hopefully, improving it).
>
> It is available here:
>
> http://try.ocamlpro.com/
>
>  There are 3 lessons, two lessons for "getting a taste of OCaml"
> (totalling 10 steps), and the last one about some new features in 3.12.
> You can use the "lessons()" command in the toplevel to get the current
> list of lessons (in case we contribute more in the meantime !).
>
>  We welcome any comment to improve it, bug reports, and new content.
> The repository is on Github:
>
> https://github.com/OCamlPro/tryocaml
>
>  You can easily fork it, compile it, modify it, and send us pull
> requests if you want your content published on our site.
>
> We will probably continue to focus on the first lessons (the "getting a
> taste of OCaml" virtual section), but we are also looking for
> contributions on advanced topics : we plan to make them start around
> lesson 10, and focus on particular issues (modules, functors, labels,
> objects, classes, polymorphic variants, etc.). Send us a mail if you
> want to volunteer !
>
>  As the engine is translated from OCaml to Javascript by js_of_ocaml,
> you can even play with it offline, when you are disconnected.
>
> Have fun,
> Fabrice
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>

[-- Attachment #2: Type: text/html, Size: 2960 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:49   ` Çagdas Bozman
@ 2011-12-23 19:10     ` Dominique Martinet
  2011-12-23 19:29       ` Jérémie Dimino
  2011-12-23 19:36       ` Adrien
  2011-12-26  8:09     ` Gabriel Scherer
  1 sibling, 2 replies; 24+ messages in thread
From: Dominique Martinet @ 2011-12-23 19:10 UTC (permalink / raw)
  To: Çagdas Bozman; +Cc: caml-list

Hi,

Çagdas Bozman wrote on Fri, Dec 23, 2011 :
> > The only "real" thing that it's missing is a way to reset the toplevel
> > without reloading the page. It's the same problem as with the real
> > toplevel now that I think about it, but I didn't think of reloading the
> > page directly!
>
> You can clear the editor view by using the command "clear()".

Yes, I've seen that - what I mean isn't clearing the view, but really
reseting the variables and whatever is defined.
Maybe there actually is something in the standard toplevel, but I don't
think I've ever heard about it :)

The behaviour I want would be:

# let x = 42;;
val x : int = 42
# reset ();;
- : unit = ()
# x;;
Characters 0-1:
Error: Unbound value x


Regards,
-- 
Dominique Martinet | Asmadeus

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:56 ` Ashish Agarwal
@ 2011-12-23 19:15   ` Philippe Strauss
  2011-12-23 21:14     ` Norman Hardy
  2011-12-23 21:32   ` oliver
  1 sibling, 1 reply; 24+ messages in thread
From: Philippe Strauss @ 2011-12-23 19:15 UTC (permalink / raw)
  To: Ashish Agarwal; +Cc: Fabrice Le Fessant, caml-list

On Fri, Dec 23, 2011 at 01:56:46PM -0500, Ashish Agarwal wrote:
> This is really great!
> 
> One comment, it doesn't work on Safari. I see parts of the page, but the
> dynamic parts don't work. This is a problem I already had on an
> ocsigen.orgpage, and I reported on the Ocsigen list. When I turn on
> the javascript
> debugger in Safari and reload the page, it then works. However, without the
> javascript console open, refreshing the page does nothing.

I confirm that one.

on safari 5.1.2 (OSX 10.6.8) it does not work, while within chrome and FF it runs fine.

-- 
Philippe Strauss
av. de Beaulieu 25
1004 Lausanne
http://www.philou.ch

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 19:10     ` Dominique Martinet
@ 2011-12-23 19:29       ` Jérémie Dimino
  2011-12-23 19:39         ` Dominique Martinet
  2011-12-23 21:35         ` oliver
  2011-12-23 19:36       ` Adrien
  1 sibling, 2 replies; 24+ messages in thread
From: Jérémie Dimino @ 2011-12-23 19:29 UTC (permalink / raw)
  To: Dominique Martinet; +Cc: Çagdas Bozman, caml-list

Le vendredi 23 décembre 2011 à 20:10 +0100, Dominique Martinet a écrit :
> Yes, I've seen that - what I mean isn't clearing the view, but really
> reseting the variables and whatever is defined.
> Maybe there actually is something in the standard toplevel, but I don't
> think I've ever heard about it :)

You can do that:

# let env = !Toploop.toplevel_env;;
val env : Env.t = <abstr>
# let x = 1;;
val x : int = 1
# Toploop.toplevel_env := env;;
- : unit = ()
# x;;
Characters 0-1:
Error: Unbound value x

Cheers,

-- 
Jérémie



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 19:10     ` Dominique Martinet
  2011-12-23 19:29       ` Jérémie Dimino
@ 2011-12-23 19:36       ` Adrien
  1 sibling, 0 replies; 24+ messages in thread
From: Adrien @ 2011-12-23 19:36 UTC (permalink / raw)
  To: Dominique Martinet; +Cc: Çagdas Bozman, caml-list

I happened to have a windows virtual machine started and tried in IE 8
(8.0.7600.16385). I can't type in it and it seems to work fine at
first I get this behaviour:
  # let x = 42;;
  # x;;
  Characters 0-1:
  Error: Unbound value x

Also, something statements don't produce anything on screen except a
new prompt: "42;;" and "print_endline \"pouet\";;" don't print
anything. It looks like nothing gets evaluated.

I wouldn't consider IE8 as a high-priority however since I've actually
been having troubles finding people who were using IE on their own
free will nowadays.

Regards,
Adrien Nader

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 19:29       ` Jérémie Dimino
@ 2011-12-23 19:39         ` Dominique Martinet
  2011-12-23 21:35         ` oliver
  1 sibling, 0 replies; 24+ messages in thread
From: Dominique Martinet @ 2011-12-23 19:39 UTC (permalink / raw)
  To: caml-list

Hi,

Jérémie Dimino wrote on Fri, Dec 23, 2011 :
> # let env = !Toploop.toplevel_env;;
> val env : Env.t = <abstr>
> # let x = 1;;
> val x : int = 1
> # Toploop.toplevel_env := env;;
> - : unit = ()
> # x;;
> Characters 0-1:
> Error: Unbound value x

Thanks!
I've even found Toploop.initialize_toplevel_env () that does exactly
what I wanted thanks to you :)


It might be a good idea to make it more obvious or name it in the handy
commands of the website then - I really believe that people, especially
beginners or when toying around, want to clean their environment
often. I though about it because I just had something weird I could not
explain because the first thing I did was define a global x, and 10
minutes later it came back inside a function where I shouldn't have had
an x...
Maybe reset it when changing lesson? (though that might be unwanted
sometimes too, I don't know.)


Cheers,
-- 
Dominique Martinet | Asmadeus

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 19:15   ` Philippe Strauss
@ 2011-12-23 21:14     ` Norman Hardy
  2011-12-23 21:18       ` William Le Ferrand
  0 siblings, 1 reply; 24+ messages in thread
From: Norman Hardy @ 2011-12-23 21:14 UTC (permalink / raw)
  To: Philippe Strauss; +Cc: Ashish Agarwal, Fabrice Le Fessant, caml-list


On 2011 Dec 23, at 11:15 , Philippe Strauss wrote:

> On Fri, Dec 23, 2011 at 01:56:46PM -0500, Ashish Agarwal wrote:
>> This is really great!
>> 
>> One comment, it doesn't work on Safari. I see parts of the page, but the
>> dynamic parts don't work. This is a problem I already had on an
>> ocsigen.orgpage, and I reported on the Ocsigen list. When I turn on
>> the javascript
>> debugger in Safari and reload the page, it then works. However, without the
>> javascript console open, refreshing the page does nothing.
> 
> I confirm that one.
> 
> on safari 5.1.2 (OSX 10.6.8) it does not work, while within chrome and FF it runs fine.

It works on WebKit which is an experimental version of Safari:
http://nightly.webkit.org/

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 21:14     ` Norman Hardy
@ 2011-12-23 21:18       ` William Le Ferrand
  0 siblings, 0 replies; 24+ messages in thread
From: William Le Ferrand @ 2011-12-23 21:18 UTC (permalink / raw)
  To: Norman Hardy
  Cc: Philippe Strauss, Ashish Agarwal, Fabrice Le Fessant, caml-list

[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]

Awesome work, congratulations !



On Fri, Dec 23, 2011 at 1:14 PM, Norman Hardy <norm@cap-lore.com> wrote:

>
> On 2011 Dec 23, at 11:15 , Philippe Strauss wrote:
>
> > On Fri, Dec 23, 2011 at 01:56:46PM -0500, Ashish Agarwal wrote:
> >> This is really great!
> >>
> >> One comment, it doesn't work on Safari. I see parts of the page, but the
> >> dynamic parts don't work. This is a problem I already had on an
> >> ocsigen.orgpage, and I reported on the Ocsigen list. When I turn on
> >> the javascript
> >> debugger in Safari and reload the page, it then works. However, without
> the
> >> javascript console open, refreshing the page does nothing.
> >
> > I confirm that one.
> >
> > on safari 5.1.2 (OSX 10.6.8) it does not work, while within chrome and
> FF it runs fine.
>
> It works on WebKit which is an experimental version of Safari:
> http://nightly.webkit.org/
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


-- 
William Le Ferrand

Mobile : (+1) (415) 683-1484
Web : http://williamleferrand.github.com/
<http://www.linkedin.com/in/williamleferrand>

[-- Attachment #2: Type: text/html, Size: 2386 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:54 ` Török Edwin
@ 2011-12-23 21:27   ` oliver
  0 siblings, 0 replies; 24+ messages in thread
From: oliver @ 2011-12-23 21:27 UTC (permalink / raw)
  To: Török Edwin; +Cc: caml-list

On Fri, Dec 23, 2011 at 08:54:15PM +0200, Török Edwin wrote:
> On 12/23/2011 08:00 PM, Fabrice Le Fessant wrote:
> > Dear ocamllers,
> > 
> >   We worked hard on our "Try OCaml" website, started by Çagdas, and we
> > managed to improve it enough, so that we think people can start using it
> > (and hopefully, improving it).
> > 
> > It is available here:
> > 
> > http://try.ocamlpro.com/
> > 
> >   There are 3 lessons, two lessons for "getting a taste of OCaml"
> > (totalling 10 steps), and the last one about some new features in 3.12.
> > You can use the "lessons()" command in the toplevel to get the current
> > list of lessons (in case we contribute more in the meantime !).
> > 
> >   We welcome any comment to improve it, bug reports, and new content.
> 
> Would it be possible to provide the Nums module?
> I think it'd look nice to show that you can do bignum ops using just the stdlib.
[...]

Following the manual, it's not part of the stdlib, even though it's shipped
in the std-distribution.

Ciao,
  Oliver

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:56 ` Ashish Agarwal
  2011-12-23 19:15   ` Philippe Strauss
@ 2011-12-23 21:32   ` oliver
  1 sibling, 0 replies; 24+ messages in thread
From: oliver @ 2011-12-23 21:32 UTC (permalink / raw)
  To: Ashish Agarwal; +Cc: Fabrice Le Fessant, caml-list

On Fri, Dec 23, 2011 at 01:56:46PM -0500, Ashish Agarwal wrote:
> This is really great!
> 
> One comment, it doesn't work on Safari.
[...]

On Konqueror it also does not work.

On FF it runs fine.


Ciao,
   Oliver

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 19:29       ` Jérémie Dimino
  2011-12-23 19:39         ` Dominique Martinet
@ 2011-12-23 21:35         ` oliver
  1 sibling, 0 replies; 24+ messages in thread
From: oliver @ 2011-12-23 21:35 UTC (permalink / raw)
  To: Jérémie Dimino
  Cc: Dominique Martinet, Çagdas Bozman, caml-list

On Fri, Dec 23, 2011 at 08:29:09PM +0100, Jérémie Dimino wrote:
> Le vendredi 23 décembre 2011 à 20:10 +0100, Dominique Martinet a écrit :
> > Yes, I've seen that - what I mean isn't clearing the view, but really
> > reseting the variables and whatever is defined.
> > Maybe there actually is something in the standard toplevel, but I don't
> > think I've ever heard about it :)
> 
> You can do that:
> 
> # let env = !Toploop.toplevel_env;;
> val env : Env.t = <abstr>
> # let x = 1;;
> val x : int = 1
> # Toploop.toplevel_env := env;;
> - : unit = ()
> # x;;
> Characters 0-1:
> Error: Unbound value x
[...]

Oh, cool. :-)

Ciao,
   Oliver

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:40 ` oliver
@ 2011-12-24  8:51   ` Stéphane Glondu
  2011-12-24 10:16     ` oliver
  0 siblings, 1 reply; 24+ messages in thread
From: Stéphane Glondu @ 2011-12-24  8:51 UTC (permalink / raw)
  To: oliver; +Cc: caml-list

Le 23/12/2011 19:40, oliver a écrit :
> From the js_of_ocaml page it looks like it's based on Ocsigen.
> Maybe it's time to explore it. :-)

It's the other way around: Ocsigen is based on js_of_ocaml. The examples
on [1] (and Try OCaml AFAICT) don't need Ocsigen.

[1] http://ocsigen.org/js_of_ocaml/manual/

If you want to write a full client-server application with both sides
written in OCaml and a clean integration, then Ocsigen is for you :-)


Cheers,

-- 
Stéphane



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-24  8:51   ` Stéphane Glondu
@ 2011-12-24 10:16     ` oliver
  2011-12-24 10:31       ` Dominique Martinet
  0 siblings, 1 reply; 24+ messages in thread
From: oliver @ 2011-12-24 10:16 UTC (permalink / raw)
  To: Stéphane Glondu; +Cc: caml-list

On Sat, Dec 24, 2011 at 09:51:54AM +0100, Stéphane Glondu wrote:
> Le 23/12/2011 19:40, oliver a écrit :
> > From the js_of_ocaml page it looks like it's based on Ocsigen.
> > Maybe it's time to explore it. :-)
> 
> It's the other way around: Ocsigen is based on js_of_ocaml.

??


> The examples
> on [1] (and Try OCaml AFAICT) don't need Ocsigen.

That it can be stand-alone, independent of Ocsigen, does not mean that
it is the base of Ocsigen.
From what I read it's rather that there are two components which might or moght
not work together, each undependently of the other.


[...]
> If you want to write a full client-server application with both sides
> written in OCaml and a clean integration, then Ocsigen is for you :-)
[...]

Yes, that was the most impressive thing I read about Ocsigen/js_of_ocaml,
that client and server stuff can be developed together.

To develop each side independently of the other all to often creates
inconsitencies and annoyance.

Also that OCaml is the base for it, of course is a big plus.

Is there also something like Python's Django for this project,
or planned at least?
Django is a Python-based Webframework that also integrates usage of databases.
And there are good reasons to have access to a databases in Web-applications.

So, such stuff would be needed too.


Ciao,
   Oliver

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-24 10:16     ` oliver
@ 2011-12-24 10:31       ` Dominique Martinet
  0 siblings, 0 replies; 24+ messages in thread
From: Dominique Martinet @ 2011-12-24 10:31 UTC (permalink / raw)
  To: caml-list

Hi,

oliver wrote on Sat, Dec 24, 2011 :
> Is there also something like Python's Django for this project,
> or planned at least?
> Django is a Python-based Webframework that also integrates usage of databases.
> And there are good reasons to have access to a databases in Web-applications.

I have only toyed around with ocsigen a bit and didn't make anything
complicated with it, but it includes database gestion out of the box -
either with just a file or with sqlite through its Ocsipersist module.

Of course, you're still free to use mysql or postgresql with the usual
ocaml libraries available through godi or other :)

I find ocsigen fairly complete and good for big projects, its only
problem is the lack of examples around compared to PHP or whatsnot, but
it is definitely more fun to write an ocsigen website ;)

Regards,
-- 
Dominique Martinet | Asmadeus

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:49   ` Çagdas Bozman
  2011-12-23 19:10     ` Dominique Martinet
@ 2011-12-26  8:09     ` Gabriel Scherer
  2011-12-27 20:23       ` Fabrice Le Fessant
  1 sibling, 1 reply; 24+ messages in thread
From: Gabriel Scherer @ 2011-12-26  8:09 UTC (permalink / raw)
  To: Çagdas Bozman; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]

I played with the toplevel a bit, but was frustrated by the limitation
of one-liner input.
Even in an interactive toplevel it is nice, I think, to be able to
write multiline programs.

The simple solution is to make ";;" mandatory, which clearly delimits
the end of user input (instead of considering all 'enter' as end of
input). The tryocaml toplevel is however very lenient regarding use of
";;", and I suppose this is a deliberate design choice.

I have implemented an heuristic to allow multiline input, based on a
past discussion with Nicolas Pouillard about, if I remember correctly,
Scala's toplevel behavior. The idea is to accumulate lines of input
until the parser either succeeds, or there is a syntax error; when it
just consumes all the line without producing a result, we wait for
more input.
Patch attached.

On Fri, Dec 23, 2011 at 7:49 PM, Çagdas Bozman
<cagdas.bozman@ocamlpro.com> wrote:
>> The only "real" thing that it's missing is a way to reset the toplevel
>> without reloading the page. It's the same problem as with the real
>> toplevel now that I think about it, but I didn't think of reloading the
>> page directly!
>>
>
> You can clear the editor view by using the command "clear()".
>
> --
> Çagdas Bozman <cagdas.bozman@ocamlpro.com>

[-- Attachment #2: 0001-Change-the-toplevel-to-allow-multiline-input.patch --]
[-- Type: text/x-diff, Size: 10335 bytes --]

From 263598f929d5d79d8dfe4ccb341565c0053abe06 Mon Sep 17 00:00:00 2001
From: Gabriel Scherer <gabriel.scherer@gmail.com>
Date: Sun, 25 Dec 2011 10:40:41 +0100
Subject: [PATCH] Change the toplevel to allow multiline input

The heuristic is the following: if parsing the input consumed the
whole line without raising a syntax error, we assume that it is
unfinished multiline input. We end the input as soon as parsing raises
a syntactic error, or succeeds.

Note that this may sometimes terminate input earlier than
intended. For example, if you try to write:

  let rec fac = function
    | 0 -> 1
    | n -> ...

then parsing will return a result at the end of the "| 0 -> 1", and
evaluate this incomplete definition. You have to write instead:

  let rec fac = begin function
    | 0 -> 1
    | n -> ...
  end

So that `begin` make all prefixes of the input (before `end`) invalid.
---
 tryocaml/toplevel.ml |  240 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 171 insertions(+), 69 deletions(-)

diff --git a/tryocaml/toplevel.ml b/tryocaml/toplevel.ml
index d3f0ac7..2fb5bad 100644
--- a/tryocaml/toplevel.ml
+++ b/tryocaml/toplevel.ml
@@ -75,39 +75,6 @@ let start ppf =
   Toploop.input_name := "";
   exec ppf "open Tutorial"
 
-let at_bol = ref true
-let consume_nl = ref false
-
-let refill_lexbuf s p ppf buffer len =
-  if !consume_nl then begin
-    let l = String.length s in
-    if (!p < l && s.[!p] = '\n') then
-      incr p
-    else if (!p + 1 < l && s.[!p] = '\r' && s.[!p + 1] = '\n') then
-      p := !p + 2;
-    consume_nl := false
-  end;
-  if !p = String.length s then
-    0
-  else begin
-    let c = s.[!p] in
-    incr p;
-    buffer.[0] <- c;
-    if !at_bol then Format.fprintf ppf "# ";
-    at_bol := (c = '\n');
-    if c = '\n' then
-      Format.fprintf ppf "@."
-    else
-      Format.fprintf ppf "%c" c;
-    1
-  end
-
-let ensure_at_bol ppf =
-  if not !at_bol then begin
-    Format.fprintf ppf "@.";
-    consume_nl := true; at_bol := true
-  end
-
 let update_lesson_text () =
   if  !Tutorial.this_lesson <> 0 then
   try
@@ -172,9 +139,6 @@ let text_of_html html =
   done;
   Buffer.contents b
 
-
-
-
 let update_debug_message =
   let b = Buffer.create 100 in
   Tutorial.debug_fun := (fun s -> Buffer.add_string b s; Buffer.add_string  b "<br/>");
@@ -195,39 +159,176 @@ let update_debug_message =
     with _ -> ()
 
 
-let loop s ppf buffer =
-  let need_terminator = ref true in
-  for i = 0 to String.length s - 2 do
-    if s.[i] = ';' && s.[i+1] = ';' then need_terminator := false;
-  done;
-  let s = if !need_terminator then s ^ ";;" else s in
-  let lb = Lexing.from_function (refill_lexbuf s (ref 0) ppf) in
-  begin try
-    while true do
-      begin
-      try
-        let phr = !Toploop.parse_toplevel_phrase lb in
-        ensure_at_bol ppf;
-        Buffer.clear buffer;
-        Tutorial.print_debug s;
-        ignore (Toploop.execute_phrase true ppf phr);
-        let res = Buffer.contents buffer in
-        Tutorial.check_step ppf s res;
-        update_lesson_text ();
-        update_lesson_number ();
-        update_lesson_step_number ();
-      with
-          End_of_file ->
-            raise End_of_file
-        | x ->
-          ensure_at_bol ppf;
-          Errors.report_error ppf x
-      end;
-      update_debug_message ();
-    done
-    with End_of_file -> ()
-  end
+(* auxiliary type and functions for `loop`, see below *)
+type 'a parse_status =
+  | Error of exn * int
+  | Success of 'a * int
+  | Need_more_input
+
+let try_parse str p =
+  let pos = ref p in
+  let len = String.length str in
+  let lb =
+    (* add a space at the end so that input ending with ';;'
+       don't raise Need_more_input *)
+    Lexing.from_function (fun output _len ->
+      if !pos = len then (incr pos; ' '; 0)
+      else begin
+        output.[0] <- str.[!pos];
+        incr pos;
+        1
+      end) in
+  try
+    let result = !Toploop.parse_toplevel_phrase lb in
+    Success (result, lb.Lexing.lex_last_pos)
+  with exn ->
+    if !pos = len + 1 then Need_more_input
+    else Error (exn, lb.Lexing.lex_last_pos)
 
+let execute_phrase phrase ppf output_buffer =
+  try
+    Buffer.clear output_buffer;
+    ignore (Toploop.execute_phrase true ppf phrase);
+    let res = Buffer.contents output_buffer in
+    Tutorial.check_step ppf s res;
+    update_lesson_text ();
+    update_lesson_number ();
+    update_lesson_step_number ();
+  with exn ->
+    Errors.report_error ppf exn
+
+let skip_whitespace s pos =
+  let rec loop i =
+    if i = String.length s then None
+    else match s.[i] with
+      | '\r' | '\n' | '\t' | ' ' -> loop (i+1)
+      | _ -> Some i in
+  loop pos
+
+let format_string pos len ppf str =
+  let last_was_r = ref false in
+  for i = pos to pos + len - 1 do
+    match str.[i] with
+      | '\r' ->
+        if !last_was_r then Format.fprintf ppf "\r";
+        last_was_r := true;
+      | c ->
+        if c = '\n' then Format.fprintf ppf "@."
+        else if !last_was_r then Format.fprintf ppf "\r";
+        Format.fprintf ppf "%c" c;
+        last_was_r := false;
+  done
+
+(* `loop` is called for each line entered in the toplevel.
+
+   In order to allow for multi-line input, we use the following
+   heuristic: if parsing the line didn't raise any syntax error, but
+   didn't succeed in parsing a complete line, we simply accumulate the
+   input into an input buffer, and wait for the next call to `loop`.
+
+   Once a syntax error is encountered, or we have succeeded in parsing
+   a whole phrase, we show the result and clear the input buffer.
+
+   For example, if the user enters "let x =", it is not a syntax
+   error, and we wait for the next line of input. If it is "1", we
+   have the complete phrase "let x = 1" which we execute in the
+   toplevel. If it is "1 in", we wait againt for the next line. Note
+   that his heuristic is imperfect: when the user writes "let x =\n
+   1\n", he may have wished to end with "in x + x", but we decide that
+   the phrase stops here.
+
+   The return value of `loop` is the rest of the input, after the last
+   phrase that could be parsed.
+
+   The code is complexified by two aspects:
+
+   - We try to be lenient in asking the user to close its phrases
+   using ';;'. She is not forced to use it, and when we see that the
+   phrase is unfinished we try to add ';;' at the end and retry
+   parsing.
+
+   - We need to print the user input to the output HTML buffer, but we
+   don't do it by batch, we try to do phrase per phrase.. For example,
+   entering "1;; 2" will not print "1;; 2", then the result of the two
+   phrases, but "# 1;;", then the result of this phrase, and "# 2;;",
+   and the result of that phrase.
+*)
+let loop =
+  let input_buffer = Buffer.create 80 in
+fun line ppf output_buffer ->
+  (* last_pos is the length of the partially entered multiline input
+     that has already been printed back to the user *)
+  let last_pos = Buffer.length input_buffer in
+  Buffer.add_string input_buffer line;
+  let input = Buffer.contents input_buffer in
+  let input_closed = input ^ ";;" in
+  let format_phrase marker str suffix pos len =
+    Format.fprintf ppf "%c %a%s@." marker
+      (format_string pos len) str suffix in
+  (* parse a phrase starting at position `pos` in the input string;
+     the first parsing attempt is handled differently below,
+     as it may be incomplete *)
+  let rec parse_next pos =
+    match skip_whitespace input pos with
+      | None -> ""
+      | Some pos ->
+        match try_parse input pos with
+          | Error (exn, offset) ->
+            let len = offset+1 in
+            format_phrase '#' input "" pos len;
+            Errors.report_error ppf exn;
+            parse_next (pos + len)
+          | Success (phrase, offset) ->
+            let len = offset+1 in
+            format_phrase '#' input "" pos len;
+            execute_phrase phrase ppf output_buffer;
+            parse_next (pos + len)
+          | Need_more_input ->
+            begin match try_parse input_closed pos with
+              | Error _ | Need_more_input ->
+                begin match skip_whitespace input pos with
+                  | None -> ""
+                  | Some i -> String.sub input i (String.length input - i)
+                end
+              | Success (phrase, _) ->
+                let len = String.length input - pos in
+                format_phrase '#' input ";;" pos len;
+                execute_phrase phrase ppf output_buffer;
+                ""
+            end
+  in
+  (* if this is not the first line of input,
+     we use '>' rather than '#' as a visual prompt marker,
+     to let the user know that she's continuing the phrase. *)
+  let marker = if last_pos = 0 then '#' else '>' in 
+  match try_parse input 0 with
+    | Error (exn, pos) ->
+      let len = pos + 1 - last_pos in
+      format_phrase marker input "" last_pos len;
+      Buffer.clear input_buffer;
+      Errors.report_error ppf exn;
+      parse_next (last_pos + len)
+    | Success (first_phrase, pos) ->
+      let len = pos + 1 - last_pos in
+      format_phrase marker input "" last_pos len;
+      Buffer.clear input_buffer;
+      execute_phrase first_phrase ppf output_buffer;
+      parse_next (last_pos + len)
+    | Need_more_input ->
+      (* if we need to close to get the phrase,
+         there are no further phrases *)
+      match try_parse input_closed 0 with
+        | Error _ | Need_more_input ->
+          let len = String.length input - last_pos in
+          format_phrase marker input "" last_pos len;
+          Buffer.add_char input_buffer '\n';
+          ""
+        | Success (phrase, _) ->
+          let len = String.length input - last_pos in
+          format_phrase marker input ";;" last_pos len;
+          Buffer.clear input_buffer;
+          execute_phrase phrase ppf output_buffer;
+          ""
 
 let _ =
   Tutorial.message_fun := (fun s ->
@@ -305,7 +406,8 @@ let run _ =
     history_bckwrd := !history;
     history_frwrd := [];
     textbox##value <- Js.string "";
-    loop s ppf buffer;
+    let remaining_input = loop s ppf buffer in
+    textbox##value <- Js.string remaining_input;
     make_code_clickable ();
     textbox##focus();
     container##scrollTop <- container##scrollHeight;
-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:00 [Caml-list] try ocaml website Fabrice Le Fessant
                   ` (3 preceding siblings ...)
  2011-12-23 18:56 ` Ashish Agarwal
@ 2011-12-26  8:50 ` Mihamina Rakotomandimby
  2011-12-26  9:05 ` Esther Baruk
  2012-01-03 22:12 ` Philippe Wang
  6 siblings, 0 replies; 24+ messages in thread
From: Mihamina Rakotomandimby @ 2011-12-26  8:50 UTC (permalink / raw)
  To: caml-list

On 12/23/2011 09:00 PM, Fabrice Le Fessant wrote:
>    We worked hard on our "Try OCaml" website, started by Çagdas, and we
> managed to improve it enough, so that we think people can start using it
> (and hopefully, improving it).
> It is available here:
> http://try.ocamlpro.com/

Very nice work.
Congratulations.

-- 
RMA.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:00 [Caml-list] try ocaml website Fabrice Le Fessant
                   ` (4 preceding siblings ...)
  2011-12-26  8:50 ` Mihamina Rakotomandimby
@ 2011-12-26  9:05 ` Esther Baruk
  2012-01-03 22:12 ` Philippe Wang
  6 siblings, 0 replies; 24+ messages in thread
From: Esther Baruk @ 2011-12-26  9:05 UTC (permalink / raw)
  To: Fabrice Le Fessant; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

Very nice work, and what a great idea !

We will definitely add a link to Try OCaml on the future OCaml Web
Portal<https://forge.ocamlcore.org/projects/ocamlweb/>website.



Esther Baruk


On Fri, Dec 23, 2011 at 7:00 PM, Fabrice Le Fessant <
Fabrice.Le_fessant@inria.fr> wrote:

> Dear ocamllers,
>
>  We worked hard on our "Try OCaml" website, started by Çagdas, and we
> managed to improve it enough, so that we think people can start using it
> (and hopefully, improving it).
>
> It is available here:
>
> http://try.ocamlpro.com/
>
>  There are 3 lessons, two lessons for "getting a taste of OCaml"
> (totalling 10 steps), and the last one about some new features in 3.12.
> You can use the "lessons()" command in the toplevel to get the current
> list of lessons (in case we contribute more in the meantime !).
>
>  We welcome any comment to improve it, bug reports, and new content.
> The repository is on Github:
>
> https://github.com/OCamlPro/tryocaml
>
>  You can easily fork it, compile it, modify it, and send us pull
> requests if you want your content published on our site.
>
> We will probably continue to focus on the first lessons (the "getting a
> taste of OCaml" virtual section), but we are also looking for
> contributions on advanced topics : we plan to make them start around
> lesson 10, and focus on particular issues (modules, functors, labels,
> objects, classes, polymorphic variants, etc.). Send us a mail if you
> want to volunteer !
>
>  As the engine is translated from OCaml to Javascript by js_of_ocaml,
> you can even play with it offline, when you are disconnected.
>
> Have fun,
> Fabrice
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>

[-- Attachment #2: Type: text/html, Size: 2789 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-26  8:09     ` Gabriel Scherer
@ 2011-12-27 20:23       ` Fabrice Le Fessant
  0 siblings, 0 replies; 24+ messages in thread
From: Fabrice Le Fessant @ 2011-12-27 20:23 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Çagdas Bozman, caml-list

[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

Hi Gabriel,

On 12/26/2011 09:09 AM, Gabriel Scherer wrote:
> I played with the toplevel a bit, but was frustrated by the limitation
> of one-liner input.
> Even in an interactive toplevel it is nice, I think, to be able to
> write multiline programs.

I uploaded a new version a few minutes ago. Now, you can use "multiline
true" to tell the toplevel that you will use ;; as an end of input
instead of the newline (and "multiline false;;" to switch back). My
patch is inspired from yours, but with minimal changes to the current code.

It works for me, but I would be happy to get feed back from "multi-line
users".

--Fabrice

[-- Attachment #2: fabrice_le_fessant.vcf --]
[-- Type: text/x-vcard, Size: 380 bytes --]

begin:vcard
fn:Fabrice LE FESSANT
n:LE FESSANT;Fabrice
org:INRIA Saclay -- Ile-de-France;P2P & OCaml
adr;quoted-printable:;;Parc Orsay Universit=C3=A9 ;Orsay CEDEX;;91893;France
email;internet:fabrice.le_fessant@inria.fr
title;quoted-printable:Charg=C3=A9 de Recherche
tel;work:+33 1 74 85 42 14
tel;fax:+33 1 74 85 42 49 
url:http://fabrice.lefessant.net/
version:2.1
end:vcard


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] try ocaml website
  2011-12-23 18:00 [Caml-list] try ocaml website Fabrice Le Fessant
                   ` (5 preceding siblings ...)
  2011-12-26  9:05 ` Esther Baruk
@ 2012-01-03 22:12 ` Philippe Wang
  6 siblings, 0 replies; 24+ messages in thread
From: Philippe Wang @ 2012-01-03 22:12 UTC (permalink / raw)
  To: Fabrice Le Fessant; +Cc: caml-list

On Fri, Dec 23, 2011 at 7:00 PM, Fabrice Le Fessant
<Fabrice.Le_fessant@inria.fr> wrote:
> Dear ocamllers,
>
>  We worked hard on our "Try OCaml" website, started by Çagdas, and we
> managed to improve it enough, so that we think people can start using it
> (and hopefully, improving it).
>
> It is available here:
>
> http://try.ocamlpro.com/

Hi,

First of all, I really like this project :)

Then, a few comments:

I believe 63-character lines are a little bit short. I'd prefer 80 (or
at least 73).
Or at least it should be resizable...

Buffer "select-all" is not available... I don't know if it is easy to
add, but if it's not, maybe it's easy to add an export feature (for
all the buffer contents to appear in a new window which can then be
saved in a txt file).

Cheers,

-- 
Philippe Wang
   mail@philippewang.info


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-01-03 22:12 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-23 18:00 [Caml-list] try ocaml website Fabrice Le Fessant
2011-12-23 18:40 ` Dominique Martinet
2011-12-23 18:49   ` Çagdas Bozman
2011-12-23 19:10     ` Dominique Martinet
2011-12-23 19:29       ` Jérémie Dimino
2011-12-23 19:39         ` Dominique Martinet
2011-12-23 21:35         ` oliver
2011-12-23 19:36       ` Adrien
2011-12-26  8:09     ` Gabriel Scherer
2011-12-27 20:23       ` Fabrice Le Fessant
2011-12-23 18:40 ` oliver
2011-12-24  8:51   ` Stéphane Glondu
2011-12-24 10:16     ` oliver
2011-12-24 10:31       ` Dominique Martinet
2011-12-23 18:54 ` Török Edwin
2011-12-23 21:27   ` oliver
2011-12-23 18:56 ` Ashish Agarwal
2011-12-23 19:15   ` Philippe Strauss
2011-12-23 21:14     ` Norman Hardy
2011-12-23 21:18       ` William Le Ferrand
2011-12-23 21:32   ` oliver
2011-12-26  8:50 ` Mihamina Rakotomandimby
2011-12-26  9:05 ` Esther Baruk
2012-01-03 22:12 ` Philippe Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).