From: Emmanuel.Engel@lri.fr (Emmanuel Engel)
To: caml-list@pauillac.inria.fr
Subject: CSL questions
Date: Mon, 25 Sep 1995 12:01:55 +0100 [thread overview]
Message-ID: <199509251101.MAA00575@newsun8.lri.fr> (raw)
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
next reply other threads:[~1995-09-28 8:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-09-25 11:01 Emmanuel Engel [this message]
1995-09-28 15:28 ` Xavier Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199509251101.MAA00575@newsun8.lri.fr \
--to=emmanuel.engel@lri.fr \
--cc=caml-list@pauillac.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox