<mrvn>
gildor: it is possible but you might have to jump through some hoops.
<mrvn>
ODBPkgVer.t isn't a 'e
adlsaks has joined #ocaml
ankit9 has joined #ocaml
<flux>
gildor, the problem is that one type cannot match 'for all' types
<flux>
gildor, maybe you can preserve the polymorphicity in the interface?
<mrvn>
or make it a ['a] class.
<flux>
given the function prototype I don't think it's what he wants..
larhat has quit [*.net *.split]
adrien_ has quit [*.net *.split]
Tianon has quit [*.net *.split]
cthuluh has quit [*.net *.split]
<gildor>
['a] class won't work, because with_file_in should return either ODBPkgVer.t or ODBPkg.t
<gildor>
and 'a will become one or the other ASA I use the class
<mrvn>
and that can't be decided when you create the class?
<gildor>
flux: I already did the 'a. stuff that enable polymorphicity
<gildor>
but the type unification beginning by guessing the object type and try to merge it with existing
<mrvn>
gildor: you might have to lift some variables to get the 'a back
<gildor>
mrvn: no, this is a FS that contains files which contains the two datastructure
larhat has joined #ocaml
adrien_ has joined #ocaml
Tianon has joined #ocaml
cthuluh has joined #ocaml
<gildor>
mrvn, flux: I am now in the process of moving the 'a method outside of the class
<mrvn>
The question is why it sees (Lwt_io.input_channel -> ODBPkgVer.t Lwt.t) instead of (Lwt_io.input_channel -> 'a Lwt.t) there
<gildor>
mrvn: type unification, the original method (from std_ro class) is 'a
<gildor>
the more I use object in ocaml, the less I like them
myu2 has joined #ocaml
<mrvn>
they do have some strange quirks with the type system.
<mrvn>
But doing inheritance with records is also a big pain.
<mrvn>
(or dirty)
<gildor>
mrvn: indeed, I am not using object just for fun, I need them because in my case, they are useful
<larhat>
mrvn: btw, could i give me some links to read about "inheritance with records". i'd like to see that
<gildor>
mrvn: I will inherit a git filesystem and a "cache" filesystem
Oejet has quit [Quit: Leaving.]
<mrvn>
larhat: quick and dirty you can do stuff like: type base = { x:int; } type foo = { x:int; y:int; } let as_base (foo:foo) = ((Obj.magic foo):base)
oriba has joined #ocaml
<larhat>
oh, Obj.magic
<gildor>
no Obj.magic !!!
<gildor>
verboten
<gildor>
;-)
<gildor>
BTW, look like a C trick
<mrvn>
you can do without Obj.magic more with 'a. 'a -> ... syntax and using 2 records in combination to hide internal types but it gets realy complex. There are some posts about universal types on the ML.
ftrvxmtrx has quit [Ping timeout: 276 seconds]
<mrvn>
type ['a] base = { x;int; more:'a; } type foo = int base ... types work too.
ftrvxmtrx has joined #ocaml
<mrvn>
with inheritance chains you then quickly get x.more.yetmore.stillmore.z
<larhat>
i'm now reading about 3.12 features and about its applications (all hail to oleg! :-) ) . what do you think of it http://paste.in.ua/2061/ ?
<flux>
gildor, when dealing with polymorphic methods, it's useful to annotate function arguments/return values that return such objects. are you doing that?
<mrvn>
larhat: that module stuff will probably help with replacing objects in many cases too.
<mrvn>
.oO(When will 3.12 be in Debian?)
<larhat>
mrvn: yes, i'm choosing exactly between modules and objects
<larhat>
module stuff looks too heavy, i think :-(
<rproust>
larhat: for the particular "Show" example, the "deriving" (and "deeriving-ocsigen" branch) syntax extension is really handy
<rproust>
that's only for this particular use
<rproust>
gildor: flux is right, it is often usefull to add type information along with the method
<mrvn>
When I get such an error I allways annotate types till I find the place that causes the error.
<rproust>
it duplicates (and sometimes triplicates) type information in the sourcce…
<mrvn>
Once the problem is fixed you can remove them again
oriba has quit [Quit: Verlassend]
<flux>
mrvn, I do the same ;)
Yoric has joined #ocaml
<mrvn>
Sometimes I wish for an interactive type inference. Show me the source with the infered types and for every expression let me pick&choose the type and rerun the inferecne.
<flux>
hmm, idea. I could hack annotator (the tool that inlines type information into source files per .annot information) into supporting emacs such that I could mark a region and it would annotate only that region..
<rproust>
mrvn: sounds like a great IDE thingy
<flux>
although I guess most of the time your source wouldn't be in compiling order anyway, unless you put in some asserts
<flux>
mrvn, you're aware of the emacs and vi type throwback feature?
<flux>
(that works with the .annot files)
<mrvn>
flux: + select an expression and then alter the type, e.g. inference shows 'a foo bar and you change it to 'a t and rerun
<flux>
mrvn, well, you would be able to do that because it would just put the types into your code
<flux>
so you could change it and recompile
Yoric has quit [Read error: Connection reset by peer]
<flux>
but the trick is that you need to be able to compile it (atleast up to certain point)
Yoric has joined #ocaml
<mrvn>
flux: yeah. that put into the code should be temporary and the compile automatic.
<mrvn>
flux: I don't worry about types until I have something that should compile.
<mrvn>
What would also often help is that the type inference should start with the bits I told it and then tell me where else it doesn't match. I.e. the place where the type is actully wrong instead of where the type inference runs into a wall.
<flux>
one thing I've though of would be allowing compilation of programs that have type errors, but change the type error parts to "assert false"
<gildor>
flux, rproust: yes argument are annotated
<gildor>
mrvn: there is a pending request to debian-release to start the OCaml 3.12 transition in Debian
<gildor>
mrvn: no news so far
<mrvn>
gildor: yeah. I was just wishing they would.
<mrvn>
they could just upload it to experimental.
<gildor>
mrvn: sgnb has created an external repository with 3.12 packages
ikaros has quit [Quit: Leave the magic to Houdini]
rgrig has joined #ocaml
sepp2k has joined #ocaml
coucou747 has joined #ocaml
<philed`>
flux: Is there anything like F#'s intellisense type-inference for Ocaml?
<flux>
philed`, I doubt that, as ocaml type inference works only for complete programs (although I'm not familiar with F#'s intellisense)
philed` is now known as philed
<philed>
It's pretty tasty. You can be half-way through writing a function definition, put the mouse over an identifier, and it will tell you the type it has currently inferred for it, even if the larger expression is incomplete.
<philed>
David Matthews was in our dept for a bit recently, and he and another guy hacked up something even better in Poly/ML where you could highlight whole subexpressions and get the inferred type at that point.
<flux>
well, you can do that after compilation
<flux>
in emacs I can prses C-c C-t and get the type of any expression (or subexpression)
<flux>
it's quite useful indeed
<flux>
it requires the compiler to generate the type information with -dtypes, but unfortunately the inference process stops once there is an error
<larhat>
afaik, intellisense built in studio, which used its own algorithm for intellisense, and don't use compiler information. so it cannot be used with different extensions (see http://tomasp.net/blog/fsharp-variations-joinads.aspx )
<flux>
the partial .annot file is stil there
<flux>
there should be a ocaml compiler daemon that could be fed new code and it could resume compilation from any given point and produce annotate AST out :)
<flux>
it could store the state of compliation into continuations, so it wouldn't need to recompile everything alwyas
<flux>
it would need to compile everything after a point, though..
<mrvn>
flux: compiling a file is so fast it hardly matters that you restart at the top
<philed>
The thing is, is that I sometimes lose track of typing while I'm writing a function, so it's nice to have something that can do the inference live.
<flux>
mrvn, sort of true I guess
<flux>
philed, sometimes I do that by inserting 'assert false' and the compiler will infer the type for me
<mrvn>
flux: I frequently use (* FIXME *) assert false;
<mrvn>
or (* FIXME *) dummy-type
<mrvn>
let fixme () = if true throw FIXME; Obj.magic 0 ??
<mrvn>
seen something like that somewhere in the past
coucou747 has quit [Ping timeout: 252 seconds]
<flux>
why not simply throw FIXME?-o
<mrvn>
don't ask me
coucou747 has joined #ocaml
Cyanure has quit [Read error: Operation timed out]
npouillard has quit [Read error: Operation timed out]
npouillard has joined #ocaml
Cyanure has joined #ocaml
sgnb has quit [Read error: Operation timed out]
eye-scuzzy has quit [Read error: Operation timed out]
jld has quit [Read error: Operation timed out]
sgnb has joined #ocaml
jld has joined #ocaml
eye-scuzzy has joined #ocaml
rossberg has quit [Read error: Operation timed out]
rossberg has joined #ocaml
Tobu_ has quit [Read error: Operation timed out]
Tobu has joined #ocaml
SEcki has joined #ocaml
vivanov has joined #ocaml
ikaros has joined #ocaml
dnolen has joined #ocaml
adlsaks has quit [Ping timeout: 260 seconds]
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
flux has quit [Read error: Connection reset by peer]
flux has joined #ocaml
larhat has quit [Read error: Connection reset by peer]
larhat has joined #ocaml
Znudzon has joined #ocaml
Poet_ has joined #ocaml
Znudzon has quit [Ping timeout: 264 seconds]
dnolen has quit [Quit: dnolen]
emmanuelux has joined #ocaml
<gildor>
question to object specialist
<thelema>
gildor: are you still having problems with polymorphic methods?
<gildor>
I have a type 'a t = { fs: 'a }
<gildor>
and I want to say that fs can be either std_ro or std_rw
<gildor>
knowing that std_rw inherit std_ro
<gildor>
how could i say that
thelema_ has joined #ocaml
<gildor>
thelema: no I just move the polymorphic method out of the class, works better
<thelema_>
ah, good. An explicit annotation would also fix the problem
<thelema_>
(probably)
<gildor>
thelema: I add a quick look to other people code (like ocamlnet) and found no common use of polymorphic method for classes
<gildor>
thelema: and I understand why, it seems very tricky to get them working
<thelema_>
yup.
* gildor
thinks that type inference stops at the door of OO
<thelema_>
pretty close. Type inference within objects seems a totally different beast than normal
<thelema_>
and the types of ocaml objects are just horrendous.
thelema has quit [Ping timeout: 276 seconds]
<thelema_>
mixing them with functors? one would go insane
thelema_ is now known as thelema
<gildor>
would prefer to stay away from this kind of frankenstein
<gildor>
(frankenstein = a mix of dead bodies bring back to life)
<thelema>
yes
<gildor>
maybe will found an answer in lablgtk
<thelema>
gildor: can I get some clarification on your question?
<thelema>
The 'a t = {fs : 'a} -- when you get the value from the fs field, what do you want to do with it?
<thelema>
you want it to be an object and to call methods on it?
<gildor>
fs should be an object of at least "class std_ro"
<thelema>
well, you can't do anything to that object that you couldn't do to a std_ro, so why not just have it be exactly that type and cast other objects into that type?
<thelema>
or because you want to keep the 'a polymorphic so sometimes you can use more than that type?
<gildor>
thelema: there are some operation that will require it to be a std_rw object
<thelema>
will it ever be required to be more than a std_rw object?
<gildor>
i.e. fs#file_exists need only std_ro bu fs#open_out need std_rw
<gildor>
no, either std_ro or std_rw, other object will be casted to one of this type
<thelema>
so why can't you leave it polymorphic, and let the type system infer the right object types needed?
<adrien>
mixing objects and functors didn't seem to work very well when I tried it :P
<gildor>
gildor: file_exists is a method of std_ro
coucou747 has quit [Ping timeout: 250 seconds]
Cyanure has quit [Remote host closed the connection]
lopex has quit []
<thelema>
gildor: it looks to me like "exists" is the method of std_ro, and the function it's being used in is "file_exists"
Cyanure has joined #ocaml
joewilliams_away is now known as joewilliams
<gildor>
thelema: indeed, there was an error, I corrected it
<gildor>
(damn to the type displayed by ocamlc error)
<thelema>
I still don't see why ocaml can't specialize 'a t to the correct type
<hcarty>
rrenaud: rlwrap is a nice alternative to ledit, and the Lwt library comes with a custom toplevel which performs context-appropriate tab completion.
<gildor>
thelema: that is mainly a matter of being able to express it in .mli, the .ml should work fine
Obfuscate has quit [Quit: A poorly written script will replace me shortly.]
Obfuscate has joined #ocaml
ttamttam has quit [Remote host closed the connection]
ulfdoz has joined #ocaml
Yoric has joined #ocaml
alexyk has joined #ocaml
vivanov has quit [Quit: Lost terminal]
<alexyk>
thelema: how can I create an enum from a single value? Use case: E.append (L.enum [myVal]) prevEnum...
<thelema>
E.singleton?
<alexyk>
aha!
<thelema>
val singleton : 'a -> 'a t
<thelema>
Create an enumeration consisting in exactly one element.
<alexyk>
I also had a bug or caveat where File.lines_of had to be forced
<alexyk>
I worked it in Enum.iter later, and nothing happened until I cloned the enum to inspect it
<alexyk>
cloning had the effect of forcing
<alexyk>
and just forcing fixed thr problem
daver_ has joined #ocaml
<thelema>
odd. It has worked for me many times without forcing
<thelema>
I wonder if the file was disappearing or something
<thelema>
Maybe it's sufficient to peek at the first value?
<alexyk>
thelema: the file is in place fince
<alexyk>
fine
<alexyk>
or, rather, I force an Enum.map result from FIle.lines_of
<daver_>
noob ocaml sdl question: i've installed the system ocaml dev stuff from the ubuntu 10 repos; what's the correct command line, without using a magic makefile, to compile the first example on this page: http://wiki.njh.eu/OCaml_and_SDL
<thelema>
is the same.
<daver_>
it's almost: "ocamlopt -o test -I /usr/lib/ocaml/sdl -cclib -lsdlstub -cclib -lSDL test.ml" but not quite