caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Unbound type constructor
@ 2007-04-25 20:21 snowfall
  2007-04-26  3:03 ` [Caml-list] " skaller
  0 siblings, 1 reply; 11+ messages in thread
From: snowfall @ 2007-04-25 20:21 UTC (permalink / raw)
  To: caml-list


Hi.

I am developing a compiler for a language. I have done the parser, the lexer
and the ast. But when I execute the command ocamlc -c parser.mli is shown
the error "unbound type constructor abacus_ast.progr".

Here is the code of the AST:

open Lexing

type ident = string
;;

...

type progr= ident * (tipo list) * (declaracao_de_variaveis list) * (funcoes
list) * (instrucao list)
;;

and in the parser I put:
% type < Abacus_ast.progr > programa

Can anyone tell me what I am doing wrong? 

Best regards
-- 
View this message in context: http://www.nabble.com/Unbound-type-constructor-tf3647847.html#a10188741
Sent from the Caml Discuss2 mailing list archive at Nabble.com.


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

* Re: [Caml-list] Unbound type constructor
  2007-04-25 20:21 Unbound type constructor snowfall
@ 2007-04-26  3:03 ` skaller
  0 siblings, 0 replies; 11+ messages in thread
From: skaller @ 2007-04-26  3:03 UTC (permalink / raw)
  To: snowfall; +Cc: caml-list

On Wed, 2007-04-25 at 13:21 -0700, snowfall wrote:
> Hi.
> 
> I am developing a compiler for a language. I have done the parser, the lexer
> and the ast. But when I execute the command ocamlc -c parser.mli is shown
> the error "unbound type constructor abacus_ast.progr".

> 
> and in the parser I put:
> % type < Abacus_ast.progr > programa
> 
> Can anyone tell me what I am doing wrong? 

yep .. you have to do

ocamlc -c abacus_ast.mli

first. If A depends on B, you must compile B before you
compile A. This applies to all files whether ml or mli
files.  x.ml depends on x.mli if it exists.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


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

* Re: Unbound type constructor
  2001-02-07 21:34       ` Pierre Weis
@ 2001-02-08  7:36         ` Sven
  0 siblings, 0 replies; 11+ messages in thread
From: Sven @ 2001-02-08  7:36 UTC (permalink / raw)
  To: Pierre Weis; +Cc: leary, caml-list

On Wed, Feb 07, 2001 at 10:34:54PM +0100, Pierre Weis wrote:
> > If the list management is/can be centralized, why not have 2 or 3 people doing the moderation?  
> > 
> > On Tue, Feb 06, 2001 at 05:35:02PM +0100, Pierre Weis wrote:
> > > If this treatment of the list is considered harmful and not
> > > desirable, we can turn the list into some other mode, maybe a
> > > completely free (non-moderated) mode ...
> 
> Good idea. Any volunteers to write or install the necessary software,
> and also volunteers to manage the list ?

Regarding spams and such, ...

The best idea to have an open list without to much spam is to :

  * limit posting to subscribers only.

  * review posts of non-subscribers, thus limiting spam.

  * Step in if a flamewar errupts, and try to halt it.

This would need a moderator, but would heighten the list troughput, and also lower the work done by the moderator.

BTW, does INRIA not have a mailing list manager or something such ?

Friendly,

Sven Luther



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

* Re: Unbound type constructor
  2001-02-06 22:39     ` leary
@ 2001-02-07 21:34       ` Pierre Weis
  2001-02-08  7:36         ` Sven
  0 siblings, 1 reply; 11+ messages in thread
From: Pierre Weis @ 2001-02-07 21:34 UTC (permalink / raw)
  To: leary; +Cc: caml-list

> If the list management is/can be centralized, why not have 2 or 3 people doing the moderation?  
> 
> On Tue, Feb 06, 2001 at 05:35:02PM +0100, Pierre Weis wrote:
> > If this treatment of the list is considered harmful and not
> > desirable, we can turn the list into some other mode, maybe a
> > completely free (non-moderated) mode ...

Good idea. Any volunteers to write or install the necessary software,
and also volunteers to manage the list ?

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/




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

* Re: Unbound type constructor
  2001-02-06 16:35   ` Pierre Weis
@ 2001-02-06 22:39     ` leary
  2001-02-07 21:34       ` Pierre Weis
  0 siblings, 1 reply; 11+ messages in thread
From: leary @ 2001-02-06 22:39 UTC (permalink / raw)
  To: Pierre Weis; +Cc: Stephan Tolksdorf, caml-list

If the list management is/can be centralized, why not have 2 or 3 people doing the moderation?  

On Tue, Feb 06, 2001 at 05:35:02PM +0100, Pierre Weis wrote:
> If this treatment of the list is considered harmful and not
> desirable, we can turn the list into some other mode, maybe a
> completely free (non-moderated) mode ...
> 



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

* Re: Unbound type constructor
  2001-02-05 18:58 ` Stephan Tolksdorf
@ 2001-02-06 16:35   ` Pierre Weis
  2001-02-06 22:39     ` leary
  0 siblings, 1 reply; 11+ messages in thread
From: Pierre Weis @ 2001-02-06 16:35 UTC (permalink / raw)
  To: Stephan Tolksdorf; +Cc: caml-list

> Maybe this topic should be added to the faq?

Yes I should do it.

> Stephan Tolksdorf
> 
> PS: Is it me or is the time a mail needs to get finally delivered when
> it is posted via the list rather slow?

No it is not you, it's me as well as for the FAQ entry: I'm the
moderator of the Caml list, and that's my fault if messages are not
bounced instantly to all the Caml list's subscribers!

In fact I bufferize them, since I read all the posts before sending
them to the list (this is partly to prevent spamming and partly to
prevent flame wars on the list) and this needs some time; also, I get
tired sometimes and go to bed and thus stop bouncing messages to the
list; even worse, in some occasions, I may attend a conference such as
POPL and be away from the list for days!  Also, I'm suppose to do some
work for INRIA other than managing this Caml list (e.g. attending
meetings, writing O'Caml examples, articles, programs, etc); that's
why I generally treat the mail from the list only once or twice a
day. If this treatment of the list is considered harmful and not
desirable, we can turn the list into some other mode, maybe a
completely free (non-moderated) mode ...

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/




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

* Re: Unbound type constructor
       [not found] <Pine.BSF.4.21.0102050903120.28934-100000@shell5.ba.best.com>
@ 2001-02-05 18:58 ` Stephan Tolksdorf
  2001-02-06 16:35   ` Pierre Weis
  0 siblings, 1 reply; 11+ messages in thread
From: Stephan Tolksdorf @ 2001-02-05 18:58 UTC (permalink / raw)
  To: Brian Rogoff; +Cc: caml-list

> If you check the recent Caml list archives under the title "circular
> types" (I think!) you'll find lots of discussion of the parameterization
> trick and other approaches. 

I've just found the thread in the archives. I've searched for it
before but I obviously had difficulties to find the right keywords.

Maybe this topic should be added to the faq?

Stephan Tolksdorf


PS: Is it me or is the time a mail needs to get finally delivered when
it is posted via the list rather slow?




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

* Re: Unbound type constructor
  2001-02-03 17:16 Stephan Tolksdorf
  2001-02-04 22:23 ` Brian Rogoff
  2001-02-05  2:21 ` Jacques Garrigue
@ 2001-02-05 17:30 ` John Max Skaller
  2 siblings, 0 replies; 11+ messages in thread
From: John Max Skaller @ 2001-02-05 17:30 UTC (permalink / raw)
  To: Stephan Tolksdorf; +Cc: caml-list

Stephan Tolksdorf wrote:

> PS: Naive question, why aren't there type members in OCaml classes?

	Because the primary unit of modularity in Ocaml is the module.
In many OO languages, it is the class, and one is forced to squeeze
all sorts of things into classes that don't belong there. 

-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net



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

* Re: Unbound type constructor
  2001-02-03 17:16 Stephan Tolksdorf
  2001-02-04 22:23 ` Brian Rogoff
@ 2001-02-05  2:21 ` Jacques Garrigue
  2001-02-05 17:30 ` John Max Skaller
  2 siblings, 0 replies; 11+ messages in thread
From: Jacques Garrigue @ 2001-02-05  2:21 UTC (permalink / raw)
  To: andorxor; +Cc: caml-list

> I'm learning OCaml...
> 
> The following code snippet fails due to an "unbound type constructor"
> error. How could I achieve the intended result in OCaml?
> 
> type combination = T1 of int | T2 of test | T3 of test * test
> 
> class test =
>       object
>             method virtual get : combination
>       end

Since you cannot have mutual recursion between a type definition and a
class definition, you have to use parameterization. In this case this
is very easy, but this can get heavier when you have lots of mutually
recursive types.

type 'a combination = T1 of int | T2 of 'a | T3 of 'a * 'a

class virtual test =
  object
    method virtual get : test combination
  end

> PS: Naive question, why aren't there type members in OCaml classes?

Because classes are not modules...
The technical explanation is rather complex, but you can just think
about the fact class types are just object types, and the compiler
should be able to infer object types without type annotations. In
general you cannot infer type members.

Jacques Garrigue



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

* Re: Unbound type constructor
  2001-02-03 17:16 Stephan Tolksdorf
@ 2001-02-04 22:23 ` Brian Rogoff
  2001-02-05  2:21 ` Jacques Garrigue
  2001-02-05 17:30 ` John Max Skaller
  2 siblings, 0 replies; 11+ messages in thread
From: Brian Rogoff @ 2001-02-04 22:23 UTC (permalink / raw)
  To: Stephan Tolksdorf; +Cc: caml-list

On Sat, 3 Feb 2001, Stephan Tolksdorf wrote:

> I'm learning OCaml...
> 
> The following code snippet fails due to an "unbound type constructor"
> error. How could I achieve the intended result in OCaml?
> 
> type combination = T1 of int | T2 of test | T3 of test * test
> 
> class test =
>       object
>             method virtual get : combination
>       end

The problem is that cuurrently you can't have classes and types in a
mutually recursive declaration, and you can't even have "class types" in 
such declarations, but you can put "object types" (see the OCaml manual 
under Type Expressions) in and then use object types to constrain the 
return value of method get. 

# type combination = T1 of int | T2 of test | T3 of test * test
  and test = <get : combination>;;
type combination = T1 of int | T2 of test | T3 of test * test
type test = < get : combination >
# class my_test = object(self) method get = T2 (self:>test) end;;  
class my_test : object method get : combination end

There are probably other ways to do what you want too.

-- Brian




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

* Unbound type constructor
@ 2001-02-03 17:16 Stephan Tolksdorf
  2001-02-04 22:23 ` Brian Rogoff
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Stephan Tolksdorf @ 2001-02-03 17:16 UTC (permalink / raw)
  To: caml-list

I'm learning OCaml...

The following code snippet fails due to an "unbound type constructor"
error. How could I achieve the intended result in OCaml?

type combination = T1 of int | T2 of test | T3 of test * test

class test =
      object
            method virtual get : combination
      end


PS: Naive question, why aren't there type members in OCaml classes?

Stephan Tolksdof




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

end of thread, other threads:[~2007-04-26  3:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-25 20:21 Unbound type constructor snowfall
2007-04-26  3:03 ` [Caml-list] " skaller
     [not found] <Pine.BSF.4.21.0102050903120.28934-100000@shell5.ba.best.com>
2001-02-05 18:58 ` Stephan Tolksdorf
2001-02-06 16:35   ` Pierre Weis
2001-02-06 22:39     ` leary
2001-02-07 21:34       ` Pierre Weis
2001-02-08  7:36         ` Sven
  -- strict thread matches above, loose matches on Subject: below --
2001-02-03 17:16 Stephan Tolksdorf
2001-02-04 22:23 ` Brian Rogoff
2001-02-05  2:21 ` Jacques Garrigue
2001-02-05 17:30 ` John Max Skaller

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