caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Cygwin ocaml crashes
@ 2001-04-23 10:05 wester
  2001-04-23 13:49 ` Alan Schmitt
  0 siblings, 1 reply; 15+ messages in thread
From: wester @ 2001-04-23 10:05 UTC (permalink / raw)
  To: caml-list

Hi,

I downloaded the CYGWIN version of OCaml301 and started the
toplevel in Emacs. But when using an undefined value (what occasionally 
happens) the program crashes. See below the Emacs output of ocaml:

        Objective Caml version 3.01

# 1+2;;
- : int = 3
# let f x = x*x;;
val f : int -> int = <fun>
# f 3;;
- : int = 9
# g 3;;
      0 [main] ocaml 129 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
  47809 [main] ocaml 129 stackdump: Dumping stack trace to ocamlrun.exe.stackdump

Process caml-toplevel exited abnormally with code 232192

Is it possible to avoid this?

Rolf Wester
-------------------------------------
Rolf Wester
wester@ilt.fhg.de
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Cygwin ocaml crashes
  2001-04-23 10:05 [Caml-list] Cygwin ocaml crashes wester
@ 2001-04-23 13:49 ` Alan Schmitt
  2001-04-23 14:16   ` wester
  0 siblings, 1 reply; 15+ messages in thread
From: Alan Schmitt @ 2001-04-23 13:49 UTC (permalink / raw)
  To: wester; +Cc: caml-list

Hi,

I also had this problem (using the toplevel in cygwin, not emacs), and
solved it by getting a more recent version of cygwin.

Alan Schmitt

>Hi,
>
>I downloaded the CYGWIN version of OCaml301 and started the
>toplevel in Emacs. But when using an undefined value (what occasionally 
>happens) the program crashes. See below the Emacs output of ocaml:
>
>        Objective Caml version 3.01
>
># 1+2;;
>- : int = 3
># let f x = x*x;;
>val f : int -> int = <fun>
># f 3;;
>- : int = 9
># g 3;;
>      0 [main] ocaml 129 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
>  47809 [main] ocaml 129 stackdump: Dumping stack trace to ocamlrun.exe.stackdump
>
>Process caml-toplevel exited abnormally with code 232192
>
>Is it possible to avoid this?
>
>Rolf Wester

--
The hacker: someone who figured things out and made something cool happen.
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Cygwin ocaml crashes
  2001-04-23 13:49 ` Alan Schmitt
@ 2001-04-23 14:16   ` wester
  2001-04-23 15:39     ` Alan Schmitt
  2001-04-23 15:59     ` Mattias Waldau
  0 siblings, 2 replies; 15+ messages in thread
From: wester @ 2001-04-23 14:16 UTC (permalink / raw)
  To: caml-list

Hi Alan,

thanks  for your reply. The toplevel also chrashes when I use it directly. 
I downloaded and installed the latest  cygwin version. But the toplevel 
still chrashes when using an undefined symbol.

Rolf Wester

> Hi,
> 
> I also had this problem (using the toplevel in cygwin, not emacs), and
> solved it by getting a more recent version of cygwin.
> 
> Alan Schmitt
> 
> >Hi,
> >
> >I downloaded the CYGWIN version of OCaml301 and started the
> >toplevel in Emacs. But when using an undefined value (what occasionally
> >happens) the program crashes. See below the Emacs output of ocaml:
> >
> >        Objective Caml version 3.01
> >
> ># 1+2;;
> >- : int = 3
> ># let f x = x*x;;
> >val f : int -> int = <fun>
> ># f 3;;
> >- : int = 9
> ># g 3;;
> >      0 [main] ocaml 129 handle_exceptions: Exception:
> >      STATUS_ACCESS_VIOLATION
> >  47809 [main] ocaml 129 stackdump: Dumping stack trace to
> >  ocamlrun.exe.stackdump
> >
> >Process caml-toplevel exited abnormally with code 232192
> >
> >Is it possible to avoid this?
> >
> >Rolf Wester
> 
> --
> The hacker: someone who figured things out and made something cool happen.
> 


-------------------------------------
Rolf Wester
wester@ilt.fhg.de
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re:  [Caml-list] Cygwin ocaml crashes
  2001-04-23 14:16   ` wester
@ 2001-04-23 15:39     ` Alan Schmitt
  2001-04-23 15:59     ` Mattias Waldau
  1 sibling, 0 replies; 15+ messages in thread
From: Alan Schmitt @ 2001-04-23 15:39 UTC (permalink / raw)
  To: wester; +Cc: caml, caml-list

Hi again,

It seems there is something that does not work anymore. I also get a:

    0 [main] ocaml 225 handle_exceptions: Exceptions: STATUS_ACCESS_VIOLATION
31220 [main] ocaml 225 stackdump: Dumping stack trace to ocamlrun.exe.stackdump
Segmentation fault (core dumped)

Any kind of error will do that (parsing, typing ...)

I'm using current cvs version of ocaml, and latest cygwin (1.1.8) on winNT.

Alan Schmitt

>Hi Alan,
>
>thanks  for your reply. The toplevel also chrashes when I use it directly. 
>I downloaded and installed the latest  cygwin version. But the toplevel 
>still chrashes when using an undefined symbol.
>
>Rolf Wester

--
The hacker: someone who figured things out and made something cool happen.
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* RE: [Caml-list] Cygwin ocaml crashes
  2001-04-23 14:16   ` wester
  2001-04-23 15:39     ` Alan Schmitt
@ 2001-04-23 15:59     ` Mattias Waldau
  2001-04-24  7:00       ` wester
  1 sibling, 1 reply; 15+ messages in thread
From: Mattias Waldau @ 2001-04-23 15:59 UTC (permalink / raw)
  To: wester, caml-list

I also get it, essentially the toplevel always crashed when you
get some kind of type-error or undefined. Note below that the
function 'g' isn't defined.

I run the latest cygwin (since it is so easy to update, just run
setup.exe again and it updates the necessary parts).

I didn't get that kind of behaviour using the pre 3.01 cygwin-versions.
Maybe the error isn't that you need the latest cygwin,
but the same cygwin that was used to build ocaml. (I used the
binary installs.)

You could try to download the source and recompile it locally.

/mattias

-----Original Message-----
From: owner-caml-list@pauillac.inria.fr
[mailto:owner-caml-list@pauillac.inria.fr]On Behalf Of wester@ilt.fhg.de
Sent: Monday, April 23, 2001 4:16 PM
To: caml-list@inria.fr
Subject: Re: [Caml-list] Cygwin ocaml crashes


Hi Alan,

thanks  for your reply. The toplevel also chrashes when I use it directly.
I downloaded and installed the latest  cygwin version. But the toplevel
still chrashes when using an undefined symbol.

Rolf Wester

> Hi,
>
> I also had this problem (using the toplevel in cygwin, not emacs), and
> solved it by getting a more recent version of cygwin.
>
> Alan Schmitt
>
> >Hi,
> >
> >I downloaded the CYGWIN version of OCaml301 and started the
> >toplevel in Emacs. But when using an undefined value (what occasionally
> >happens) the program crashes. See below the Emacs output of ocaml:
> >
> >        Objective Caml version 3.01
> >
> ># 1+2;;
> >- : int = 3
> ># let f x = x*x;;
> >val f : int -> int = <fun>
> ># f 3;;
> >- : int = 9
> ># g 3;;
> >      0 [main] ocaml 129 handle_exceptions: Exception:
> >      STATUS_ACCESS_VIOLATION
> >  47809 [main] ocaml 129 stackdump: Dumping stack trace to
> >  ocamlrun.exe.stackdump
> >
> >Process caml-toplevel exited abnormally with code 232192
> >
> >Is it possible to avoid this?
> >
> >Rolf Wester
>
> --
> The hacker: someone who figured things out and made something cool happen.
>


-------------------------------------
Rolf Wester
wester@ilt.fhg.de
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives:
http://caml.inria.fr

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* RE: [Caml-list] Cygwin ocaml crashes
  2001-04-23 15:59     ` Mattias Waldau
@ 2001-04-24  7:00       ` wester
  2001-04-24  7:44         ` Alan Schmitt
  0 siblings, 1 reply; 15+ messages in thread
From: wester @ 2001-04-24  7:00 UTC (permalink / raw)
  To: caml-list

Hi,

I rebuilt Ocaml with the latest Cygwin version and now it works.

Rolf 
 
> I also get it, essentially the toplevel always crashed when you
> get some kind of type-error or undefined. Note below that the
> function 'g' isn't defined.
> 
> I run the latest cygwin (since it is so easy to update, just run
> setup.exe again and it updates the necessary parts).
> 
> I didn't get that kind of behaviour using the pre 3.01 cygwin-versions.
> Maybe the error isn't that you need the latest cygwin, but the same cygwin
> that was used to build ocaml. (I used the binary installs.)
> 
> You could try to download the source and recompile it locally.
> 
> /mattias
> 
> -----Original Message-----
> From: owner-caml-list@pauillac.inria.fr
> [mailto:owner-caml-list@pauillac.inria.fr]On Behalf Of wester@ilt.fhg.de
> Sent: Monday, April 23, 2001 4:16 PM To: caml-list@inria.fr Subject: Re:
> [Caml-list] Cygwin ocaml crashes
> 
> 
> Hi Alan,
> 
> thanks  for your reply. The toplevel also chrashes when I use it directly.
> I downloaded and installed the latest  cygwin version. But the toplevel
> still chrashes when using an undefined symbol.
> 
> Rolf Wester
> 
> > Hi,
> >
> > I also had this problem (using the toplevel in cygwin, not emacs), and
> > solved it by getting a more recent version of cygwin.
> >
> > Alan Schmitt
> >
> > >Hi,
> > >
> > >I downloaded the CYGWIN version of OCaml301 and started the
> > >toplevel in Emacs. But when using an undefined value (what occasionally
> > >happens) the program crashes. See below the Emacs output of ocaml:
> > >
> > >        Objective Caml version 3.01
> > >
> > ># 1+2;;
> > >- : int = 3
> > ># let f x = x*x;;
> > >val f : int -> int = <fun>
> > ># f 3;;
> > >- : int = 9
> > ># g 3;;
> > >      0 [main] ocaml 129 handle_exceptions: Exception:
> > >      STATUS_ACCESS_VIOLATION
> > >  47809 [main] ocaml 129 stackdump: Dumping stack trace to
> > >  ocamlrun.exe.stackdump
> > >
> > >Process caml-toplevel exited abnormally with code 232192
> > >
> > >Is it possible to avoid this?
> > >
> > >Rolf Wester
> >
> > --
> > The hacker: someone who figured things out and made something cool
> > happen.
> >
> 
> 
> -------------------------------------
> Rolf Wester
> wester@ilt.fhg.de
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr.  Archives:
> http://caml.inria.fr
> 


-------------------------------------
Rolf Wester
wester@ilt.fhg.de
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re:  [Caml-list] Cygwin ocaml crashes
  2001-04-24  7:00       ` wester
@ 2001-04-24  7:44         ` Alan Schmitt
  2001-04-24 20:52           ` Mattias Waldau
  2001-04-25 10:02           ` [Caml-list] Cygwin ocaml crashes Christophe Macabiau
  0 siblings, 2 replies; 15+ messages in thread
From: Alan Schmitt @ 2001-04-24  7:44 UTC (permalink / raw)
  To: wester; +Cc: caml-list

Hi,

I guess I went too fast sending my message yesterday. I had rebuilt a
cvs Ocaml on a couple months old cygwin and it did not work. Then I
got a new cygwin and it still did not work. This morning I rebuilt
Ocaml on the new cygwin and it does work.

Alan

>Hi,
>
>I rebuilt Ocaml with the latest Cygwin version and now it works.
>
>Rolf 
> 

--
The hacker: someone who figured things out and made something cool happen.
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* RE: [Caml-list] Cygwin ocaml crashes
  2001-04-24  7:44         ` Alan Schmitt
@ 2001-04-24 20:52           ` Mattias Waldau
  2001-04-25  3:17             ` [Caml-list] Subtypes in Ocaml Mark Wotton hons2001
  2001-04-25 10:02           ` [Caml-list] Cygwin ocaml crashes Christophe Macabiau
  1 sibling, 1 reply; 15+ messages in thread
From: Mattias Waldau @ 2001-04-24 20:52 UTC (permalink / raw)
  To: Alan Schmitt, wester; +Cc: caml-list

Yes, downloading and rebuilding helps. The below, before and after:

BEFORE (cygwin-binary downloaded from www.ocaml.org):

data$ ocaml.exe
        Objective Caml version 3.01

# fdas
  ;;
      0 [main] ocaml 1604 handle_exceptions: Exception:
STATUS_ACCESS_VIOLATION
  80086 [main] ocaml 1604 stackdump: Dumping stack trace to
ocamlrun.exe.stackdump
bash: [1516: 1] tcsetattr: Not a character device
Segmentation fault (core dumped)

AFTER (source downloaded and compiled locally using very up-to-date cygwin):

data$ ocaml.exe
        Objective Caml version 3.01

# fdas
  ;;
Characters 0-4:
Unbound value fdas
# #quit;;
data$

-----Original Message-----
From: owner-caml-list@pauillac.inria.fr
[mailto:owner-caml-list@pauillac.inria.fr]On Behalf Of Alan Schmitt
Sent: Tuesday, April 24, 2001 9:45 AM
To: wester@ilt.fhg.de
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Cygwin ocaml crashes


Hi,

I guess I went too fast sending my message yesterday. I had rebuilt a
cvs Ocaml on a couple months old cygwin and it did not work. Then I
got a new cygwin and it still did not work. This morning I rebuilt
Ocaml on the new cygwin and it does work.

Alan

>Hi,
>
>I rebuilt Ocaml with the latest Cygwin version and now it works.
>
>Rolf
>

--
The hacker: someone who figured things out and made something cool happen.
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives:
http://caml.inria.fr

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* [Caml-list] Subtypes in Ocaml
  2001-04-24 20:52           ` Mattias Waldau
@ 2001-04-25  3:17             ` Mark Wotton hons2001
  2001-04-25  5:45               ` Mark Wotton hons2001
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Wotton hons2001 @ 2001-04-25  3:17 UTC (permalink / raw)
  Cc: caml-list

How do you do subtypes in Ocaml? I'm writing a parser in which I want
literals to be treated as expressions, but I also want to be able to treat
them as literals in other contexts; ie, I need to be able to ensure that
I'm being passed a literal at one point (for case statements), but I don't
want to have to treat literals specially when they're being used somewhere
in which a normal expression is allowable.

This may be a stupid question, but I can't find an answer I can understand
in the docs.

mrak


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Subtypes in Ocaml
  2001-04-25  3:17             ` [Caml-list] Subtypes in Ocaml Mark Wotton hons2001
@ 2001-04-25  5:45               ` Mark Wotton hons2001
  2001-04-25  7:35                 ` Chris Hecker
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Wotton hons2001 @ 2001-04-25  5:45 UTC (permalink / raw)
  To: caml-list

On Wed, 25 Apr 2001, Mark Wotton hons2001 wrote:

> How do you do subtypes in Ocaml? I'm writing a parser in which I want
> literals to be treated as expressions, but I also want to be able to treat
> them as literals in other contexts; ie, I need to be able to ensure that
> I'm being passed a literal at one point (for case statements), but I don't
> want to have to treat literals specially when they're being used somewhere
> in which a normal expression is allowable.
> 
> This may be a stupid question, but I can't find an answer I can understand
> in the docs.

Patternmatching seems to do it. if this isn't the right way to do it,
please, someone let me know before i do something stupid.

mrak


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Subtypes in Ocaml
  2001-04-25  5:45               ` Mark Wotton hons2001
@ 2001-04-25  7:35                 ` Chris Hecker
  2001-04-25  7:42                   ` Mark Wotton hons2001
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Hecker @ 2001-04-25  7:35 UTC (permalink / raw)
  To: Mark Wotton hons2001, caml-list


>Patternmatching seems to do it. if this isn't the right way to do it,
>please, someone let me know before i do something stupid.

I'm not 100% sure what you're saying.  My first interpretation of your question leads me to say "this is what variants and pattern matching are all about".  Since a variant is a union type, it can be a Literal and just an expression and pattern matching will let you choose which to interpret it as.

My second interpretation is that you want to have a function typed to only take a subset of the variant type.  In this case, you can either use exceptions (the default pattern match one, or one raised with a | _ -> failwith "bad type" if you don't want the compiler warnings), or I think you can do something with polymorphic variants, but I must admit to being kind of confused by them.

Chris

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Subtypes in Ocaml
  2001-04-25  7:35                 ` Chris Hecker
@ 2001-04-25  7:42                   ` Mark Wotton hons2001
  2001-04-25 11:04                     ` Jean-Francois Monin
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Wotton hons2001 @ 2001-04-25  7:42 UTC (permalink / raw)
  To: caml-list

On Wed, 25 Apr 2001, Chris Hecker wrote:

> 
> >Patternmatching seems to do it. if this isn't the right way to do it,
> >please, someone let me know before i do something stupid.
> 
> I'm not 100% sure what you're saying.  My first interpretation of your
> question leads me to say "this is what variants and pattern matching
> are all about".  Since a variant is a union type, it can be a Literal
> and just an expression and pattern matching will let you choose which
> to interpret it as.

Yes, that was it.

I had a suspicion it was a dumb question... i'm just not used to using
pattern-matching like that. It's working nicely now.

> My second interpretation is that you want to have a function typed to
> only take a subset of the variant type.  In this case, you can either
> use exceptions (the default pattern match one, or one raised with a |
> _ -> failwith "bad type" if you don't want the compiler warnings), 

Yes, I want this too.
Pattern matching seems to do it nicely. I was doing without it and
wondering why everything was so hard...

> or I think you can do something with polymorphic variants, but I must
> admit to being kind of confused by them.

I might wait until i'm a hardcore ocaml hacker, then.
Might be a while.

mrak


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Cygwin ocaml crashes
  2001-04-24  7:44         ` Alan Schmitt
  2001-04-24 20:52           ` Mattias Waldau
@ 2001-04-25 10:02           ` Christophe Macabiau
  1 sibling, 0 replies; 15+ messages in thread
From: Christophe Macabiau @ 2001-04-25 10:02 UTC (permalink / raw)
  Cc: caml-list

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

Alan Schmitt wrote:

> Hi,
>
> I guess I went too fast sending my message yesterday. I had rebuilt a
> cvs Ocaml on a couple months old cygwin and it did not work. Then I
> got a new cygwin and it still did not work. This morning I rebuilt
> Ocaml on the new cygwin and it does work.
>
> Alan
>
> >Hi,
> >
> >I rebuilt Ocaml with the latest Cygwin version and now it works.
> >
> >Rolf
> >
>
> --
> The hacker: someone who figured things out and made something cool happen.
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr

Hi,

I have the same problem (segmentation fault, STATUS_ACCESS_VIOLATION) using labltk;
I compiled ocaml 3.01 on the new cygwin 1.1.8-2. I don't have the problem of
undefined function, this works well :

$ ocaml.exe
        Objective Caml version 3.01
# fdas
  ;;
Characters 0-4:
Unbound value fdas
#quit;;
$

but when I use labltk (see the file ihm2.ml), the program crashs when I try to
erase the canvas.

Christophe

[-- Attachment #2: ihm2.ml --]
[-- Type: text/plain, Size: 1942 bytes --]

open Tk

(***********************************)
(* Pour la creation de l'interface *)
(***********************************)
let button_create ?(relief=`Raised) owner name  =
  Button.create ~relief ~text:name owner

and frame_create owner =
  Frame.create ~relief:`Groove ~borderwidth:2 owner

and menubutton_create owner name =
  Menubutton.create ~text:name owner 

(**************************************)
(* Creation d'un item texte du canvas *)
(**************************************)
let texte_create canvas (name,x,y) =
  ignore(Canvas.create_text ~x:x ~y:y ~fill:`Red ~text:name canvas)

(*******************************************)
(* Creation du canvas, creation des items  *)
(**&****************************************)
let new_def top name =
  let wgt = Toplevel.create top in
  Wm.title_set wgt name;
  let frm = Frame.create wgt in
  let cvs = Canvas.create frm in
  pack ~expand:true ~fill:`Both [cvs];
  pack ~expand:true ~fill:`Both [frm];
  let ref =[("Texte0",20,20);("Texte1",60,60);("Texte2",90,90)] in
  List.iter ~f:(function r -> texte_create cvs r) ref;

  let b = Button.create ~text:"erase" ~command:(function _ -> Canvas.delete cvs (Canvas.find cvs ~specs:[`All])) wgt in
  pack ~side:`Bottom [b]


let win = openTk();;

(******************************************)
(* Le menu...                             *)
(* Start : fonctionnement normal          *)
(* Start_Pb : probleme                    *)
(******************************************)
let start () =
  new_def win "essai" in

let quit () =
  closeTk();
  exit 0 in

let menu_bar = frame_create win in
let menu_button = menubutton_create menu_bar "Menu" in
let menu = Menu.create ~tearoff:false menu_button in
Menu.add_command ~label:"Start" ~command:start menu;
Menu.add_command ~label:"Quit" ~command:quit menu;
Menubutton.configure ~menu:menu menu_button;
pack ~side:`Top ~fill:`X [menu_bar]; 
pack ~side:`Left ~fill:`Y [menu_button]; 

mainLoop()

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

* Re: [Caml-list] Subtypes in Ocaml
  2001-04-25  7:42                   ` Mark Wotton hons2001
@ 2001-04-25 11:04                     ` Jean-Francois Monin
  0 siblings, 0 replies; 15+ messages in thread
From: Jean-Francois Monin @ 2001-04-25 11:04 UTC (permalink / raw)
  To: Mark Wotton hons2001; +Cc: caml-list

> I might wait until i'm a hardcore ocaml hacker, then.
> Might be a while.

Unless you have a special reason to think with subtypes, my advice
would be to change a little your way of seeing things. Basic notions of
Ocaml like sum (now called variant) types are clean, simple and very
good for describing syntactic trees and parsers. See sec 1.4 of the
manual (Records and variants).

A typical example is given in sec 1.7 (Symbolic processing of
expressions). I lost your original message, may be you want something
like:

type expression =
  | Lit of litteral
  | Sum of expression * expression
  | Diff of expression * expression
  | Prod of expression * expression
  | Quot of expression * expression

type litteral =
  | Const of float
  | Var of string

You can convert a litteral l into an expression using Lit(l). 
Conversely, if you have an expression e which shoud come
from a litteral, use pattern matching, e.g. 

let lit_of_exp e = 
  match e with
  | Lit(l) -> l
  | _ -> failwith "expression should come from a litteral"
  end


In some contexts you may also consider:

type expression =
  | Sum of expression * term
  | Diff of expression * term
  | Term of term

and term =
  | Lit of litteral
  | Prod of term * litteral
  | Quot of term * litteral
  | Parentexp of expression

and litteral =
  | Const of float
  | Var of string

  Jean-Francois Monin

-----------------------------------------------------------------------
Mark Wotton hons2001 wrote:
 > On Wed, 25 Apr 2001, Chris Hecker wrote:
 > 
 > > 
 > > >Patternmatching seems to do it. if this isn't the right way to do it,
 > > >please, someone let me know before i do something stupid.
 > > 
 > > I'm not 100% sure what you're saying.  My first interpretation of your
 > > question leads me to say "this is what variants and pattern matching
 > > are all about".  Since a variant is a union type, it can be a Literal
 > > and just an expression and pattern matching will let you choose which
 > > to interpret it as.
 > 
 > Yes, that was it.
 > 
 > I had a suspicion it was a dumb question... i'm just not used to using
 > pattern-matching like that. It's working nicely now.
 > 
 > > My second interpretation is that you want to have a function typed to
 > > only take a subset of the variant type.  In this case, you can either
 > > use exceptions (the default pattern match one, or one raised with a |
 > > _ -> failwith "bad type" if you don't want the compiler warnings), 
 > 
 > Yes, I want this too.
 > Pattern matching seems to do it nicely. I was doing without it and
 > wondering why everything was so hard...
 > 
 > > or I think you can do something with polymorphic variants, but I must
 > > admit to being kind of confused by them.
 > 
 > I might wait until i'm a hardcore ocaml hacker, then.
 > Might be a while.
 > 
 > mrak
 > 
 > 
 > -------------------
 > To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* RE: [Caml-list] Cygwin ocaml crashes
@ 2001-04-23 16:49 Dave Berry
  0 siblings, 0 replies; 15+ messages in thread
From: Dave Berry @ 2001-04-23 16:49 UTC (permalink / raw)
  To: Mattias Waldau, wester, caml-list

My experience of Cygwin, when working at Harlequin, is that it was very
flakey.  New versions would fix earlier bugs but introduce new ones, and
versions would be incompatible.  I was rather hoping that this would have
improved by now.  We ended up keeping a known working version stored
locally, and always using that, if necessary patching it ourselves.
Fortunately this was all for internal tools, and we never had to worry about
distributing them.

Is it possible for INRIA to distribute the exact version of Cygwin needed
for OCaml?  I remember Cygwin having fairly nasty licensing restrictions.


-----Original Message-----
From: Mattias Waldau [mailto:mattias.waldau@abc.se]
Sent: Monday, April 23, 2001 16:59

I didn't get that kind of behaviour using the pre 3.01 cygwin-versions.
Maybe the error isn't that you need the latest cygwin,
but the same cygwin that was used to build ocaml. (I used the
binary installs.)

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

end of thread, other threads:[~2001-04-25 11:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-23 10:05 [Caml-list] Cygwin ocaml crashes wester
2001-04-23 13:49 ` Alan Schmitt
2001-04-23 14:16   ` wester
2001-04-23 15:39     ` Alan Schmitt
2001-04-23 15:59     ` Mattias Waldau
2001-04-24  7:00       ` wester
2001-04-24  7:44         ` Alan Schmitt
2001-04-24 20:52           ` Mattias Waldau
2001-04-25  3:17             ` [Caml-list] Subtypes in Ocaml Mark Wotton hons2001
2001-04-25  5:45               ` Mark Wotton hons2001
2001-04-25  7:35                 ` Chris Hecker
2001-04-25  7:42                   ` Mark Wotton hons2001
2001-04-25 11:04                     ` Jean-Francois Monin
2001-04-25 10:02           ` [Caml-list] Cygwin ocaml crashes Christophe Macabiau
2001-04-23 16:49 Dave Berry

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).