caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] What does this mean?
@ 2004-04-13  4:26 skaller
  2004-04-13 14:00 ` skaller
  0 siblings, 1 reply; 6+ messages in thread
From: skaller @ 2004-04-13  4:26 UTC (permalink / raw)
  To: caml-list

Can someone explain what this means .. 

Invalid_argument("equal: abstract value")

The code is below. I am fairly sure the problem
occurs in 'assoc' trying to compare two terms
for equality.

This piece of code unravels a Felix expression term
into a three-address-code, the equality comparison
is used to eliminate common subexpressions.

let unravel syms e =
  let sube = ref [] in
  let get e = 
    try assoc e !sube 
    with Not_found ->
      let n = !(syms.counter) in incr (syms.counter);
      let name = "_tmp" ^ si n in
      sube := (e,name) :: !sube;
      name
  in
  let refer ((_,t) as e) = 
    `BEXPR_expr (get e,t),t
  in
  let idt t = t in
  let e' = 
    let rec aux e = 
      match e with
      | `BEXPR_apply ((`BEXPR_name _,_) as f, b),t
      | `BEXPR_apply ((`BEXPR_closure _,_) as f, b),t ->
        `BEXPR_apply (f, aux b),t
      | `BEXPR_apply (f,b),t -> `BEXPR_apply(aux f, aux b),t
      | `BEXPR_tuple ls,t -> `BEXPR_tuple (map aux ls),t
      | (`BEXPR_name _,t) as x -> x
      | x -> refer x
    in 
      aux e
 in !sube,e

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] What does this mean?
  2004-04-13  4:26 [Caml-list] What does this mean? skaller
@ 2004-04-13 14:00 ` skaller
  0 siblings, 0 replies; 6+ messages in thread
From: skaller @ 2004-04-13 14:00 UTC (permalink / raw)
  To: skaller; +Cc: caml-list

On Tue, 2004-04-13 at 14:26, skaller wrote:
> Can someone explain what this means .. 
> 
> Invalid_argument("equal: abstract value")

Argg! Found it! Hmmm. My representation
of literals is the problem:

and literal_t =
  [
  | `AST_int of string * big_int
  | `AST_string of string
  | `AST_cstring of string
  | `AST_wstring of string
  | `AST_ustring of string
  | `AST_float of string * string
  ]

where you see 'big_int' is an abstract type.
I'm lucky, I can fix this easily,
'List.assoc' is easy to rewrite :D

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] what does this mean?
       [not found]   ` <3CBC7B46.9EB83B57@sage.att.com>
@ 2002-04-17  9:18     ` Nicolas barnier
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas barnier @ 2002-04-17  9:18 UTC (permalink / raw)
  To: Garry Hodgson; +Cc: ocaml

Garry Hodgson wrote:
> 
> no, i hadn't thought of that.  works fine now.  thanks!

After thinking about it, I figured out a better explanation for
this restriction. Suppose you have the following code:

let h = Hashtbl.create 10

module M = (struct
  type t = A
  let _ = Hashtbl.add h 0 A
end : sig end)

let t = Hashtbl.get h 0

then type t would be visible outside M, whereas module M,
restricted by its signature, does not export it. I think this
is the meaning of the error message: "The type constructor t
would escape its scope". So it rather is a safe restriction.

Regards

-- Nicolas
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] what does this mean?
  2002-04-16 18:06 ` Eric C. Cooper
@ 2002-04-16 19:26   ` Garry Hodgson
  0 siblings, 0 replies; 6+ messages in thread
From: Garry Hodgson @ 2002-04-16 19:26 UTC (permalink / raw)
  To: ocaml

"Eric C. Cooper" wrote:
> 
> On Tue, Apr 16, 2002 at 01:28:23PM -0400, Garry Hodgson wrote:
> >
> > i'm getting en error message i don't understand in the following code
> > fragment.  foo.ml is:
> >
> > let regions = Hashtbl.create 64
> >
> > type region = { name:string; coords:(int*int*int*int); countries:string
> > list }
> >
> > let addRegion name0 coords0 ccs =
> >       let r = { name=name0; coords=coords0; countries=ccs } in
> >       Hashtbl.add regions name0 r
> >
> > when i comp[ile, i get:
> >
> > $ ocamlc foo.ml
> > File "foo.ml", line 9, characters 13-20:
> > This expression has type ('a, 'b) Hashtbl.t but is here used with type
> >   (string, region) Hashtbl.t
> > The type constructor region would escape its scope
> >
> > can someone explain what this means, and perhaps how to resolve it?
> > thanks
> 
> The problem is that you create the regions hash table before defining
> the region type.  Just move the type definition to the top, before
> creating any data structures that might use it.

that was it.  my thanks, to you and the others who pointed this out in
email.

-- 
Garry Hodgson                   Let my inspiration flow
Senior Hacker                      in token rhyme suggesting rhythm
Software Innovation Services    that will not forsake me
AT&T Labs                          'til my tale is told and done.
garry@sage.att.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] what does this mean?
  2002-04-16 17:28 [Caml-list] what " Garry Hodgson
@ 2002-04-16 18:06 ` Eric C. Cooper
  2002-04-16 19:26   ` Garry Hodgson
       [not found] ` <3CBC64F8.B677F621@recherche.enac.fr>
  1 sibling, 1 reply; 6+ messages in thread
From: Eric C. Cooper @ 2002-04-16 18:06 UTC (permalink / raw)
  To: ocaml

On Tue, Apr 16, 2002 at 01:28:23PM -0400, Garry Hodgson wrote:
> 
> i'm getting en error message i don't understand in the following code
> fragment.  foo.ml is:
> 
> let regions = Hashtbl.create 64
> 
> type region = { name:string; coords:(int*int*int*int); countries:string
> list }
> 
> let addRegion name0 coords0 ccs =
> 	let r = { name=name0; coords=coords0; countries=ccs } in
> 	Hashtbl.add regions name0 r
> 
> when i comp[ile, i get:
> 
> $ ocamlc foo.ml
> File "foo.ml", line 9, characters 13-20:
> This expression has type ('a, 'b) Hashtbl.t but is here used with type
>   (string, region) Hashtbl.t
> The type constructor region would escape its scope
> 
> can someone explain what this means, and perhaps how to resolve it?
> thanks

The problem is that you create the regions hash table before defining
the region type.  Just move the type definition to the top, before
creating any data structures that might use it.

-- 
Eric C. Cooper          e c c @ c m u . e d u
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] what does this mean?
@ 2002-04-16 17:28 Garry Hodgson
  2002-04-16 18:06 ` Eric C. Cooper
       [not found] ` <3CBC64F8.B677F621@recherche.enac.fr>
  0 siblings, 2 replies; 6+ messages in thread
From: Garry Hodgson @ 2002-04-16 17:28 UTC (permalink / raw)
  To: ocaml


i'm getting en error message i don't understand in the following code
fragment.  foo.ml is:

let regions = Hashtbl.create 64

type location = { name:string; mutable nodes:string list }
type region = { name:string; coords:(int*int*int*int); countries:string
list }

let addRegion name0 coords0 ccs =
	let r = { name=name0; coords=coords0; countries=ccs } in
	Hashtbl.add regions name0 r


when i comp[ile, i get:

$ ocamlc foo.ml
File "foo.ml", line 9, characters 13-20:
This expression has type ('a, 'b) Hashtbl.t but is here used with type
  (string, region) Hashtbl.t
The type constructor region would escape its scope

can someone explain what this means, and perhaps how to resolve it?
thanks

-- 
Garry Hodgson                   Let my inspiration flow
Senior Hacker                      in token rhyme suggesting rhythm
Software Innovation Services    that will not forsake me
AT&T Labs                          'til my tale is told and done.
garry@sage.att.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2004-04-13 14:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-13  4:26 [Caml-list] What does this mean? skaller
2004-04-13 14:00 ` skaller
  -- strict thread matches above, loose matches on Subject: below --
2002-04-16 17:28 [Caml-list] what " Garry Hodgson
2002-04-16 18:06 ` Eric C. Cooper
2002-04-16 19:26   ` Garry Hodgson
     [not found] ` <3CBC64F8.B677F621@recherche.enac.fr>
     [not found]   ` <3CBC7B46.9EB83B57@sage.att.com>
2002-04-17  9:18     ` Nicolas barnier

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