<bluestorm>
once you stripped away all the comments
<bluestorm>
you've got a short and clear code
<cheatersrealm>
true
<kig>
is there a nice command line parsing lib that returns an ordered_hash or somesuch?
<bluestorm>
ordered_hash ?
<kig>
well, the data structure i'm thinking of would provide a way to iterate the parsed command line by order of appearance and by flag
<flux>
kig, this is not what you're looking for, but have you taken a look at the Arg-module?
darinm has joined #ocaml
<kig>
i mean, sometimes you want "convert -scale 400x400 foo.jpg -scale 100x100 foo_sm.jpg" mean a different thing from "convert -scale 400x400 -scale 100x100 foo.jpg foo_sm.jpg", but usually you just want to get the values to each flag and the filenames
<kig>
flux: yes, that's why i'm asking :)
<flux>
kig, how would the "ordere hash" be used? I'm thinking it would be quite difficult, if you have names associated with arguments, but they still have an order..
<flux>
it usually goes either way: either you don't care about the location, or you handle the switches in the order as they appear
<flux>
I think Arg is suitable for both kinds of uses
<flux>
it does however always go it in the proper order though.. and I'm not exactly happy with its imperative interface
<kig>
Cmdline.get_at parsed_cmdline i -> (flag_name * array_of_values)
<kig>
er, (flag_name * value)
<flux>
also as the number of command line arguments is usually small, you don't even need an advanced data structure here.. (key * value) list should do
<kig>
yep, it's just a matter of the interface
<kig>
(started writing a simple clone of unix userland to learn ocaml)
<kig>
cat (no cmdline flags) is: open Utils;; let _ = piping_command (output_channel stdout) (atail Sys.argv)
hsuh has joined #ocaml
Yoric[DT] has joined #ocaml
<AxleLonghorn>
bluestorm: am I looking for the Eclipse SDK?
<bluestorm>
i don't know, sorry
<bluestorm>
i don't use eclipse
<AxleLonghorn>
haha
<AxleLonghorn>
ok
<bluestorm>
emacs + tuareg is quite good for ocaml development
<AxleLonghorn>
I've never used eclipse either
<bluestorm>
(and there are good vim bindings too, if you are that kind of people)
darinm has quit []
<AxleLonghorn>
thanks for the help though
<bluestorm>
if you have no additional constraints, i'd advise you to try the emacs/vim mode before going the elephant route
pango has joined #ocaml
<Yoric[DT]>
emacs+tuareg is nice
<bluestorm>
Yoric[DT]: concerning the exception thing
<Yoric[DT]>
Yeah ?
<bluestorm>
i have the feeling that there was not enough experimentations in the polymorphic variants direction
* Yoric[DT]
hasn't seen a "hm" so maybe there's nothing to be afraid of.
<Yoric[DT]>
Frankly ?
<bluestorm>
most ocaml coders dismissed it as a bit "complicated"
<Yoric[DT]>
Me too, but I have the feeling that the missing experience on polymorphic variants is still years away.
<bluestorm>
in my case, i see this as as "complicated" feature of OCaml because it's advanced, i have never really used it, and it look a bit tricky
<Yoric[DT]>
(with or without polymorphic variants)
<Yoric[DT]>
I've used it a bit to encode Peano's arithmetics in OCaml.
<Yoric[DT]>
And a few times to provide error reporting, too.
<Yoric[DT]>
And I was actually quite satisfied with them at the time.
<Yoric[DT]>
Oh, and for phantom types a few times.
<bluestorm>
in the exception case
<Yoric[DT]>
But I still believe that I'm not experienced enough to use them daily (as I would if they were necessary for *every* error-handling).
<bluestorm>
it seems to me that they could be used to provide "light" exception specification in each function
<bluestorm>
something like var find : ('a -> bool) -> 'a list -> [ `Found of 'a | `Not_found ]
<bluestorm>
(may not be the real syntax, though, but i think i've seen something like that)
<bluestorm>
wich is quite nice compared to the need of a supplementary ADT declaration in most cases
<Yoric[DT]>
Let's be clear on something: my first reflex when it came to exceptionless error-handling was tu use polymorphic variants.
<bluestorm>
:p
<Yoric[DT]>
Then the remarks regarding the use of polymorphic variants *as they are inferred by the compiler* + wildcards made me think twice about it.
<bluestorm>
anyway this is a side question, as i guess the main ideas in your proposition could cope well with polymorphic variants
<Yoric[DT]>
Indeed.
<Yoric[DT]>
Well, perhaps not completely.
<bluestorm>
in the context of interface-defined functions with closed polymorphic types, i'm not sure the inference problem is that much of a problem
<bluestorm>
(but again i don't know those polymorphic variants enough)
<Yoric[DT]>
-> [ `Found of 'a | `Not_found ] is much more lightweight than -> may_fail stuff.
<Yoric[DT]>
And this may_fail, in turn, is necessary for monadic error management.
<Yoric[DT]>
So if you want to write something like this, I guess this would be "take 3".
<Yoric[DT]>
bluestorm: my problem there, is that usually, if you trust OCaml to generate your .mli, it gives you the right result. You may want something more specific, but it's usually the right result.
<Yoric[DT]>
If you need to close polymorphic types yourself, well, it's not the right result anymore.
ttamttam has left #ocaml []
<bluestorm>
as this specification is intended for interface-careful developpers, i'm not sure this is a real problem
<Yoric[DT]>
Is it ?
ita has joined #ocaml
<bluestorm>
i guess by the time a proposal is accepted, we'll have a rule-them-all decentralized VCS for every OCaml project out there, wich a nice standardized building framework, and free ice creams, and then it will just be a matter of "darcs push ... -p the-right-interface" :-'
<bluestorm>
s/wich/with/
Snrrrub has quit [Read error: 110 (Connection timed out)]
thelema|away is now known as thelema
hsuh has quit [Remote closed the connection]
Demitar has joined #ocaml
AxleLonghorn has left #ocaml []
ttamttam has joined #ocaml
ttamttam has left #ocaml []
<Yoric[DT]>
bluestorm: :)
<Yoric[DT]>
Hopefully, it will be much faster.
<bla>
Hm. What's the simpliest way to force a type of let expression?
<bla>
I've seen here some nice approach once. But can't figure it out.
<bla>
I'm looking where I've done a mistake so the type is wrongly inferred.
<bla>
Ok, found mistake... /me was using mod_float as infix operator. Which inferred argument type to something taking mod_float as argument... Hm. ;-)
<bla>
Nevertheless - is there a clean method? Or just placing in module and writting sig?
<thelema>
bla: you can't really force a type for anything. What you can do is narrow a more general type to something more specific.
<thelema>
ex: let f x y : float -> float -> int = x > y
Snark has quit ["Ex-Chat"]
Snrrrub has joined #ocaml
<bla>
thelema, thanks.
<thelema>
if you try to force a type that doesn't fit, the type checker will error your program out
<bluestorm>
thelema:
<bluestorm>
iirc it's let f (x : float) (y : float) : bool = x > y
<bluestorm>
in your example, float -> float -> int would be the return type of the function
<thermoplyae>
it's true, compare is the one that returns ints
ygrek has quit [Remote closed the connection]
<bluestorm>
but even let compare x y : int -> int -> int = x - y wouldn't work
<pango>
let f : float -> float -> bool = fun x y -> x > y is correct, though
jonathanv has joined #ocaml
<pango>
in real life, annotating this function could only be useful to prevent it from being overly polymorphic... annotating either x or y would be enough for that purpose
<bluestorm>
it sometimes help to annotate for debugging purposes
<bluestorm>
"if it doesn't complain, then the typing is correct up to that piece of code"
* Yoric[DT]
uses that quite often.
bongy has quit [Read error: 110 (Connection timed out)]
<thelema>
wow, I botched things a lot. Thanks for the corrections.
bluestorm has quit ["Konversation terminated!"]
* thelema
doesn't annotate types often
jonafan has quit [Read error: 110 (Connection timed out)]
hkBst has joined #ocaml
Snrrrub__ has joined #ocaml
thelema is now known as thelema|away
StoneNote has quit [Read error: 104 (Connection reset by peer)]
Snrrrub has quit [Read error: 110 (Connection timed out)]
postalchris has joined #ocaml
postalchris has quit [Client Quit]
Snrrrub__ is now known as Snrrrub
jlouis_ has quit [Read error: 110 (Connection timed out)]
m3ga has joined #ocaml
<Snrrrub>
Does anyone know what the default behaviour is for the compare function of an Abstract_tag block?
<Snrrrub>
Does it just take the defaults from Custom_tag?