* rwmjones
got about 10% of the way through that oleg email
screwt8 has quit [Read error: 104 (Connection reset by peer)]
love-pingoo has joined #ocaml
cap has joined #ocaml
screwt8 has joined #ocaml
leo037 has joined #ocaml
_ke has joined #ocaml
<_ke>
hi there
cap` has joined #ocaml
<_ke>
is it possible to create an own type, where a certain element (e.g. int) is set to a certain value (e.g. = 0)?
cap` has quit [Remote closed the connection]
<rwmjones>
_ke, not in basic OCaml, but there are camlp4 extensions, or other ways to do it
<rwmjones>
for example, you can hide the type behind a signature to stop callers from making values directly (but only through your functions which ensure the invariants you want)
<_ke>
ok
<_ke>
no i will stay with ocaml, thanks
<rwmjones>
_ke, something like this ...
<_ke>
rwmjones, if i use a list, is there a simple to way to iterate through that list and set that int?
<rwmjones>
module Test : sig type t val make_t : unit -> t val inc_t : t -> t val print_t end = struct type t = int let make_t = 0 let inc_t t = t+1 let print_t t = print_endline (string_of_int t) end ;;
<xavierbot>
Characters 72-79:
<xavierbot>
Parse error: [a_LIDENT] expected after [value_val] (in [sig_item])
<xavierbot>
module Test : sig type t val make_t : unit -> t val inc_t : t -> t val print_t end = struct type t = int let make_t = 0 let inc_t t = t+1 let print_t t = print_endline (string_of_int t) end ;;
<xavierbot>
^^^^^^^
<rwmjones>
grrr
<rwmjones>
module Test : sig type t val make_t : unit -> t val inc_t : t -> t val print_t : t -> unit end = struct type t = int let make_t = 0 let inc_t t = t+1 let print_t t = print_endline (string_of_int t) end ;;
<xavierbot>
Characters 98-202:
<xavierbot>
module Test : sig type t val make_t : unit -> t val inc_t : t -> t val print_t : t -> unit end = struct type t = int let make_t = 0 let inc_t t = t+1 let print_t t = print_endline (string_of_int t) end ;;
<rwmjones>
module Test : sig type t val make_t : unit -> t val inc_t : t -> t val print_t : t -> unit end = struct type t = int let make_t () = 0 let inc_t t = t+1 let print_t t = print_endline (string_of_int t) end ;;
<xavierbot>
module Test :
<xavierbot>
sig
<xavierbot>
type t
<xavierbot>
val make_t : unit -> t
<xavierbot>
val inc_t : t -> t
<xavierbot>
val print_t : t -> unit
<xavierbot>
end
<_ke>
hehe
<rwmjones>
let t = Test.make_t ();;
<xavierbot>
val t : Test.t = <abstr>
<rwmjones>
Test.print_t t ;;
<xavierbot>
0
<xavierbot>
- : unit = ()
<rwmjones>
let t = Test.inc_t t ;;
<xavierbot>
val t : Test.t = <abstr>
<rwmjones>
let t = Test.inc_t t ;;
<xavierbot>
val t : Test.t = <abstr>
<rwmjones>
Test.print_t t ;;
<xavierbot>
2
<xavierbot>
- : unit = ()
<rwmjones>
so that's an example of a constrained type - it's an integer, but callers can't mess with it, they can only do limited stuff
<_ke>
i understand
<_ke>
but i think thats too complicated for that i want to do
fmadero has left #ocaml []
<rwmjones>
_ke, so camlp4 is not possible?
<_ke>
rwmjones, no, it has to be ocaml only
<rwmjones>
there is something called "private rows" which I've not used
cap has quit ["ERC Version 5.2 (IRC client for Emacs)"]
<rwmjones>
I don't think there's anything particularly special to OCaml
pango has joined #ocaml
<oracle1>
ok interesting
<oracle1>
thx
descender has quit ["Elegance has the disadvantage that hard work is needed to achieve it and a good education to appreciate it. - E. W. Dijkstra"]
leo037 has quit ["Leaving"]
love-pingoo has quit ["Connection reset by pear"]
<_ke>
is there a easy way to find the same entries in a list? e.g. if i have "a", "b", "c", "a", i want to find the second "a"
<rwmjones>
_ke, and what do you want to do with it? just return its position in the list? return the duplicated element? what if there is more than one duplicate?
<rwmjones>
or no duplicates?
<_ke>
rwmjones, i have a list of tuples, e.g. "a" and 1, "b" and 1, "c" and 2, "a" and 2. now i want to finde the same strings, and put the number behind it togheter. in that example i want to get "a" and 1,2, "b" and 1, "c" and 2
etnt has quit ["bye"]
<rwmjones>
it sounds like you want the "group_by" function
<xavierbot>
- : (string * int list) list = [("a", [1; 2]); ("b", [1]); ("c", [2])]
<rwmjones>
yup, that group_by only works if the list is sorted first
<_ke>
its not ;)
<rwmjones>
well, sort it then!
<rwmjones>
you could do it imperatively, using an intermediate Hashtbl, if you didn't want to sort it
smimou has joined #ocaml
<_ke>
rwmjones, could you tell me more about that Hashtbl-method?
<rwmjones>
well, the general plan would be to create a Hashtbl (Hashtbl.create), then go over the list adding each (key, value) pair into the hashtable.
<rwmjones>
Note that OCaml Hashtbl allows multiple values for a single key, which is why this would work.
<rwmjones>
Then when you've gone over the list, using Hashtbl.fold to pull out the keys.
<rwmjones>
Then for each key, get all the values.
<rwmjones>
and construct a list from that (key, list-of-values)
marc has quit [Read error: 113 (No route to host)]
marc has joined #ocaml
_ke has quit ["umount /mnt/me"]
pango has quit [Remote closed the connection]
pango has joined #ocaml
edwardk has joined #ocaml
love-pingoo has joined #ocaml
buluca has joined #ocaml
marc has quit [Nick collision from services.]
marc___ has joined #ocaml
Len1 has joined #ocaml
rwmjones has quit ["Closed connection"]
rwmjones has joined #ocaml
buluca has quit [Read error: 110 (Connection timed out)]
<TFK>
Excuse me for the noobish question, but with what Linux distributions I can get OCaml running in the most painless fashion? Will Ubuntu do?
<Smerdyakov>
I've only ever tried Debian, but it's totally painless there.
pantsd has quit [Read error: 110 (Connection timed out)]
visage has quit []
descender has joined #ocaml
<rwmjones>
TFK, I'm afraid to say that at the moment it's Debian, who have great support
<rwmjones>
but I'm trying to get Fedora to have an equal level of support
<TFK>
And other distros?
<rwmjones>
and if you like you can get my packages (which work on FC6, F7 and F8) here:
<rwmjones>
TFK, what Linux distro did you have in mind?
<rwmjones>
it's a slow business, but hopefully Fedora will have excellent OCaml support in a few months
<TFK>
Well, Ubuntu :-P that's because I've been brainwashed. But I suppose I can try Debian and Fedora as well.
<rwmjones>
Ubuntu has ..... issues ....... although at the moment it does work
* rwmjones
boots laptop, back in a second
rwmjones_ has joined #ocaml
rwmjones_ is now known as rwmjones_laptop
<rwmjones_laptop>
did I miss anything?
* TFK
shakes head
<TFK>
What kind of issues does ubuntu have? I think I only need the debugger and profiler.
<rwmjones_laptop>
the issues are (and this is highly my personal opinion btw):
<rwmjones_laptop>
(1) upstream Debian don't like them much, and so won't deal with bug reports and other problems
pantsd has joined #ocaml
<rwmjones_laptop>
(2) Ubuntu takes OCaml packages at random points, which can lead to inconsistencies
<rwmjones_laptop>
(eg. in Ubuntu 6.06 there was originally a load of inconsistencies which meant you could compile programs which used libraries from different .debs at all)
<rwmjones_laptop>
(3) Ubuntu is usually one release behind Debian
<rwmjones_laptop>
however, if all you want is the basic OCaml package, then it will most likely work
<TFK>
yup, that's what I want.
<Smerdyakov>
In conclusion, if you want a usable Linux system, use Debian. :P
<TFK>
And then maybe everything else the stdlib lacks :-P
<Smerdyakov>
It just has waaaay more effort going into it than anything else.
<rwmjones_laptop>
well go for it! did you try to grab & install the ocaml-native-compilers package/?
<TFK>
Well, I don't even have Linux yet!
buluca has joined #ocaml
<rwmjones_laptop>
this is true, Debian have an excellent team of something like 5-10 people working on OCaml
<TFK>
How hard is it to port the profiler and debugger to Windows?
<Smerdyakov>
rwmjones, and _that's_ for a (relatively) obscure package!
<rwmjones_laptop>
however, Fedora will have great support!
<rwmjones_laptop>
TFK, save yourself time and use Linux, it's considerably better than Windows in so many ways when it comes to serious development
<TFK>
I don't want to start a flame war of any sort :-)
<TFK>
But I still wonder about possibilities for portability.
<Smerdyakov>
Regardless of what rwmjones hopes to achieve some day, I think we agree that Debian wins today.
<rwmjones_laptop>
TFK, I actually have some direct experience there
<rwmjones_laptop>
see:
<Smerdyakov>
That is, Debian Linux wins over all OS/distro choices for developers.