Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* CSL questions
@ 1995-09-25 11:01 Emmanuel Engel
  1995-09-28 15:28 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Emmanuel Engel @ 1995-09-25 11:01 UTC (permalink / raw)
  To: caml-list

I have some (naives ?) questions about csl.

1) Why cslc and cslopt don't print part of the source
to explain where is error. The configuration found the 
termlib, the toplevel (csltop) use it. It underline
error but cslc and cslopt juste write something like

(engel)newsun8 >cslc -c error.ml 
File "error.ml", line 1, characters 12-16:
This expression has type bool but is here used with type int

camllight give a better indication of the location of the error.

>camlc -c error.ml 
File "error.ml", line 1, characters 12-16:
>let v = 1 + true ;;
>            ^^^^
This expression has type bool,
but is used with type int.

2) I have some problems with higher-order module 
system. I try to define a type (camllight syntaxe)

type expr = V of int
          | Binop of expr * expr
          | A_op of expr list
          | AC_op of expr set__t;;

So I write

**************** expr.ml *********************************

module type OrderedExpr = (* Set.OrderedType with t = expr *) 
  sig 
    type expr 
    val  compare : expr -> expr -> int 
  end

module type SetExpr = (* Set.S with elt = expr *)
  sig
    type expr
    type t
    val empty : t
    val is_empty : t -> bool
    val mem : expr -> t -> bool
    val add : expr -> t -> t
    val remove : expr -> t -> t
    val union : t -> t -> t
    val inter : t -> t -> t
    val diff : t -> t -> t
    val compare : t -> t -> int
    val equal : t -> t -> bool
    val iter : (expr -> 'a) -> t -> unit
    val fold : (expr -> 'a -> 'a) -> t -> 'a -> 'a
    val cardinal : t -> int
    val elements : t -> expr list
    val choose : t -> expr
  end

module OrderedExpr =
struct
  type expr = V of int
            | Binop of expr * expr
            | A_op of expr list
            | AC_op of SetExpr.t 

  let compare = compare
end

module SetExpr:SetExpr = Set.Make((OrderedExpr:OrderedExpr))

*************************************************************

If i try to compile this I have 

>cslc -c -i expr.ml
File "expr.ml", line 21, characters 23-37:
Unbound type constructor SetExpr.t

How can I recursivly define modules ? I need SetExpr to define
the type expr and I need the type expr to define SetExpr.

3) If I suppress the case AC_op in my definition I still have some problems.

>cslc -c -i expr.ml
File "expr.ml", line 47, characters 34-60:
Signature mismatch:
Modules do not match: OrderedExpr is not included in Set.OrderedType
The field `t' is required but not provided

So I try to use the "with" constuct

My first try was not good

module SetExpr:SetExpr = 
  Set.Make(((OrderedExpr:OrderedExpr):Set.OrderedType with t=OrderedExpr.expr))

>cslc -c -i expr.ml
File "expr.ml", line 48, characters 35-60:
Signature mismatch:
Modules do not match:
  OrderedExpr
is not included in
  sig type t = OrderedExpr.expr val compare : t -> t -> int end
The field `t' is required but not provided

The second one too

module SetExpr:SetExpr = 
   Set.Make((OrderedExpr:Set.OrderedType with t=OrderedExpr.expr))

>cslc -c -i expr.ml
File "expr.ml", line 52, characters 35-46:
Signature mismatch:
Modules do not match:
  sig
    type expr = V of int | Binop of expr * expr | A_op of expr list
    val compare : expr -> expr -> int
  end
is not included in
  sig type t = OrderedExpr.expr val compare : t -> t -> int end
The field `t' is required but not provided



Emmanuel Engel








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

end of thread, other threads:[~1995-09-29  8:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-09-25 11:01 CSL questions Emmanuel Engel
1995-09-28 15:28 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox