hat is should either unify 'a and 'b, being in practice
equivalent to "type 'a t = Foo of 'a", or flag an error because 'a is not
available in this branch. I might actually prefer the unification approach,
because this conforms to the intuition that the scope
kup:"Hello" ()
Jacques Garrigue
On 2010/11/29, at 22:20, Daniel de Rauglaudre wrote:
> Hi,
>
> I'd like to have a "label" widget in Lablgtk with a string with
> internationalization, bold, italic, utf8, color, things like that.
>
> I am not su
lumsy).
The obvious alternative to lablgtk2 is of course labltk.
I personally think that labltk is still the easiest way to build a GUI,
but many do not like Tk's look&feel.
I'm not aware of other GUI toolkits for ocaml, but I think there are also
web-based UIs.
Jacques Garrigue
O
point of view, since you can use it
in place of parentheses to sequence multiple arguments)
If you want the compositionality, you can use something starting with @:
# let (@@) f x = f x;;
val ( @@ ) : ('a -> 'b) -> 'a -> 'b =
# succ @@ succ @@ succ 3;;
- : int = 6
inherit bar_t end
val do_something : #foobar_t -> bool
I agree that this is rather verbose.
I thought a few times of adding the syntax you propose, but was always
stopped by the fact you can already do it in a verbose way.
Jacques Garrigue
___
Caml-l
t * 'a t : 'b t
seems OK too.
Actually this would have the advantage of allowing the scope of existential
variables
to be explicit. I.e. one could write
App of 'a. ('a -> 'b) t * 'a t : 'b t
Jacques Garrigue
___
Cam
ricvalue_val's,
Args need not be protected. Similarly for the result, we are just returning the
result of another
function, with no risk of corruption.
When in doubt, it is always safer to use CAMLparam/CAMLreturn, eventhough they
will
generate a bit more code.
Jacques Garrigue
___
On 2010/10/09, at 2:13, Sylvain Le Gall wrote:
> Hello all,
>
> I would like to build an interface for plugins that allow to extract at the
> same time a very specific data for a plugin family and to extract
> general help for plugins.
>
> Here is an example:
[...]
> This code doesn't compile
You were looking in the wrong place.
The official lablgtk distribution is at
wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/lablgtk.html
Since 2.14.2 as just been released, and there has been no change in the trunk
since then, the daily snapshots are also ok.
Jacques
-
From: Jianzhou Zhao
Hi,
I
rse we are very careful of not breaking the formal semantics
(where there is no eta-expansion, and discarding will only occur when
the function is applied). Whenever the eta-expansion approach might
introduce a discrepancy, you will get a type error.
Jacques Garrigue
__
e.
When checking types against an interface, such conjunctive types are
not allowed. So the type checker attemps to unify all possibilities, but
since no argument is not unifiable with anything else, it fails.
Unfortunately, the error message is not very explicit about the cause.
J
Thanks for the report.
This is fixed now.
Jacques Garrigue
-
From: JérémieDimino
The link to download the tarball seems to be broken: it ends with
lablgtk-2.14.2.gz instead of lablgtk-2.14.2.tar.gz
On Fri, Sep 17, 2010 at 05:59:19PM +0900, Jacques Garrigue wrote:
> Dear Caml
, gtksourceview2.)
You can find it at:
http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/lablgtk.html
The windows release will have to wait for a windows version of ocaml
3.12...
---
Jacques Garrigue Nagoya University
r option, -no-app-funct, which disables
applicative functors, and as a result allows strengthening in more cases.
This solves your problem, but not Hendrik's, because his example
requires applicative functor to start with.
Jacques Garrigue
[Your 2 other versions]
>
> module A :
uilt assuming that there no anonymous modules.
The solution is easy enough: name all modules.
Here you just have to write:
module Unit = struct end
module C(FreshGram : functor(Unit : sig end) -> Camlp4Syntax) : Camlp4Syntax =
Printers_Ocaml_Make(FreshGram(Unit))
Hope this helps.
Jacqu
On 2010/07/22, at 18:37, rossb...@mpi-sws.org wrote:
> "Jacques Garrigue" wrote:
>>
>> module type MyModuleType(Param:ParamType) = sig ... end
>>
>> But this just doesn't make sense.
>
> Hm, I would disagree. It makes perfect sense, it just
new solution in 3.12 is to use a variant of the "with"
construct, which does exactly what you want, i.e. it turns a
signature into a "function" returning a signature.
Hope this helps,
Jacques Garrigue
___
Caml-list ma
From: Kaustuv Chaudhuri
> On Tue, Jun 8, 2010 at 4:37 PM, Jacques Garrigue
> wrote:
>> Of course intify can cause a segmentation fault!
>>
>> # let arr = Array.of_list [intify 1.0; 0];;
>> Segmentation fault
>
> This may be splitting hairs, but the reason tha
representations...
Jacques Garrigue
On Tue, Jun 8, 2010 at 8:40 PM, bluestorm wrote:
> You're right : that's true in the "int" case and I hadn't considered it.
> But if you use the same trick for ('a -> float) or other types you can get a
> segfault :
> #
thout
pattern-matching.
But I know that many people are happy with the other aproach, so I'm
not sure that it matters that much.
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinf
ethod to encoding existential types in CPS style, but
this is going to be costly and not very natural.)
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml
t tuareg mode was more stable.
I'm not going to suggest that tuareg mode switch to the ocaml-mode
code base, because I think that actually the tuareg code is cleaner.
However, for various historical reasons the two code bases are
developped in parallel, with some reasonable amount of sharing,
The windows release has not been updated at this time.
---
Jacques Garrigue Nagoya University garrigue at math.nagoya-u.ac.jp
http://www.math.nagoya-u.ac.jp/~garrigue/>
: sig
type foo = { bar : M.bar; }
class type bar = object val mutable foo : foo list end
end = M
class bar : M.bar = object val mutable foo : M.foo list = [] end
You still need to provide an explicit interface for bar.
Hope this helps,
Jacques Garrigue
___
gt; let r3 = r ts
>
> let test12 = assert (r1 = r2) (* fail => r1 ≠ r2 *)
> let test13 = assert (r1 = r3) (* fail => r1 ≠ r3 *)
>
> (* Conclusion: RHS evaluated exactly at the point of mapping application *)
Sure, this is an eager language.
Jacques Garrigue
_
hiding something.
This is not the same thing as type abbreviations, because constraints
are applied from the outside, while abbreviations just have to be
expanded.
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yq
From: Philippe Veber
> 2010/5/14 Jacques Garrigue
>
>> From: Philippe Veber
>>
>> > I'd like to define a type with a variable that is constrained to accept
>> only
>> > polymorphic variant types included in a given set of tags. That is how I
>
But it doesn't really work!
More precisely, the type [< `a | `b > `a ] t is an instance of 'a t,
not 'a t itself, an a module interface should give a type at most as
general as the implementation.
In your case, you should simply write
type t = [`a | `b]
since you don
entEdge (SmallX)
(* Build the result signature by instantiating Edge signature *)
module type EdgeX = Edge with type t := SmallX.t
(* Alternative approach, obtain the same signature from EdgeX itself *)
module type EdgeX' = module type of EdgeX
module Algorithm(EdgeX : EdgeX) = struct let d
amples, but you cannot build
polymorphic combinators.
Note. In designing a type system where you would be able to express
such "differential" types, poinder the problem: what is the type of
transform composed with itself.
Jacques Garrigue
ifferent. The range is 31-bits rather than 30-bits, and
the factor is 243, so that names of no more than 4 characters are
guaranteed to be different. You still have collisions, but they are
going to be less similar.
Both hash functions are defined in byterun/hash.c.
Hope this helps,
Jacques Garrig
s not work in ocaml. So ocaml also could profit from uniqueness
types.
Cheers,
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner'
ref (fun () -> ())
let f ctx =
r := (fun () -> chgCtx ctx)
(* later on *)
List.hd !r ()
The language is just too expressive...
You should rather look into adding a dynamic flag to your context,
causing a runtime error if you use it later.
Jacques Garrigue
__
ally want to define this type, you have to unroll it by hand:
type ('a, 'b) t = [ `A of 'a | `T of [ `A of 'b | `T of ('a,'b) t]];;
(I added an argument to `A to make the parameters meaningful.)
Jacques Garrigue
___
Caml-
map f t)
end
module IntList = struct
type elt = int
type list = Nil | Cons of elt * list
end
module IntM = F(IntList);;
IntM.map succ (IntList.Cons (1, IntList.Nil));;
Again, these two definitions of list, while representing the same data,
are incompatible.
Hope this helps.
Jacques Garrigue
able before transforming it, then
it would not be theoretically impossible to have campl4 read the
dumped types and use them for an extra pass. You would still need to
type everything once more after that for safety.
Jacques Garrigue
___
Caml-list
.
---
Jacques Garrigue Nagoya University garrigue at math.nagoya-u.ac.jp
http://www.math.nagoya-u.ac.jp/~garrigue/>JG
___
Caml-list mailing list. Subscription management:
h
First, like everybody else, I'd like very much to try this out.
Is there any chance it could compile on Snow Leopard :-)
(I suppose it's near impossible, but still ask...)
From: Jon Harrop
> Visual Basic has been a *lot* faster than OCaml for several years now, not
> least because it makes effic
x27;m not sure it
will help beginners
* adding yet another keyword is not that great...
So if find time with nothing else to do I might try with a prototype,
but don't hold your breath.
At times I even think that all class definitions should be accompanied
by a class interface, with explici
ll as a language feature. Particularly when you
think that future versions of the compiler may be able to infer more
polymorphic types, thanks to improvements in type inference, and
suddenly break your program.
Jacques Garrigue
___
Caml-list mailing lis
method type contains also class
parameters:
class ['a] cell (x : 'a) = object
method pair : 'b. 'b -> 'a * 'b = fun y -> (x,y)
end
More generally, you might end up with types more polymorphic than you
expected, and since differently instantiated polymorphic method
track of them independently of the value itself.
Since linux has no GC, using doubly linked lists has only a very
limited cost, mostly related to the extra space needed.
By the way, BSD uses lots of singly-linked lists, probably because it
comes fro
les even syntactically legal in annotations? If backwards
> compatibility is the issue, could it not at the very very least give a
> compiler warning when they are used?
Because it is useful to be able to have type annotations sharing type
variables in different places in a term (for instance for di
both are much worse than real records. But whether it
matters or not depends much on what you use them for in your program.
Jacques Garrigue
(*
To compile:
ocamlc -I +camlp4 -c -pp camlp4orf pa_polymap.ml
ocamlc -c polymap.ml
To use:
ocaml dynlink.cma camlp4o.c
;;
After the gc, x is collected.
What you are seeing is the size taken by y.
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner'
est = private < print : unit; .. >
val create : int -> test
val equal : test -> test -> bool
end = struct
class test (n : int) =
object
val x = n
method get_x = x
method print = print_int x
end
let create = new test
let equal t1 t2 = t1#get_x = t
rences of batch)
All occurences of batch inside its own definition should have the same
parameters ('a,'b), but here both have different parameters.
I admit that the error message is a bit confusing because all
parameters are variables, and their names are not preserved by the
type-chec
method x = x
method t = t
end
The above class has just two implicit fields, x and t.
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Be
ent of the OCaml get_x you propose.
You can do this with SML#
http://www.pllab.riec.tohoku.ac.jp/smlsharp/
# fun f x = #name x;
val f = fn : ['a, 'b#{name:'a}. 'b -> 'a]
# f {name = "Joe", age = 21};
val it = "Joe" : string
But the compiler is rather clever...
Jac
regular
types in type abbreviations. It only applies when the definitions are
mutually recursive, and do not go through any datatype definition.
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/m
From: Radzevich Belevich
> class [ 'c ] a =
> object(self)
> constraint 'c = < .. >
> method as_c = (self :> 'c)
> method id = Oo.id self
> end ;;
> class ['a] a :
> object ('a)
> constraint 'a = < as_c : 'a; id : int; .. >
> method as_c : 'a
g you cannot abbreviate is the {bop = ...} part, as this
is where universality is checked, to ensure that no cross application
can be done.
Jacques Garrigue
> Then what you are asking for is existential types. There is no syntax
> for them in ocaml, but they can be encoded through universal typ
x27;b base_op -> 'b}
let l =
let a = {x = 1; fn = print_int}
and b = {x = 1.2; fn = print_float} in
[{base = fun x -> x.bop a}; {base = fun x -> x.bop b}]
List.iter (fun w -> w.base {bop = fun r -> r.fn r.x}) l
As you can see, the result is rather verbose, but this wor
tializers too.
The current implementation keeps the definition order, and I don't see
why it should change, but if your code depends on such things it may
always be a good idea to put somewhere a bit of code that verifies
that the behaviour is correct.
Jacques Garrigue
y, the self coercion and the use of a non-abbreviated object
type are independent, but in general it is too heavy to use the second
without the first.
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.i
tions this way: as
> instance variable and accessible through inheritance, is there any
> workaround or suggestions ?
The simplest way I see currently is to use a let defined field (i.e.,
before the object keyword, but then you can't access it aft
] | Cp of tp] as 'b)
> where ['b/'a] represents substitution. In other words, b has one more
> constructor than a. Is a always a subtype of b?
Yes, but only if 'a appears only in covariant positions inside
t1...tn. And you will need "double coercions" (i.e. coercions
rtual base_type =
object (self)
val mutable virtual next : base_type option
method virtual set_next_base : base_type option -> unit
method as_base = (self :> base_type)
method set_next : 'a. as 'a -> unit =
fun x -> self#set_next_base x#as_base
end
T
few years ago. The idea was to provide a basis for
implementing GADTs. But since the GADT work was not finished, it was
never merged in the main trunk.
So it would be very easy to have polymorphic recursion in ocaml.
The real question is whether it is that useful in the absence of
GADTs, knowing t
=
struct
type 'a foobar_t =
[ `Foo of int
| `Bar of 'a list ]
type t = t foobar_t
let foo x = `Foo x
let bar x = `Bar x
end
Jacques Garrigue
> module M:
> sig
> type 'a foobar_t =
> [ `Foo of int
>
ef of string * 'a t list" in the definition, rather than
"Mref of string * [`Nonlink] t list" like I did. But being more
specific also means that you have more information when you unwrap an
Mref node.
Cheers,
Jacques Garrigue
_
to do it inside Node, and you keep full generality
(i.e. your make may choose to only recurse on Bold for instance...)
I hope this gives you some ideas on how to proceed.
Cheers,
Jacques Garrigue
module Node: sig
type +'a t = private
| Text of string
| Bold of 'a t list
|
From: Dario Teixeira
> I ditched the regular variants in favour of polymorphic variants, hoping
> the coercion trick described by Jacques Garrigue would help [1]. I've also
> simplified the formulation as much as possible. Anyway, I'm still stuck
> with the same problem:
[That point to the seq in List.map sprintf2 seq]. Here is where the
> potential bug is: how is string incompatible with string?
> [If this is a bug, I'll add it to the database]
The bug is in only in the error message; which seems another instance
of the problem you reported in your p
stance, it is not completely clear how one could select instances of
type classes for polymorphic variants, without introducing conflicts.
I'm afraid the combination of type classes with modules and functors
is not trivial either.
Jacques Garrigue
From: Jacques Carette
Subject: [Caml-list] Debugging the compiler
Date: Sat, 27 Dec 2008 10:24:52 -0500
> Nothing like the holidays for a little playing around with some ideas by
> modifying a compiler... Having got the hang of bootstrapping the
> compiler [with help from old caml-list posting
Note that this will not work properly if partial applications of f cause
side-effects (i.e. f is actually "fun x -> ...; fun y -> ...").
This is pretty rare, but I believe this is the case for printf for
instance.
Jacques Garrigue
_
int
> and float differs, a coercion function isn't required. The internal
> representation of [private int] and [int] is the same, not to mention
> one is exactly the [private] of the other.
This was not intended as a complete comparison :-)
However, since the coercion function is
pture it with 'a), you would have to recover it by hand.
Jacques Garrigue
> I have also been playing with 3.11's private types, and I would like to
> share a problem I've come across. Suppose I have a Foobar module defined
> as follows (note the use of a type constraint):
>
er ocaml
separates the two, and requires coercion functions whenever you want
to use an int as a float.
Cheers,
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://cam
Using labels makes this kind of code more readable.
open StdLabels
let x = List.map my_list ~f:
begin fun z ->
very_blabla
end in
...
Jacques Garrigue
From: DooMeeR <[EMAIL PROTECTED]>
> Another possibility is:
>
> let x = List.map begin fun z ->
Hi Jun,
If it's a bug, it should go to mantis... but it's not one.
From: "Jun Furuse" <[EMAIL PROTECTED]>
> I found a strange bug in 3.11.0 beta 1. The following typical example
> of phantom types does not compile any more. (It is compilable in
> 3.10.2, but not in release311):
>
> module M : si
g 7.1-BETA1.
Even unison works fine.
Note however that since 7.0 linking lablgtk programs under FreeBSD is
very slow (1mn). I know how to fix it in the ocaml compiler, but this
rather looks like a FreeBSD bug.
Cheers,
Jacques Garrigue
___
Caml-list mai
ate to create an item, but
you can use pattern-matching as usual to access its contents.
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Be
rized class type inside a recursive
definition introduces constraints on parameters.
The classical workaround is to break the recursion (when needed) by
adding more parameters. Another trick is to use recursive modules, but
this is actually more verbose, and
our object type
(which you need here, since you want to write #mappable), there are
other difficulties related to recursive types having to be regular.
A classical workaround is to define map as a function using #fold and
cons:
let map cons f (o : 'a #foldable) =
o#fold (fun x o' ->
From: Jacques Carette <[EMAIL PROTECTED]>
> Jacques Garrigue wrote:
> > The message is maybe not clear enough: for pattern-matching and
> > inheritance, you need an "exact" variant type, i.e. a type whose lower
> > and upper bounds are identical.
> Indeed
7;a = [< a | b]
> ;;
The message is maybe not clear enough: for pattern-matching and
inheritance, you need an "exact" variant type, i.e. a type whose lower
and upper bounds are identical. This is clearly not the case for
c. The standard workar
er-engineered. You shouldn't need all that many constraints.
I you could find a way to use private rows rather than private
abbreviations, your code might be much simpler.
But I'm sorry I couldn't follow the whole discussion on your problem.
I you could summarize it shortly, with the ba
From: Jacques Garrigue <[EMAIL PROTECTED]>
> This is now fixed. I just hope this does not break anything...
> It should be ok, but please report any new non-termination problem
> immediately :-)
OK, my first solution was not correct, and caused infinite loops with
type t = an
e ok, but please report any new non-termination problem
immediately :-)
Cheers,
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner
gt; int) - 1) : int :> Nat.t);; (* fails *)
I think I know the reason, which is probably related to the way
abbreviation expansions are cached, but this needs more investigating.
Jacques Garrigue
___
Caml-list mailing list. Subscription management:
From: Jeremy Yallop <[EMAIL PROTECTED]>
> Jacques Garrigue wrote:
> > From: Jeremy Yallop <[EMAIL PROTECTED]>
> >> Dario Teixeira wrote:
> >>> type ('a, 'b) t = private 'a constraint 'a = [< super_node_t ]
> >> I don
inction between private rows and private abbreviations is
syntactic. In particular
type (+'a, 'b) t = private 'a constraint 'a = [< super_node_t ]
defined a private row in 3.10, but it is a private abbreviation in 3.11
(with of course a different semantics).
If you need the pri
problem is that phantom types must be implemented in terms
> of abstract (or at least generative) types.
This is actually the other way round: abstract and private types allow
phantom types, but abbreviations and normal datatypes (generative
ones) don
uires a very complicated
type system (look at Didier Remy's papers)
Also, if you want lots of fields, this may be a good idea to use
a constraint to name parameters.
type +'a parent_data =
{str: 'str; cmt: 'cmt} constraint 'a =
The ex
e realized that the above code just uses functions to
do that same thing as functors. Functors would be syntactically nicer,
but they wouldn't let you infer the type of w, which is the whole
point. If getting data out of tuples proves to be a pain, you could
also return an immediate object.
Chee
re.ml.
As to why the name of the method matters, it may be related to the
order in which the checking is done. Since types are graphs, this ends
up being relevant (but only when there is a bug!)
Jacques Garrigue
___
Caml-list mailing list. S
o the bug tracker.
By the way you could also trigger it in the toplevel by giving
explicitly a module signature (this is what ocamlc does internally).
This is now fixed in CVS, branch release310.
Note that you may still have other kinds of problems using
upper-bounded polymorpic variants inside co
with non-generalizable types, as
it does not generate any .cmi.
* if you want to be still able to compile, you can write a .mli file
not including the witness. ocamlc -i on the .ml will still show you
the witness.
* other solution: put everything inside a function, so that the
type variab
checks changing type levels, and losing polymorphism.
In you specific case, this is the delayed check about sequences
(here you should have a warning if x has a concrete type other than
unit).
So yes, this is the fix you need to avoid the above problem, and
other loss of polymorphism related to
d be sufficient for your needs.
It is however sensitive to the data format you use (the types for your
data), and there is currently no way to verify that the type has not
changed between two versions of a program.
-----
code.
Anyway, this is the first line that matters.
You cannot change a method's type with method override.
So get_right_sibling in typ has still type [node option], which means
that in foo_typ, ['p foo_typ] should be a [node option], hence the
contradiction.
There was a type-checker bug
e "open StdLabels" there is no way to access the
original List module (except if you've first defined an alias for it
with a different name).
It has been discussed at times that putting the standard library in a
packed module would alleviate t
94 matches
Mail list logo