Axioplase has quit [Read error: 60 (Operation timed out)]
kinners has joined #ocaml
gim has quit []
gzl has left #ocaml []
Phreaze is now known as Axioplase
<Axioplase>
++
Axioplase has quit [Remote closed the connection]
kinners has quit ["leaving"]
mrsolo_ has joined #ocaml
urz has joined #ocaml
<urz>
hello
<urz>
i'm creating a console user interface
<urz>
what libraries should i look into asside from ncurses and ocaml-tmk
<urz>
any?
<urz>
also, in ncurses, there is a window type and a screen type, what is the difference?
sundeep has quit ["Client exiting"]
kinners has joined #ocaml
slashvar[ejcp] has quit [zelazny.freenode.net irc.freenode.net]
Hadaka has quit [zelazny.freenode.net irc.freenode.net]
yella has quit [zelazny.freenode.net irc.freenode.net]
Naked has joined #ocaml
yella has joined #ocaml
Naked is now known as Hadaka
slashvar[ejcp] has joined #ocaml
sundeep has joined #ocaml
vezenchio has quit ["look at you, hacker, a pathetic creature of meat and bone, panting and sweating as you run through my corridors; how can you c"]
kinners has quit ["leaving"]
dobrek has joined #ocaml
benja has joined #ocaml
mrsolo_ has quit [Read error: 60 (Operation timed out)]
ne1 has quit ["To understand recursion, you must first understand recursion."]
Snark has joined #ocaml
Anvil_Vapre has joined #ocaml
benja has quit ["Leaving"]
hf_ has joined #ocaml
<Anvil_Vapre>
I'm learning ocaml as my frist language (not including perl, awk, php, python, etc) what should I move on to next?
<Snark>
Anvil_Vapre: eiffel
<Anvil_Vapre>
why?
<Anvil_Vapre>
I've heard good things about it
<Anvil_Vapre>
design by contract intrests me...
<Anvil_Vapre>
but doesn't seem too different than what we have in ocaml
<Snark>
it does full multiple inheritance
<Snark>
and ocaml doesn't do DbC, as far I know
<Anvil_Vapre>
yeah
hf has quit [Read error: 104 (Connection reset by peer)]
<Anvil_Vapre>
any other languages as cool as ocaml?
<Anvil_Vapre>
ie. safe and fast
<Anvil_Vapre>
I'm very interested in functional programming
<Anvil_Vapre>
and formal verification
<Snark>
ocaml is nice in that category
<Anvil_Vapre>
I know, I just want to expand my knowledge base
<Anvil_Vapre>
I try to know as many languages as I can
_fab has quit [Remote closed the connection]
<simon->
there are plenty of languages
Hipo has joined #ocaml
<vegai>
Anvil_Vapre: standard ml
Iter has joined #ocaml
tyler has quit ["Client Exiting"]
gim has joined #ocaml
karryall has joined #ocaml
<vegai>
Anvil_Vapre: and if your definition of 'fast' is flexible, haskell ;)
arnowa__ has quit [Read error: 60 (Operation timed out)]
noss has joined #ocaml
demitar_ has quit [Read error: 54 (Connection reset by peer)]
demitar__ has joined #ocaml
<sundeep>
what is the best way to handle global variables in ocaml
<vegai>
pass state explicitly into functions, perhaps?
<sundeep>
what if the function that actually using the state is very deep in the function calling stack?
<sundeep>
%s/using/uses
<karryall>
you have to percolate the state variable all the way then
<karryall>
or use a global variable
<vegai>
indeed =)
<sundeep>
:)
<sundeep>
which gets us back to the original question
<sundeep>
i need the variable to be global across modules
<karryall>
so ? what's the problem ?
<sundeep>
oops, no problem sorry. dunno for a sec thought there must be a better way
bk_ has joined #ocaml
kinners has joined #ocaml
<sundeep>
why is this invalid (3 lines):
<sundeep>
let l = ref [];;
<sundeep>
let appendList e =
<sundeep>
l := e :: !l;;
Shammah_ has joined #ocaml
<kinners>
sundeep: are you using the appendList function correctly (in other parts of code)?
mattam_ has joined #ocaml
<sundeep>
i haven't used it anywhere, i am just trying to compile just that piece of code
<sundeep>
however it seems to work in the interpreter
Iter has quit [Read error: 110 (Connection timed out)]
_fab has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
<kinners>
sundeep: it needs a specific type for the list ref to use
<sundeep>
but how do i specify the type for an empty list
yella has quit [Remote closed the connection]
<kinners>
sundeep: and without that knowledge it can't compile the code into a module because it wouldn't be typesafe
<kinners>
sundeep: you explicitly type it like 'let a : int list ref = ref []' or it would be implicitly typed by how you use it in other parts of the code
<sundeep>
i see, i didn't i could explicity type stuff
<sundeep>
%s/didn't/didn't know
<sundeep>
thanks kinners!
cjohnson has quit [Read error: 60 (Operation timed out)]
cjohnson has joined #ocaml
kosmikus|away is now known as kosmikus
urz has quit ["."]
kinners has quit ["leaving"]
segphault has quit [Read error: 60 (Operation timed out)]
cjohnson has quit [Read error: 60 (Operation timed out)]
cjohnson has joined #ocaml
karryall has quit ["tcho"]
sundeep has quit [Connection timed out]
sundeep has joined #ocaml
cjohnson has quit [No route to host]
sproctor has quit [Read error: 110 (Connection timed out)]
Rotty has joined #ocaml
<Rotty>
i have a question: how can I get a ocaml REPL that has some functions (from an .ml file) preloaded? I tried ocamlmktop, but the compiled-in functions are not bound...
mfurr has joined #ocaml
<mattam>
you just have got to 'open' the module.
<mattam>
have to even
fariseo has quit [Read error: 104 (Connection reset by peer)]
fariseo has joined #ocaml
kosmikus is now known as kosmikus|away
maihem has joined #ocaml
Anvil_Vapre has quit [Read error: 60 (Operation timed out)]
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
monotonom has joined #ocaml
rhys has quit ["Lost terminal"]
karryall has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
bk_ has joined #ocaml
dobrek has quit ["leaving"]
Lemmih has quit [Read error: 110 (Connection timed out)]
dobrek has joined #ocaml
lam__ has joined #ocaml
Snark has quit ["Parti"]
lam has quit [Read error: 110 (Connection timed out)]
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
bk_ has joined #ocaml
Nutssh has joined #ocaml
Nutssh has left #ocaml []
vezenchio has joined #ocaml
JPL-Justin_ has quit [Read error: 60 (Operation timed out)]
JPL-Justin_ has joined #ocaml
Anvil_Vapre has joined #ocaml
<Anvil_Vapre>
How do I open up a file and perform a search/replace regexp on the text?
noss has quit ["Leaving"]
<Anvil_Vapre>
I can't find any reference in the manuals explaining how to do this... have I missed something?
<monotonom>
If you decompose the problem, you may be able to find library functions to do each subproblem.
<Anvil_Vapre>
hrmm...ok
<mfurr>
look at Str.global_replace. it does substition
dobrek has quit ["leaving"]
<mfurr>
er, substitution
<Anvil_Vapre>
right, I know about Str, but not how to open a file for processing
<mfurr>
you mean like open_in? or reading it all as a single string?
<Anvil_Vapre>
both, actually
<mfurr>
open_in will give you an input channel to read from
<mfurr>
you probably don't want to read in the entire file as a sting...
<Anvil_Vapre>
hrmm
<mfurr>
but you could with repeated calls to 'input'
<Anvil_Vapre>
I'd like to do search/replace on really big blocks of text, repeated calls to 'input' probably isn't what I want...
<mfurr>
how big would the file be?
<Anvil_Vapre>
anywhere from one to several hundred pages
<Anvil_Vapre>
of plaintext
<mfurr>
is your search block fixed in size?
<monotonom>
If there is some regex facility that works on streams or lazy lists rather than in-memory strings, we're game.
<mfurr>
I'm not aware of any that do that, though it probably wouldn't be too hard to do
<Anvil_Vapre>
no, other then being ascii, nothing can be assumed before hand
<Anvil_Vapre>
hrmm
<mfurr>
well, you could create a rolling string buffer that slowly walked over the file
<mfurr>
if you're pattern is N chars, create a buffer with size 2N and add to it 1 char at a time
<Anvil_Vapre>
...yeah, that might work.
<mfurr>
or even N+1
<monotonom>
^.*$
<Anvil_Vapre>
but if the regexp has to be rerun everytime the buffer is expanded, that could take a really long time
mattam has quit [Read error: 54 (Connection reset by peer)]
<Anvil_Vapre>
right?
mattam has joined #ocaml
<monotonom>
rolling string buffer won't work for things like a.*b
<Anvil_Vapre>
hrmm..yeah
__DL__ has joined #ocaml
<mfurr>
that's true
<mfurr>
eh, just read the whole thing into memory as one big string
<mfurr>
:)
<Anvil_Vapre>
yeah, memory resources are not a concern
<monotonom>
The stronger claim is that if you find some way to handle things like a.*b with bounded memory, you amount to giving a regex facility that works over streams.
<monotonom>
I like Haskell more than I like Ocaml because of defaulting to lazy streams. You write a function for strings, and you get a function that works for streams too. It is very unifying.
<mfurr>
yeah, lazy streams are definately nice to use
<Anvil_Vapre>
hrmm... I've never tried haskell, how different is it from Ocaml?
<mfurr>
not very
<monotonom>
Haskell has even fewer libraries than OCaml.
<mfurr>
same basic idea
<mfurr>
you can have type classes though, to give you ad-hoc polymorphism
<monotonom>
However, one implementation (ghc) does provide a regex library, and it works just as well if the string is really a lazy stream coming from a huge file.
<Anvil_Vapre>
ooh
<Anvil_Vapre>
how does the performance compare to ocaml?
<mfurr>
slooooowwwwwwww
<monotonom>
Haskell is slower and more bulky
<Anvil_Vapre>
damn
<monotonom>
Not as bulky as reading the whole file into memory though :)
<mfurr>
and then there's monads
<mfurr>
which are fun to learn if you haven't seen them before
<Anvil_Vapre>
like I said, I'm not really concerned about memory usage
<__DL__>
well it is doable, I'm pretty sure.
<Anvil_Vapre>
would ocaml's pcre work for this?
<__DL__>
(depend of what you mean by hadle, and bounded : as the length of the matched string is unbounded, if you want it, you will use unbounded memory)
<Anvil_Vapre>
or should I stick with Str?
gl has left #ocaml []
gl has joined #ocaml
<mfurr>
depends, are your regex in perl style?
<Anvil_Vapre>
not at the moment, but they easily could be.
<__DL__>
my main concern with haskell are the difficulties to compute memory usage a priori
* mfurr
prefers pcre to str
_fab has quit []
<mfurr>
especially with the camlp4 syntax sugaring library out there
<mfurr>
haskell code can also be hard to read because people tend to go crazy with defining new operators
<monotonom>
OCaml is widely open to that kind of abuse too. It is a property of crazy people, not a crazy language.
<mellum>
at least you cannot overload them
<vegai>
haskell has some nifty features for the overloading, though
<mfurr>
the `func` notation is nice I must say though
Rotty has quit [Remote closed the connection]
__DL__ has quit [Remote closed the connection]
benja has joined #ocaml
<benja>
hi all
<mfurr>
hello
<benja>
I've a class ['a] c (v:'a) (to_string: 'a -> string) (v:'a) = ... method print = print_endline to_string v end
<benja>
and I've differtent instance of it with int/string/bool as 'a
<benja>
now I want to put all the instance in a list do List.iter (fun o -> o#print)
<benja>
but the ocaml type-checker is not appy with that
<benja>
I tried un open-type like let li : < print : unit .. > = [instance1, i2] but the ocaml type checker seems to extant the type of ther first class to the type of the list
<Smerdyakov>
benja, a list can't have an object type, so of course that won't typecheck....
<Smerdyakov>
benja, you probably want: let li : < print : unit .. > list = [instance1, i2]
<benja>
yes that's wath I meant, sry
<Smerdyakov>
benja, and you'll probably need explicit coercions for some or all list elements.
<benja>
and how I do that ?
<Smerdyakov>
Like [instance1 :> className, i2 :> className]
<monotonom>
ocaml is full of smileys.
<benja>
so I've to make the class inherit from a virtual print_class ?
<benja>
which define the print method ?
<Smerdyakov>
You could just as well put <print : unit> instead of className.
<Smerdyakov>
But it's nicer to name it.
<benja>
ok thanks a lot Smerdyakov !
<benja>
:)
segphault is now known as seg|startrek
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
<monotonom>
I tried grep "m.*e" /dev/zero. It eats up a lot of memory and then dies due to memory exhaustion.
<monotonom>
This says that even grep reads at least one complete line into memory before it starts matching.
<benja>
ho the correct syntax was [(instance1 : 'a c :> print_class);...], it works ! thx
<monotonom>
So to use ocaml's regex library, you can do exactly the same: read one line, which is a normal string, then regex it.
<benja>
ho my bad, the [(instance :> super_class)...] works to but you need the parentheses
Iter has joined #ocaml
<Anvil_Vapre>
monotom, I'm writing a crude program transformation engine for class, so regexing one line at a time isn't going to work well for me.
<monotonom>
Ah no wonder.
<monotonom>
Also, although ghc provides a regex library over strings, and although strings could be lazy streams there, the regex library is actually a Haskell interface to the Posix C regex library, which still requires the string to be all in memory before it begins working.
<monotonom>
(This is also the same situation with Str in OCaml.)
<Anvil_Vapre>
I'm evolving program transformation rulesets using a user-defined fitness plane, each ruleset is stored as a tree of regular expressions
<monotonom>
So I suppose there is no harm reading the entire file into memory.
<Anvil_Vapre>
yeah
<Anvil_Vapre>
that's what I concluded
<monotonom>
(Afterall everyone else is doing that.)
<Anvil_Vapre>
eh?
<monotonom>
In the entire open source community, everyone relies on the same Posix C regex library.
<Anvil_Vapre>
oh
<Anvil_Vapre>
is that good or bad?
<monotonom>
I don't know. Reuse is good. But a non-lazy regex library is rather silly.
<Anvil_Vapre>
how hard would it be to rewrite?
<monotonom>
The hard part is in the politics. First everyone has to agree upon a common interface of lazy streams. (And it has to be compatible with C no less.)
<Anvil_Vapre>
hmmm
<monotonom>
See, if everyone used OCaml, it would be rather easy to solve because worst comes to worst you can always functorize your lazy regex module.
<karryall>
monotonom: ocaml uses its own regex engine, it's not a binding