<accel>
i'm using lua; and I'm struggling to write a program that scales over 5K LOC (due to dynamic typing); is it easy in ocaml to write 50K LOc programs?
<thelema_>
kaustuv: more likely a mistake in the interface
<kaustuv>
thelema_: Hmm, "make doc" on git master seems to have Array.Cap exposed in the generated docs. Are the api pages out of date?
<kaustuv>
I am curious why BatBigarray.Genarray.mapi uses Array.Cap, while BatBigarray.Array<n>.mapi[j[k]] doesn't use caps.
myu2 has joined #ocaml
<kaustuv>
Also curious is that BatArray.unsafe_read/write is now hidden and isntead only available as BatArray.Cap.unsafe_read/write (with an incompatible type signature!)
<thelema_>
I'm just hearing bug, bug, bug. Is it easy for you to fix these?
<kaustuv>
Yes, I am quite happy to give you a patch if you think these are obvious bugs.
<thelema_>
the API pages do need to be regenerated, I just wish it weren't a pain to do so
<kaustuv>
Would you be averse to adding "-annot -warn-error A" to the compile flags?
* thelema_
looks up what that warning is
<kaustuv>
it makes all default warnings into errors
<kaustuv>
(Batteries compiles fine with it)
<thelema_>
really? I'm surprised, but ok.
<kaustuv>
It has saved my skin so *many* times because it forces me to deal with unused variables and nonexhaustive patterns
<thelema_>
I think that's perfectly fine to add
<thelema_>
yes, I have -w Z turned on for my projects, and it's very nice getting the message
tnguyen has quit [Remote host closed the connection]
tnguyen has joined #ocaml
charlesno has joined #ocaml
charlesno has left #ocaml []
<thelema_>
kaustuv: map_in_place instead of Array.modify?
<thelema_>
also it looks like there's a bunch of whitespace changes in the patch...
<thelema_>
I approve of everything else
<thelema_>
don't mind me though - make any further patches like it you want
tnguyen has quit [Remote host closed the connection]
Amorphous has quit [Ping timeout: 272 seconds]
<kaustuv>
thelema_: 'modify' is what's used in the Standard ML basis, if that serves as a point of reference. But I'll leave naming decisions to you.
<kaustuv>
ah, sorry about the whitespace -- my emacs automatically strips out line-ending whitespace before saving.
drunK has quit [Remote host closed the connection]
Amorphous has joined #ocaml
<thelema_>
kaustuv: no problem getting rid of that.
<thelema_>
it's committed as modify, if anyone objects, there's some time for it to be renamed
<thelema_>
The Map.modify is nicely compatible with your modify, so I think we can keep it.
tnguyen has joined #ocaml
lamawithonel has quit [Remote host closed the connection]
ymasory has joined #ocaml
lamawithonel has joined #ocaml
Yoric has joined #ocaml
myu2 has quit [Remote host closed the connection]
ymasory has quit [Quit: Ex-Chat]
valross has joined #ocaml
groves has left #ocaml []
thelema_ has quit [Remote host closed the connection]
thelema has joined #ocaml
Snark has joined #ocaml
ulfdoz has joined #ocaml
tnguyen has quit [Remote host closed the connection]
hto has quit [Read error: Connection reset by peer]
hto has joined #ocaml
hto has quit [Client Quit]
hto has joined #ocaml
mfp has quit [Ping timeout: 276 seconds]
Guest10402 has joined #ocaml
valross has quit [Remote host closed the connection]
ulfdoz has quit [Read error: Operation timed out]
myu2 has joined #ocaml
seafood has joined #ocaml
myu2 has quit [Remote host closed the connection]
emias has quit [Ping timeout: 276 seconds]
seafood has quit [Ping timeout: 240 seconds]
edwin has joined #ocaml
AZora has joined #ocaml
<AZora>
OCaml is functional, it's procedural, it does objects, it does functional on objects... but when will handle database style data structures and NULL?
<mrvn>
AZora: let x = None;;
<mrvn>
And what are database style data structures? Why can't you just define one?
<AZora>
Well I tried to connect MySQL and OCaml years ago... and then dropped OCaml as a result. Wondering if it has evolved enough for me to give it a third look.
<mrvn>
That probably stemed from a lack of you knowing ocaml.
<AZora>
Probably true, and the tutorials I read on the subject started by saying "Don't.... but... if you really want to... "
<mrvn>
allways a good idea to stay away from those tutorials
<AZora>
I'm more willing to correct my misconceptions than blame anything else.
<mrvn>
Not having null pointer is actualy an essential core design of ocaml. You really really don't want them.
<AZora>
Due to a lack of union on functional?
<mrvn>
Because you want to use an option type so you have None | Some x
<mrvn>
That makes it clear the x is optional and the code can check properly. That way you can't accidentally access a null pointer because you forgot to check if it is null or not.
<AZora>
Hmmm... mind if I paraphrase your reply in the context of what I'm trying to do and see if I understand what it means?
<mrvn>
sure
<mrvn>
(as in go ahead)
Yoric has quit [Read error: Connection reset by peer]
<AZora>
Let's say you have a vast number of conditions, and you arrange those into a list/array/etc. The functional query I make gives me the subset of the pertinent data, disregarding information that is superfluous. If a condition wasn't present at all, but is part of the query, then I should populate with some data tape like None so that I can return results that include None?
<mrvn>
If a condition is optional then you use the option type. In ocaml you have no choice than to populate the return value. There simply is no other choice, you MUST always return something.
<AZora>
That would help me in this project :)
ikaros has joined #ocaml
<mrvn>
Actually strictly speaking you don't have to "return" something all the time. you can also throw an exception.
<AZora>
Coul d I create something like "Not Present" in addition to "none" ?
<mrvn>
# List.find (fun x -> x = 3) [1;2;4];;
<mrvn>
Exception: Not_found.
<flux>
azora, well, you could use an option of option type, but that can be confusing
<mrvn>
AZora: You can define a union type: type result = Not_Present | Result of whatever
<flux>
azora, or you can create your own type
<flux>
like: type 'a result = Not_Present | Empty | Something of 'a
<mrvn>
The option type is actualy just type 'a option = None | Some of 'a
<flux>
techically this is could be considered equivalent: type 'a result = 'a option option
<flux>
but as I said, it can get confusing..
<AZora>
hey look ! ocaml-mysql project!
<AZora>
I think it was around 0.2 last I looked ,and now it is 1.0
<mrvn>
AZora: Practically I would use an option type if a failure is likely/common and an exception if a failure is the exception to the rule.
<AZora>
hmmm looks like I should start (and this time finish) another book on lambda calculus and then pick up OCaml again.
<mrvn>
AZora: A good mysql module should probably provide both ways.
<AZora>
well I want to return a somewhat fuzzy set of data, since I probably won't be repeating conditions exactly. The fuzziness degree may restrict or include None and NotHere depending on the condition and query
<AZora>
As a design question, I need to figure out what degree of approximation is permitted to reduce the data explosion that will result from anything more than a test case scenario
ttamttam has joined #ocaml
<AZora>
Thanks for correcting my misconceptions :)
<mrvn>
If you return a list of properties you can just skip the properties that aren't present.
<mrvn>
If your C struct has a structur with pointers that can be null then an option type is called for.
<AZora>
ah ... that is very similar to what I will need to do in many cases. Can I also include them in the result conditionally, but restrict out certain values? like 0.2 < x < 0.4 && not present?
<mrvn>
if (x >= 0.2 && x < 0.4) then Not_Present else Present x
<mrvn>
with type result = Not_Present | Present of float in this case
<mrvn>
You can use whatever code you want to compute what to return
<f[x]>
Julien_T, I've used that patch some time ago, on x86
<AZora>
Thank very much, I need to finish current project before I start this one, but I saved your advice for later
Guest10402 has left #ocaml []
<f[x]>
gildor, ssh: connect to host forge.ocamlcore.org port 22: Connection timed out
AZora has left #ocaml []
boscop has joined #ocaml
ygrek has joined #ocaml
ygrek has quit [Remote host closed the connection]
<gildor>
f[x]: retry
<gildor>
f[x]: eth0 has bugged at 00:38 and the whole server has been rebooted
<gildor>
you will see that you have been removed from extunix group (so do i)
* gildor
working on this problem
<gildor>
f[x]: so this is a permission problem
<f[x]>
true, ok
<f[x]>
btw it looks like some forge prefs were reset too, e.g. sorting in trackers, had to setup it again
<gildor>
f[x]: humm, probably related to the latest upgrade
<gildor>
(2011-01-07)
<gildor>
+ it seems to appear when you are added to a new project
<gildor>
f[x]: e.g. you are still part of hypertable/lzo
Yoric has joined #ocaml
<thomasga>
does somebody understand the semantics of Lwt.ignore_result ?
<gildor>
f[x]: I just do something that gives you back access to extunix
<gildor>
f[x]: try it and tell me when you are done
<gildor>
f[x]: I am not sure what has happened and how long it will last
<f[x]>
gildor, ok, push worked, but now id shows only hypertable and extunix groups, not that I need others now
<gildor>
f[x]: yes, I was trying to understand the problem when a manipulation just put you back in extunix
<gildor>
f[x]: (yes I am using your login to do some tests)
<f[x]>
ok
<gildor>
thomasga: what do you want to know about Lwt.ignore_result ?
<gildor>
f[x]: if your push is successful, I will update the whole forge with the latest version
<gildor>
(it may fix some bugs and introduce new one)
mfp has joined #ocaml
<f[x]>
looks ok
<f[x]>
mfp, why do sqlite3 handles have to be used in same thread that created them? Looks like there is no such restriction in sqlite3 and no special code in bindings afaics
<thomasga>
gidlor: is it equivalent to do: lwt () = f x in ... and ignore_result (f x) ?
<f[x]>
iiuc, restriction is one handle in one thread at a time
<gildor>
thomasga: no
<gildor>
... wait I don't use the pa_lwt, need to see what lwt () means
<thomasga>
ignore_result creates a pending thread ?
almaisan-away is now known as al-maisan
<thomasga>
lwt () = f x in is the same as f x >>= fun () ->
<Julien_T>
f[x], I finally get it work by reporting modification of files in asmcomp/i386/ to files in asmcomp/amd64/ , thx :)
<gildor>
ok, so the answer is really "no"
<f[x]>
Julien_T, cool
<thomasga>
so what is the difference ? :-)
<gildor>
lwt () will create a thread but you don't have guarantee that it finished
<gildor>
where ignore_result will make the thread run
<thomasga>
ok, so if I know for sure that f will finish, is it the same ?
<gildor>
thomasga: I think that in the real world both finish
<gildor>
thomasga: but with ignore_result you really create a "background" thread
<gildor>
if you are sure f will finish, it is probably the same
ygrek has joined #ocaml
<thomasga>
ok, so if f has some side effects, >>= will ensure a certain order with what follow but not ignore_result ?
<gildor>
thomasga: yes
<gildor>
(at least I think so, I am not lwt upstream)
<flux>
thomasga, I view ignore_result as basically detach_thread
<thomasga>
thanks gildor for your help
_andre has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
<avsm>
ignore_result is a bit wierd
<avsm>
since it can raise an exception, but if it's raised after it it yields, it's ignored (i think)
<mfp>
f[x]: I don't know, but it's clearly documented in the .mli
<mfp>
avsm: AFAIK an exception inside ignore_result will be raised eventually... in some random place of your code
<f[x]>
mfp, hm, maybe it was applicable to some older sqlite versions
<mfp>
I always do ignore_result begin try_lwt .... with e -> (* log and ignore *) end
<avsm2>
wow, you're right. i must not have noticed since it was in a try/catch somewhere safe when it triggered
<avsm2>
whats the point of that? in the source, the add_immutable_waiter just needs to discard the exception. the return value is ignored, so why would an exception matter?
<mfp>
f[x]: well, the warning is still in ocaml-sqlite-1.5.6's sqlite3.mli, and I once saw the OCaml runtime lock --- I believe this was the reason (I was running Sqlexpr stuff in a detached thread)
<mfp>
avsm2: yes... ignore_result is quite pointless, plain old ignore is better
<mfp>
... but still not safe because an escaping exn (not in the monad) could be raised at any point in the program, so you still have to wrap with try_lwt ... with e -> (* drop exn *)
joelr has joined #ocaml
<joelr>
good morning
myu2 has joined #ocaml
LeNsTR has quit [Ping timeout: 240 seconds]
LeNsTR has joined #ocaml
accel has joined #ocaml
<accel>
i am reading aboug multiple file ocaml programs
<accel>
andm odules
<accel>
when should i split by module; and why across multiple files?
cyanure has joined #ocaml
<mfp>
accel: it's no different from modular decomposition in e.g. C --- you put related functionality in a module; in OCaml, this often means at least one (usually abstract) data type and the operations defined on it
<mfp>
s/no different/not very different/
ftrvxmtrx has joined #ocaml
<mfp>
hmmm are there any guarantees regarding the thread in which finalizers (given to Gc.finalise) are executed?
<mfp>
guess they all run in the main thread?
<joelr>
assuming type 'a error = | A of 'a | B | C of int ;;
<joelr>
why does this work: let error v = function | -1 -> B | x when x < 0 -> B | 0 -> A v | x -> C x ;;
<joelr>
but this doesn't? let error v : 'a -> int -> 'a error = function | -1 -> B | x when x < 0 -> B | 0 -> A v | x -> C x ;;
<mfp>
aren't you missing a parameter in the 2nd definition?
<mfp>
the one with type 'a
<joelr>
mfp: A v
<mfp>
misread, ignore me
<joelr>
mfp: 'a is the type of the 1st argument
<mfp>
ah didn't misread completely
<mfp>
let error v : int -> 'a error = ... would work
<accel>
is ocaml for scientists good ?
<mfp>
or let error (v : 'a) : int -> 'a error = <=> let error = fun (v : 'a) -> function ...
<mrvn>
joelr: because you can not type a function declaration with parameters.
<mrvn>
mfp: aren't you missing some ()?
<joelr>
mfp: thanks!
<mfp>
mrvn: am I?
<mrvn>
I take it all back. you can actually type it like mfp said.
<mrvn>
I would have thought at a minimum you needed let (error v) : ...
<joelr>
this works fine indeed: let error v : int -> 'a error = function | -1 -> B | x when x < 0 -> B | 0 -> A v | x -> C x ;;
<mrvn>
joelr: but why give that when it is already infered that way?
<joelr>
mrvn: it's not when you need it polymorphic
<mrvn>
# let error v = function | -1 -> B | x when x < 0 -> B | 0 -> A v | x -> C x ;;
<mrvn>
val error : 'a -> int -> 'a error = <fun>
<mrvn>
# error 1 2;;
<mrvn>
- : int error = C 2
<mrvn>
# error "foo" 0;;
<mrvn>
- : string error = A "foo"
<mrvn>
works here
<mfp>
joelr: also, annotating with 'a does not make it polymorphic necessarily, e.g. let f (a : 'a) = a + 1 is still : int -> int
<mfp>
in 3.12, you can have explicitly polymorphic types, though (then you'd get a type error in the above)
<mrvn>
The annotation is just a constraint on the result it infers.
<joelr>
mfp: it works for my use case with just that amount of annotation. thanks for ponting out 3.12, though
<mfp>
joelr: the syntax is something like let f : 'a. 'a -> .... = fun x -> ....
<accel>
is there a way to render tex in an opengl window in ocaml?
<mrvn>
joelr: In 3.12 you can use the 'a. 'a -> 'a syntax from records also on normal functions.
<joelr>
right
<mrvn>
accel: tex or text?
<accel>
text
<accel>
is there a way to render text (as in a standard ttf font) in an opengl window in ocaml?
<flux>
a big difference :)
<accel>
if you can render tex in ocaml
<mrvn>
accel: I'm pretty sure the opengl bindings have something to render text
<accel>
I can convert it to rendering text
<accel>
is there any where to get a copy of ocaml for scientists for less than $170 USD ?
<accel>
book looks interesting
<accel>
price slightly high
<flux>
I wonder if Jon would make a better or worse profit by lowering the book price
<mfp>
accel: IIRC some ppl made a deal with the author, xx% off in exchange for publishing a review of the book
<accel>
that's totally not cool
<flux>
mfp, does it require the review to be a favorable one?-)
<mfp>
I don't know :-|
<accel>
Review: The author has so much faith in this book, he bribed me to write this sreview.
<flux>
also, if you've paid $170 for a book, you better not give the impression that you've done a bad deal, so obviously all reviews are going to be positive ;)
<accel>
taht's brilliant
<accel>
it's like the $2 hooker that started charging $2000
<mfp>
indeed a pb... while I've seen some favourable reviews, I don't know to which extent they can be trusted
<mrvn>
At $170 probably only university libraries and researchers buy it.
<accel>
our library desn't have it
<accel>
just checekd
<mrvn>
accel: ask the functional languages department
<flux>
ask the whatwhat?
<accel>
I think that's like 0.5 professors
<mrvn>
the department of the computer science section that deals with functional languages, lamda calculus and such stuff
<flux>
suure...
<mrvn>
It's probably called something else that covers a bit more.
<mrvn>
At my university the departments each had some extra books that werent in the general library.
al-maisan is now known as almaisan-away
joelr has quit [Quit: joelr]
<flux>
ocaml-tutorial.org appears to be still down. I guess there went the google rating it possibly had :-o.
<gildor>
flux: go to mirror.ocamlcore.org for ocaml-tutorial mirror
<flux>
gildor, yes, but ocaml tutorial in google won't find that
<flux>
I guess the domain could simply be adjusted to point there, and a vhost configuration could be added ;)
accel has quit [Quit: leaving]
<flux>
gildor, it won't find it because ~nobody links there
<flux>
mfp, I imagine it would. although I would prefer the domain-based solution ;).
hto has quit [Read error: Connection reset by peer]
<cyanure>
HI, can someone help me with camlp5 ? I have a "Invalid argument: index out of bounds" whan i do the command "camlp5o -I . pr_o.cmo pa_autoabstract.cmo prog.ml -o prog.ppo"
<edwin>
whats wrong with the ocaml-tutorial server? still being rebuilt after exim exploit?
<flux>
afaik yes
<flux>
probably not a full-time job that ;)
hto has joined #ocaml
eye-scuzzy has quit [Ping timeout: 240 seconds]
eye-scuzzy has joined #ocaml
smerz has joined #ocaml
oriba has joined #ocaml
boscop_ has joined #ocaml
almaisan-away is now known as al-maisan
boscop has quit [Ping timeout: 240 seconds]
<cyanure>
In a '_tags' file, for ocambuild, how can i say "every file but toto.ml"
<cyanure>
nvm found it
Yoric has quit [Quit: Yoric]
ygrek has quit [Remote host closed the connection]
<edwin>
add another rule for toto
rixed_ has joined #ocaml
<cyanure>
edwin, yeah found it thx
<cyanure>
Is there a way to pass a cflag for a single file by putting it in the _tags file ?
<cyanure>
cflag( <flag>) doesn't work
<edwin>
_oasis has CCOpt, not sure how its implemented
<gildor>
CCOpt will apply for a whole library/executable
<edwin>
is it implemented with something in _tags though? or in myocamlbuild.ml?
<gildor>
cyanure: if you want to do this for a single file you will have to define a tag (e.g. mycflag) and define a flag ["ocamlc"; "mycflag"] & S[A"-ccopt"; A"-toto"] in myocamlbuild.ml
<gildor>
edwin: it is implemented with something in _tags, indeed
<gildor>
like library_foo_ccopt
<gildor>
if cyanure wants, he can use _oasis and remove this tags for all files except the one where it applies
<gildor>
i.e. <*.ml>: -library_foo_ccopt
<gildor>
"myfile.ml": library_foo_ccopt
<cyanure>
gildor, a new file _oasis ?
<edwin>
its not quite as simple, you also need to install oasis :D
<edwin>
if you want to use that instead of handwriting all of the buildsystem
<cyanure>
there is no easy way to do this ? because I have no myocamlbuild.ml for now
<gildor>
_oasis is buildsystem generator that eases creating library/exec in ocaml
<edwin>
for me the buildfiles generated by oasis provide a good starting point. Sure it needs a few tweaks in _tags, but better than writing all by hand IMHO
<gildor>
cyanure: what I have describe with the myocamlbuild.ml is the easiest way
<gildor>
cyanure: oasis can help you if you don't want to write your own myocamlbuild.ml (which can be tedious task)
<cyanure>
Another question, can I add a dependencies myself ? saying foo.ml needs bar.cmo ?
<gildor>
with ocamlbuild this should be autodiscovered
<gildor>
if foo.ml contains Bar.XXX
<gildor>
e.g.
<gildor>
isn't it auto-discovered ?
<cyanure>
well
<cyanure>
no
<cyanure>
bar is a syntax augmentation with camlp5
<gildor>
does foo.ml contain a reference to Bar ?
<cyanure>
Not directly
<gildor>
so it is not a dependency
<cyanure>
if you want, <foo.ml> : pp(camlp5o bar.cmo) in _tags
<gildor>
Bar contains some stuff that auto-register themselves ?
<cyanure>
I'm not sure what it means ?
<gildor>
(auto-register, like let () = register myfun at the toplevel, but it doesn't seems to be your case)
<cyanure>
no ^^
<gildor>
cyanure: you'll have to define a "dep" in myocamlbuild.ml
<cyanure>
IS there no way to define two successive targets ?
avsm1 has joined #ocaml
avsm has quit [Ping timeout: 272 seconds]
<Julien_T>
I fear I already know the answer but ... let's try ! Is there any chance to have a way to inline a function given in parameter to a functor ?
<Julien_T>
in the instantiation of the functor
<thelema>
Julien_T: the compiler makes its own decisions on inlining
<Julien_T>
I really need to force him to inline the function
jm has joined #ocaml
<Julien_T>
cause it's something like 5x faster when inlined, but I need to keep the functor structure of my code
<gildor>
cyanure: dep is the way to define successive targets
Vinnipeg has joined #ocaml
<mfp>
Julien_T: neither functional parameters passed to a HOF nor functor parameters are inlined
<cyanure>
gildor, Any tuto for "how to make a myocamlbuild.ml" ?
seafood has joined #ocaml
<mfp>
Julien_T: the only workaround is to defunctorize manually (which be automated to some extent with camlp4.macro and INCLUDE)
<Julien_T>
I heard about a defunctorization program but it seems to be no more maintained
<thelema>
kaustuv: If I merge the feat-testing branch, would you use the inline testing for unit tests?
eaburns has joined #ocaml
<kaustuv>
thelema: I generally don't write or use tests, so I'm not the best person to ask.
<thelema>
me neither, but this branch has some machinery to make it dumb easy to write tests, which might make it easy enough to just do.
drunK has quit [Remote host closed the connection]
<kaustuv>
Anyway, I have to catch a train, but if you want me to eg. make a post on the batteries mailing list about these proposed additions, I can do that.
<thelema>
It wouldn't hurt to announce them somehow, although elehack is right - we need examples of why this stuff is useful/cool
Axioplase_ has quit [Ping timeout: 246 seconds]
<kaustuv>
OK, will do that tomorrow-ish.
<thelema>
no problem, thanks for the code
<thelema>
I hope we can get the vast majority of your personal standard library included in batteries
smerz has quit [Remote host closed the connection]
thatch has joined #ocaml
thatch has quit [Remote host closed the connection]
thatch has joined #ocaml
<thelema>
I'm impressed by quicktest... It seems to have found a bug in kaustuv's heap.
<thelema>
and I didn't even have to do any work...
<edwin>
is quicktest the same as quickcheck for Haskell?
<adrien>
could you copy-paste what you had to do? (just copy-paste)
<edwin>
and do you have an URL for quicktest?
<thelema>
excuse me - quickcheck, Ilmari Heikkinen's hack of apparently jane street's clone of quicktest
<thelema>
with the help of some evil ruby (that will be excised as soon as convenient), this comment gets turned into the natural quicktest and hooked into batteries' testing infrastructure
<thelema>
I guess they changed some unicode handling in 1.9
<thelema>
adrien: just filter magic comments from the .ml files to make _t.ml test files
<thelema>
kaustuv: there are some comments with high-ascii characters in batChar.ml
<adrien>
why does that use ruby... wouldn't shell scripting be more suitable?
<adrien>
(and not less portable: both aren't perfect)
<thelema>
adrien: you're welcome to rewrite the build/make_suite.rb file, it's less than 200 lines, and doesn't seem to use any external libraries
srcerer has quit [Read error: Connection reset by peer]
<adrien>
reading regular expression in ruby :-)
srcerer has joined #ocaml
<thelema>
I guess I shouldn't be surprised it's buggy, considering how it uses regexes
<adrien>
does it handle new lines in the middle of the comment? (faster to ask than to read a regexp)
<thelema>
yes
<thelema>
the bug is that if there's a newline right after (**T, it eats the first test
<adrien>
so, we'd want something in ocaml?
<adrien>
bah, must make food quickly and go out
<thelema>
adrien: yes, ocaml would be great
<thelema>
it's mostly string manipulation - it could probably be done using String.find
<adrien>
what about (* (* ... *) *), what should be the result?
<adrien>
well, that one isn't an issue I guess but I think that the ruby code might be a bit loose
<adrien>
so we'll probably want to have a "better" definition of when to execute something and when not to
<thelema>
as long as the code already in batteries stays working, define it as you like.
<thelema>
you may even be whitespace-sensitive
<adrien>
won't be able to spend time on that before saturday I think however
<thelema>
if someone beats you to re-implementing it, you won't get any geek-cred for the accomplishment
<thelema>
:)
<adrien>
;p
<thelema>
actually, best would be to write it as an ocamlbuild plugin
<thelema>
I think...
<thelema>
although maybe just migrating the build rules from Makefile to ocamlbuild would suffice, even if using an external program to generate the tests
<kaustuv_>
a real manly programmer would use BatParserCo
<kaustuv_>
(which would parse the ocaml, then throw away all but the comments, of course...)
<thelema>
of course :)
<thelema>
monads + functors.
<kaustuv_>
I don't know about the rest of you, but whenever I look in the src/ directory I can't help starting to hum the batman cartoon theme
<kaustuv_>
clearly I need to write a library for mobile code and put it in batMobile.ml
<adrien>
I say "baaaaaaaaatmaaaaaan" in my head instead ;-)
<adrien>
yeah, waiting for batmobile too ;-)
ulfdoz has joined #ocaml
<thelema>
batArang.ml - library for arranging values
<mrvn>
batCave.ml?
<thelema>
hcarty: can you find the patch to fix the types in the toplevel again? Your link doesn't go to a specific patch
<thelema>
hcarty: unless it's this first patch
_andre has quit [Quit: leaving]
<hcarty>
thelema: IIRC, it was the patch in the link I provided
<hcarty>
thelema: Let me check...
<thelema>
hcarty: found it, it was the first patch in the list you linked to
<hcarty>
thelema: Ok, cool. Sorry - I thought I had linked to the patch directly
<thelema>
hcarty: got it. thanks for digging that up and testing it.
cyanure has quit [Ping timeout: 255 seconds]
<hcarty>
thelema: You're welcome. It's too bad there isn't a cleaner solution, or at least a known cleaner solution.
drunK has joined #ocaml
jm has quit [Ping timeout: 240 seconds]
sandmann has joined #ocaml
<sandmann>
i have a recursive function which is supposed to put elements from left to the right into a list, put somehow its the wrong way
<mrvn>
you can only (without cheating) add elements to the front of a list
<sandmann>
my function takes two elements the first is the element to be analysed and the second one is a accumualtor in form of c@[x]
<mrvn>
Use List.rev at the end
<mrvn>
Never use @ in a recursive function
<sandmann>
i have to solve it without using that function
<mrvn>
"have to"?
<sandmann>
my boss said
<mrvn>
If you use @ instead of List.rev then your runtime is O(n^2) instead of O(n)
Yoric has joined #ocaml
<mrvn>
you seriously want to use x::c and List.rev that at the end if needed.
<sandmann>
no list.rev
<mrvn>
is your list the wrong way around with c@[x]?
<sandmann>
yes
<mrvn>
then simply using x::c makes it the right way around. problem solved
jm_ocaml has joined #ocaml
<sandmann>
x::[c] ?
Snark has quit [Quit: Ex-Chat]
<sandmann>
or is it [x]::c?
<sandmann>
and another troubling point is, i have a constructor node = int, how can i access the int value
<sandmann>
no one there?
<jonafan>
x::c
<jonafan>
the type of the :: operator is 'a -> 'a list -> 'a list
<jonafan>
(it's syntax though, not an operator)
<jm_ocaml>
sandmann: If you have a data type type n = Node of int, you need to use pattern matching to extract the integer, e.g. match node with Node i -> i.
<sandmann>
thanks jm_ocaml
lpereira has joined #ocaml
thatch__ has joined #ocaml
thatch has quit [Ping timeout: 240 seconds]
thatch__ has quit [Remote host closed the connection]
thatch has joined #ocaml
<mrvn>
type n = Node of int is a bit wastefull though.
strlen has quit [Ping timeout: 240 seconds]
<sandmann>
@ jm_ocaml are you still available?
<jm_ocaml>
sandmann: Sure.
<sandmann>
very good, i have something in form of type node = int
<mrvn>
sandmann: then you just use it. That is still an int
<sandmann>
i thought so but when i apply string_to_int node then it throws an exception
<mrvn>
that isn't a type problem then.
<sandmann>
what if no type problem is it=?
<thelema>
# type node=int let (s : node) = int_of_string "132";;
<thelema>
type node = int
<thelema>
val s : node = 132
<thelema>
sandmann: what string are you trying to convert to an int?
<sandmann>
i have a file with type node = int, which i access through a different file an try, for debugging purposes to convert it to string, via string_to_int but it throws a exception
<mrvn>
how do you convert an int from string to int?
<sandmann>
no i want to convert an in to string via string_to_int
<thelema>
string_of_int?
<sandmann>
doesnt string_of_int converts an int to string?
<mrvn>
no. it does what it says.
<mrvn>
# string_of_int;;
<mrvn>
- : int -> string = <fun>
<sandmann>
yes#
<mrvn>
given the signature a int_to_string would be more logical.
<mrvn>
But ocaml does "of" functions usually.
<sandmann>
i am back in 15 minutes if thats okay
<mrvn>
I'm going to bed so do whatever you like. :)
<sandmann>
thanks anyway :)
kani has quit [Remote host closed the connection]
ulfdoz has quit [Ping timeout: 240 seconds]
<thelema>
is there someone running 3.12 and batteries that can check if a bug is fixed for me?
<thelema>
s/for me/for you/
ygrek has quit [Ping timeout: 240 seconds]
edwin has quit [Remote host closed the connection]
joelr has quit [Quit: joelr]
<jonafan>
how are we supposed to work with binary files in ocaml?
<hcarty>
thelema: What's the bug?
<hcarty>
jonafan: Bigarray can mmap files?
<hcarty>
jonafan: Bitstring if you need more detailed support
ikaros has quit [Quit: Leave the magic to Houdini]
<jonafan>
i was going to write a wave file wrapper
<jonafan>
er not wrapper, something to read/write wave files
<synod>
Can you not unify existential types inside of object types?
<synod>
the class type is actually just a wrapper around a javascript object which doesn't propagate its type information up into ocaml
<synod>
is there a way to declare something like a type wildcard in this case?
<synod>
I thought that's what the existential quantification was supposed to do but I guess it needs to ground whatever you put into the quantified type variable?
<hcarty>
thelema: Ah, ok. I may not be able to test today, but I'll hopefully be able to tomorrow.
<thelema>
hcarty: no problem. I'm kinda done hacking on batteries for the moment
<thelema>
there's a ton of changes that have happenned today - please update and test
<hcarty>
thelema: I have a self-patched Batteries which I was testing against, and it does fix the bug there
<hcarty>
thelema: I can test in more detail tomorrow, but it looks like it does prevent Batteries from triggering that bug
<thelema>
yay.
<thelema>
I hope I can bring the majority of peoples' batteries patches into the mainline
<thelema>
I kind of approve of batteries patches, as they're a way for batteries to grow
<jonafan>
does batteries have something for working with binary data?
ymasory has joined #ocaml
<jonafan>
bitstring looks nice but it doesn't look like you can use it for writing
<sandmann>
hey, can someone explain me the difference between node = int and node = of int?
<jonafan>
Node of int?
<sandmann>
was it wrong?
<jonafan>
yes, i don't think node = of int is a thing
<sandmann>
okay i have type node = int
<sandmann>
but than i cant make string_of_int node?????
<jonafan>
you can in most cases
<jonafan>
if you're using the module system to hide the representation of node, it will result in a type error
<jonafan>
if you do "type node = Node of int", it will also result in a type error
<sandmann>
okay type node = int is in a different file then the one i am using so how can i work around that problem?
ftrvxmtrx has quit [Ping timeout: 276 seconds]
<jonafan>
well, i don't think that's your problem
<jonafan>
type node = int doesn't really do anything but possibly make code more readable
<jonafan>
accessing functions from another file depends on how you're running your code
<sandmann>
could you explain that more probably=
<sandmann>
?`
<jonafan>
what is the file with type node = int?
ftrvxmtrx has joined #ocaml
<jonafan>
ocamlc -c thatfile.ml
<jonafan>
then accessing those functions would be Thatfile.aFunction
<jonafan>
i need to go now, cya
<sandmann>
okay, i really apppreciate your efforts, thanks a lot
<hcarty>
thelema: Does it make sense to provide .seq (and possibly .of_seq) functions in Batteries? Enum is nice, but the consumtion of Enum.t values can give surprising results at times.
<thelema>
jonafan: batteries has nice functions for writing various binary values
<hcarty>
thelema: Of course, the lack of consumption on Seq.t values could certainly be surprising as well
<thelema>
jonafan: but not quite like bitstring
fraggle_ has quit [Read error: Connection reset by peer]
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
<thelema>
hcarty: It's not unreasonable to provide *.seq and *.of_seq for those situations where enum isn't appropriate
Edward__ has quit [Read error: Connection reset by peer]
lpereira has quit [Quit: Leaving.]
synod has quit [Quit: Page closed]
<eaburns>
sandmann: still having issues with type node = int?
<sandmann>
yes....
<sandmann>
it really bothers me....
<eaburns>
can you explain your problem in more detail? My understanding is that you are getting an exception when converting a string to an int