<flux>
why as syntax extension? for getting nice types out of it?
<flux>
I'm not sure perl pack/unpack is better than the regular unparsing technique (using composing)
avsm has quit [Ping timeout: 240 seconds]
Yoric has joined #ocaml
avsm has joined #ocaml
djcoin has joined #ocaml
avsm has quit [Ping timeout: 252 seconds]
larhat has joined #ocaml
avsm has joined #ocaml
<pippijn>
flux: getting nice types out
<pippijn>
flux: and having short code
K_F has quit [Ping timeout: 272 seconds]
testcocoon has quit [Quit: Coyote finally caught me]
ontologiae has joined #ocaml
<Kakadu>
hey
<flux>
pippijn, but, syntax extensions.. I bet after learning camlp4 everything starts to look like a nail?-)
<Kakadu>
I've installed xml-light with opam but there is no META file in installation and ocamlfind doesn't see xml-light. It is bug or feature?
* Kakadu
thinks that it's bug
testcocoon has joined #ocaml
avsm has quit [Ping timeout: 252 seconds]
<flux>
I used to use xml-light as well, but after learning that it uses Obj.magic, I started to prefer xmlm :/
<flux>
even though xmlm's interface isn't quite as simple for simple tasks
<flux>
actually now that I revised the code, it looks to me it wouldn't perhaps even need them with some additional type annotations in a separate module or something..
lolcategory has joined #ocaml
<Kakadu>
So, it seems that just there is no META file in xml-light tarball used by opam. Where is supposed to report this?
<Kakadu>
found
avsm has joined #ocaml
<adrien>
Kakadu: but xml-light is not updated anymore
<Kakadu>
I have seen xml-light with META file
<adrien>
3rd-party addition
<Kakadu>
what else I should use with js_of_ocaml?
avsm has quit [Ping timeout: 252 seconds]
<Kakadu>
okay, I'll try tyxml
testcocoon has quit [Quit: Coyote finally caught me]
lolcategory has quit [Ping timeout: 245 seconds]
avsm has joined #ocaml
testcocoon has joined #ocaml
<Kakadu>
pfff, my mind is confused
<Kakadu>
I'm coding a chain of async http actions. Argument of next element depends on previous result
<Kakadu>
if error occures I should write about it
<Kakadu>
So, it looks like a classic example of Maybe monad
<Kakadu>
Hence, I shoud use Lwt monad prametrized by Maybe monad?
<Kakadu>
ah, exceptions
lolcategory has joined #ocaml
lolcategory has quit [Ping timeout: 240 seconds]
<pippijn>
flux: I love it
<pippijn>
flux: I love domain-specific languages and syntax extensions
<pippijn>
flux: providing additional semantics and constraints in code allows for domain-specific optimisations
djcoin has joined #ocaml
chambart has quit [Ping timeout: 246 seconds]
<pippijn>
flux: right now, unpack is reasonably efficient, but it could be better
<pippijn>
flux: if I optimise unpack, all the code that uses it will benefit
Enjolras has joined #ocaml
andreypopp has joined #ocaml
andreypopp has quit [Ping timeout: 252 seconds]
avsm has quit [Quit: Leaving.]
andreypopp has joined #ocaml
gustav__ has joined #ocaml
gustav__ has quit [Remote host closed the connection]
gustav__ has joined #ocaml
chambart has joined #ocaml
chambart has quit [Ping timeout: 246 seconds]
chambart has joined #ocaml
avsm has joined #ocaml
andreypopp has quit [Quit: sleep]
Kakadu has quit [Quit: Konversation terminated!]
chambart has quit [Ping timeout: 246 seconds]
avsm has quit [Ping timeout: 260 seconds]
Xizor has joined #ocaml
<gustav__>
OCaml/netcgi_apache loads 30M RES memory for Apache 2 module. -.-" When I load batteries, postgresql and netcgi_apache in Apache 2 conf... that's a lot...
djcoin has quit [Quit: WeeChat 0.3.9]
cdidd has joined #ocaml
<gustav__>
I'm not sure what all that memory is used for. I don't think it's for optimizing performance... or anything to that effect... Except maybe not having to load these files on each access.
<gustav__>
Hmm.
avsm has joined #ocaml
avsm has quit [Ping timeout: 246 seconds]
andreypopp has joined #ocaml
mjonsson has joined #ocaml
andreypopp has quit [Quit: sleep]
andreypopp has joined #ocaml
mrm has joined #ocaml
andreypopp has quit [Quit: sleep]
avsm has joined #ocaml
Neros_ has joined #ocaml
avsm has quit [Ping timeout: 252 seconds]
beckerb has joined #ocaml
cdidd has quit [Read error: Connection reset by peer]
cyounes has joined #ocaml
avsm has joined #ocaml
cdidd has joined #ocaml
avsm has quit [Ping timeout: 248 seconds]
andreypopp has joined #ocaml
fraggle_ has joined #ocaml
leoncamel has joined #ocaml
ulfdoz has joined #ocaml
avsm has joined #ocaml
avsm has quit [Ping timeout: 255 seconds]
andreypopp has quit [Quit: sleep]
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
tane has joined #ocaml
tane has quit [Remote host closed the connection]
tane has joined #ocaml
avsm has joined #ocaml
tautologico has joined #ocaml
avsm1 has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
sepp2k has joined #ocaml
andreypopp has joined #ocaml
cyounes has quit [Quit: Lost terminal]
pango has quit [Read error: Operation timed out]
<wieczyk>
mhmh
<wieczyk>
Via first-class module someone can delcare local polymorphic exceptions
<wieczyk>
let f (type t) (x : t) =
<wieczyk>
let module M = struct exception E of t end in
<wieczyk>
raise (M.E x)
<wieczyk>
;;
<wieczyk>
f 1;;
<wieczyk>
Exception: E 1.
<wieczyk>
f "a";;
<wieczyk>
Exception: E "a".
<wieczyk>
Cool.
Yoric has quit [Ping timeout: 246 seconds]
andreypopp has quit [Quit: sleep]
pango has joined #ocaml
emmanuelux has joined #ocaml
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
fraggle_ has quit [Remote host closed the connection]
Break has joined #ocaml
Break has quit [Client Quit]
ontologiae has quit [Ping timeout: 255 seconds]
fraggle_ has joined #ocaml
beckerb has quit [Quit: Konversation terminated!]
emmanuelux has quit [Quit: emmanuelux]
andreypopp has joined #ocaml
<gustav__>
Hey, what's a 'a in this for example: val camlbox_send : camlbox_sender -> 'a -> unit
<gustav__>
I thought it was anything but it wasn't.
Xizor has quit [Quit: So yes it's mIRC under wine under debian double peche capital. ;) I'll soon see in kfreeBSD.]
<gustav__>
It's over...
<gustav__>
Not under...
<gustav__>
Debian runs in the bottom...
<gustav__>
Unless he's done something crazy. O_O
larhat has quit [Quit: Leaving.]
jamii has joined #ocaml
<gustav__>
If 'a is some type of catch-all, why doesn't it like 1 or 3 or 2?
<_habnabit>
gustav__, define "doesn't like"
<gustav__>
I did something bad.
<gustav__>
I misread the declarations.
Xizor has joined #ocaml
<Enjolras>
gustav__: i don't understand your issue question :/
eikke has joined #ocaml
<flux>
wieczyk, nice, but can you catch them?
<wieczyk>
of course not ;]
<wieczyk>
and probably no one is producing a big function where it is practical to declare local module and use some exception, it would be very bad code.
<wieczyk>
So this trick is useless probably ;]
<flux>
well, it's sometimes nice
<flux>
for example, if you want to 'early bail-out' from List.fold_left
<flux>
and your value is polymorphic on input
<flux>
but what I'm surprised about is that it doesn't produce an error
<flux>
of an exception escaping the scope of the module..
<flux>
I think there are some related errors
<gustav__>
Uhm. What does this mean 'Failure("Netsys_mem.init_value: Library error")?'
andreypopp has quit [Quit: sleep]
leoncamel has quit [Remote host closed the connection]
<flux>
probably Netsys_mem module's init_value function has a line failwith "Library error" :-)
<flux>
I guess you could file a bug report or look at the source
<gustav__>
Eeh. Hm.
<gustav__>
{v=3} was okay but not 3.
<gustav__>
I guess it was trying to allocate a structure of that value and 3 has no structure I guess...
mye_ has joined #ocaml
<flux>
a good guess. maybe a better error would be nice.
<flux>
you're trying out Netsys_mem for the first time or do you already have experience with it? (I haven't touched it yet)
<gustav__>
Yeah... maybe. But that stuff goes out to the Internet, so,... but Idk. Not this time it didn't.
<gustav__>
Yes, well, not directly. I'm trying Netcamlbox.
<gustav__>
It works now. I was able to send {v=3}. Or that style.
<gustav__>
1 message in the box. :3
<gustav__>
Now I'm going to fetch it.
<gustav__>
Or get it.
<wieczyk>
flux:
<wieczyk>
18:09 < flux> but what I'm surprised about is that it doesn't produce an error
<wieczyk>
18:09 < flux> of an exception escaping the scope of the module..
<wieczyk>
18:09 < flux> I think there are some related errors
<wieczyk>
Maybe becuase the type 'exp' is open for new definitions.
leoncamel has joined #ocaml
<wieczyk>
You always can exception, it is just value of typ exn
mye has quit [Ping timeout: 240 seconds]
mye_ is now known as mye
<wieczyk>
you only cannot do always pattern matching.. you cannot match not-yet-defined values for exn and .. as we can see from ,,anonymous'' modules.
<wieczyk>
You always can catch an exception*
ontologiae has joined #ocaml
eikke has quit [Ping timeout: 255 seconds]
<gustav__>
Even though I do $ ocaml unix.cma str.cma bigarray.cma pcre/pcre.cma threads/threads.cma netsys/netsys_oothr_mt.cma netsys/netsys.cma netcamlbox/netcamlbox.cma. I get # open Netcamlbox;;
<gustav__>
Error: Unbound module Netcamlbox.
<gustav__>
The first $ is bash...
<gustav__>
Annoying...
<gustav__>
I got the value from the box, but that was in the same script. Now I want to check the box from the command line.
<flux>
gustav__, you need some -I there as well
<gustav__>
Neat trick, if it works.
<gustav__>
Aha.
<flux>
gustav__, "Unbound module" errors come from not finding the .cmi-files
<flux>
it cannot find netcamlbox.cmi, specifically
<flux>
btw, I think many (like me) would prefer to use ocamlfind instead of typing out all that..
<gustav__>
Oh. Right...
<gustav__>
That's a bit different from C/gcc for instance... ehm...
<flux>
although, it doesn't running toplevel directly
<gustav__>
Nah. ocamlfind doesn't work with ocaml, right? It works with the compilers.
<flux>
(assuming you can the associated ocamlfind toplevel module loaded with #use "topfind";; in your ~/.ocamlinit)
<gustav__>
Oh...
<wieczyk>
Draft F# Component Design Guidelines
<wieczyk>
is interesting.
<gustav__>
Hurr...
<flux>
after that it's easy :)
<flux>
you can even stick that+other stuff on your local .ocamlinit and everything works automatically for your project
<flux>
possibly even #load other files..
<flux>
(that #use_mod orwhateveritwascalled recently on the mailing list was pretty interesting, btw)
<gustav__>
That stuff should already be in some system init file... This is Ubuntu...
<flux>
well, ocaml has this approach of not force feeding anything, I think :)
<gustav__>
Well... maybe it SHOULDN'T be... but.
<gustav__>
Yeah.
<flux>
btw, while you're at it, I hope you use rlwrap or ledit?-)
<gustav__>
No...
<flux>
(or utop)
<gustav__>
Bonking away with vim.
<flux>
if not anything of those, please sudo apt-get install rlwrap; and then rlwrap ocaml
<flux>
you get command line editing.
<flux>
hmph, debian unstable doesn't have utop, sad..
jamii has quit [Ping timeout: 246 seconds]
<flux>
gustav__, hmm, you use ocaml toplevel from within vim?
<flux>
(I didn't know it was possible, just wondering0
<gustav__>
I don't know what that is but if you mean "$ ocaml" then I think so. I can't remember how to run that in a window, but... hmz. I usually start a shell in vim and do things or just keep another window for those things. I'm in X.
<flux>
ok
<flux>
I was wondering if you have an easy way to 'send' stuff from vim to ocaml
<flux>
other than #use "file.ml"
<gustav__>
I should find out but most of the time after I set up those kinds of things my computer or distribution crashes so then I'm back to basic, i.e. not having it.
<flux>
but I guess not
<gustav__>
No.
<gustav__>
Maybe I could set up a netcamlbox and send it through there... but... no... hmm... I don't know how to start threads for listening to that in ocaml toplevel, as you say.
<flux>
an 'rlwrap' variant thing that could accept data from a socket would perhaps be more generic and easier to implement
<gustav__>
There's no way of checking if a camlbox is open except catching an exception.
<gustav__>
I should already know, right?
<flux>
possibly, I haven't used those
<gustav__>
It seems to be a UNIX socket, so I could check for it, but that's breaking the abstraction...
<gustav__>
Hmmm.
<wieczyk>
btw: F# has nice extension for ML records, the members.
sepp2k1 has joined #ocaml
sepp2k has quit [Ping timeout: 240 seconds]
<gustav__>
lol. It crashed.
jamii has joined #ocaml
<gustav__>
How do I cast a value to a type? I should know this, right?
<flux>
("helo" : string)
<flux>
it doesn't really cast anything, though
<flux>
rather lets you tell what a polymorphic type is or otherwise the compiler checks that it is indeed of the given type
<flux>
if you don't have polymorphic variants or objects, you don't probably need to do (up)casting, which would be (foo :> bar)
<flux>
in the very extreme you can use Obj.magic to interpret values to be of any other type. danger: segmentation faults lie this way :)
<gustav__>
# (r : sv);;
<gustav__>
Error: This expression has type 'a but an expression was expected of type sv
<gustav__>
The type constructor sv would escape its scope
<gustav__>
r is possibly more than a sv, so it doesn't want to?
<gustav__>
Eh...
<gustav__>
r is some data coming from a send... but I guess the type information doesn't come along.
<gustav__>
r is indeed sv, but not that name, but the same record type. On the sending side.
<gustav__>
So it should work.
<gustav__>
# r;;
<gustav__>
- : '_a = <poly>
<gustav__>
When I did r.[0] r changed type to string. :)
<gustav__>
LOL. Now it thinks camlbox_get returns string:s.
<gustav__>
Can't I convince it it's my record type? :)
mjonsson has quit [Read error: Connection reset by peer]
mjonsson has joined #ocaml
SanderM has joined #ocaml
<wieczyk>
btw; what do you think about SML's val/fun, when compared to ocaml let/rec?
SanderM has quit [Remote host closed the connection]
SanderM has joined #ocaml
SanderM has quit [Client Quit]
SanderM has joined #ocaml
emmanuelux has joined #ocaml
ontologiae has quit [Ping timeout: 252 seconds]
<gustav__>
# r.value_to_send;;
<gustav__>
Error: Unbound record field label value_to_send
<gustav__>
How can it know that?!
<gustav__>
r is a <poly>.
Yoric has joined #ocaml
<wieczyk>
Because name of the field is not part of value.
<wieczyk>
It is only a syntactical concept.
<gustav__>
But a <poly> then can have any field name.
<wieczyk>
So he does not do any lookup-at-runtime for field named ,,value_to_send''.
<wieczyk>
No.
<wieczyk>
<poly> is a value of unknown type (any type).
<gustav__>
But I can't set a <poly> value to a typed variable.
<gustav__>
That's weird?
<wieczyk>
You need to seperate two important things.
<wieczyk>
The syntactical concept of record and its representation.
<wieczyk>
It is very similar to C
<wieczyk>
When you declare record then compiler allows you to use named fields
<wieczyk>
but he is seeing them as some offset in memory
<wieczyk>
so field-map is not stored in record.
<wieczyk>
If you have value p = <poly>
<wieczyk>
and you want to use some field 'fld' then you need to declare type with this field
<wieczyk>
type record_with_fld = { fld : int };;
<wieczyk>
Now compiler understand the field 'fld' and I am sure you can use it.
<wieczyk>
I am telling bullshit?
<wieczyk>
I will check it empirical :d
<gustav__>
I think I tested that. It doesn't work.
<gustav__>
I did. let (a:record_with_fld) = p;; and it farts.
andreypopp has joined #ocaml
SanderM has quit [Read error: Operation timed out]
<wieczyk>
For me it works.
<wieczyk>
Maybe you change type somewhere
<wieczyk>
I did:
<gustav__>
Did you run it interactively or in a script?
<wieczyk>
# let aspoly e = let mem = Marshal.to_string e [] in Marshal.from_string mem 0;;
<wieczyk>
val aspoly : 'a -> 'b = <fun>
<wieczyk>
# let v = aspoly 1;;
<wieczyk>
val v : 'a = <poly>
<wieczyk>
Here I have value 'v' which is poly.
<wieczyk>
# type r = { fld : int };;
<wieczyk>
# v.fld;;
<wieczyk>
It break interpreter but we were interested to check if typechecker reject tis program.
<wieczyk>
If course it was not rejected but go through infinite loop until stack end. Interesting why.
<gustav__>
It began to think v, the foreign value, was a string. I did v.[0] and could read it as a string.
<gustav__>
Then it said it was a string.
<wieczyk>
if you do (v + 0) then it will start to think that v is integer
<wieczyk>
mabe we try annotation in another place
<wieczyk>
try this
<wieczyk>
let v = camlbox_get b 0
<wieczyk>
let rv : unit -> int = fun () -> v
lolcathost has joined #ocaml
<wieczyk>
does it forces the type of v?
<gustav__>
Yes.
<wieczyk>
cool
<wieczyk>
let v = camlbox_get b 0
<wieczyk>
let rv : int = v
<wieczyk>
this?
<gustav__>
Wait.
<gustav__>
I'll try with my record type, now.
<wieczyk>
ok
<gustav__>
Hm. Nope.
<gustav__>
Ok wait.
<wieczyk>
(Value restriction is not perfect, sometime it rejects good programs, but it is nature of type systems.. it rejects all bad program (due to some rules) and some good programs.
tautologico has quit [Ping timeout: 245 seconds]
<gustav__>
# let v = camlbox_get b 0;;
<gustav__>
val v : '_a = <poly>
<gustav__>
# let rv : int = v;;
<gustav__>
val rv : int = 69859011819652
<gustav__>
Well...
<wieczyk>
so works.
<gustav__>
Yes, but not to a record.
<wieczyk>
you casted value to int so it is not a record but int.
tautologico has joined #ocaml
<gustav__>
Yes.
<wieczyk>
let rv : your-record-type = v
<gustav__>
Error: This expression has type int but an expression was expected of type mu
<gustav__>
The type constructor mu would escape its scope
<gustav__>
v is the int.
<wieczyk>
yes... because your '_a is instantaited
<gustav__>
Yes.
<wieczyk>
declare v again
<gustav__>
It thinks camlbox_get returns an int now. Have to restart the whole thing if it's to go back to '_a.
<wieczyk>
did you defined v again?
<wieczyk>
let v = ...
<wieczyk>
?
<gustav__>
Yep.
<gustav__>
It's int directly.
<gustav__>
# let v = camlbox_get b 0;;
<gustav__>
val v : int = 69859011819652
<wieczyk>
could you type camlbox_get
<wieczyk>
and show me the interpreter result
<gustav__>
# camlbox_get;;
<gustav__>
- : 'a Netcamlbox.camlbox -> int -> 'a = <fun>
<gustav__>
# let t = camlbox_get b 0;;
<gustav__>
val t : int = 69859011819652
<gustav__>
It says it returns an 'a but it returns it instansiated.
<wieczyk>
weird.
<wieczyk>
it has 'a in type.
<gustav__>
Well, yes, I guess it makes sense but it's annoying.
Submarine has joined #ocaml
<gustav__>
Yes. But it actually is '_a, so, that information is not correct.
<wieczyk>
Where is '_a ?
<wieczyk>
Hm
<gustav__>
Nowhere from now on. It was v.
<gustav__>
Before:
<gustav__>
# let v = camlbox_get b 0;;
<gustav__>
val v : '_a = <poly>
<wieczyk>
Maybe you find some error in typechecker, because comlbox_get has normal polymorphic type.
<gustav__>
No idea.
<wieczyk>
Restart interpreter
<gustav__>
I think I am doing something wrong...
<gustav__>
Ok.
<gustav__>
Ok, done.
mye_ has joined #ocaml
<wieczyk>
;]
<wieczyk>
let v = (camlbox_get b 0 : int)
<gustav__>
Yep.
<wieczyk>
Works?
<gustav__>
Yes.
<gustav__>
It's an int.
<wieczyk>
type t = { test : int }
<wieczyk>
let v2 = (camlbox_get b 0 : t)
<wieczyk>
accepted by type system?
<gustav__>
YAY!
<gustav__>
# let v2 = (camlbox_get b 0 : t);;
<wieczyk>
;]
<gustav__>
val v2 : t = {test = 3883}
<wieczyk>
;]
<wieczyk>
So all works, we see that
<gustav__>
Uhm.
<wieczyk>
you need to annotate the result of camlbox_get
<gustav__>
Wait...
<gustav__>
I sent a record, but got an int?
mye has quit [Ping timeout: 246 seconds]
mye_ is now known as mye
<gustav__>
Oh. Right. No.
<wieczyk>
;]
<wieczyk>
The type in Ocaml is purely syntactical concept. It is erased on representation so you decide when using camlbox_get what did you get.
<gustav__>
I see...
<gustav__>
It's so cool this works. xD
<gustav__>
Netcamlbox is neat.
<wieczyk>
I did not use it yet.
<gustav__>
Easy to use.
<wieczyk>
I have not used this yet*.
<wieczyk>
Good to hear, I will check it.
<gustav__>
I send from a .cma running over the apache module.
<wieczyk>
To be honest, what are you doing now
<pippijn>
what's netcamlbox?
<pippijn>
or camlbox?
<gustav__>
Part of the netcgi2 package... I think. No. Ocamlnet.
<wieczyk>
is violating a type system.
<gustav__>
That's not good...
<wieczyk>
So not be weird that you need to annotate something and you are responsible to give a good annotations.
<pippijn>
what does it do?
<gustav__>
I think the type system seems ambiguous.
<pippijn>
that's a bold statement
<Qrntz>
heh what
<wieczyk>
pippijn: He is working with marshaling data, sending it via network and unmarshaling on client-side.
<pippijn>
wieczyk: I wrote something for that
<pippijn>
type-safe
<gustav__>
pippijn: Apache 2 module, for serving HTML/HTTP, interpretation of HTTP requests and QUERY_STRING/CGI. And an HTTP Client.
<wieczyk>
How can you do something type-safe when marshaling data?
<pippijn>
wieczyk: you need to do it manually
<pippijn>
or generate it
<gustav__>
wieczyk: I am just testing this. Looking to set up some kind of system to process SQL requests from web server "clients," i.e. hosts who want to share a connection to the SQL server...
<gustav__>
But I wasn't marshalling anything.
<pippijn>
wieczyk: biniou, json, sexp
<gustav__>
The resulting code is quite small. I think.
<pippijn>
or using my newly implemented pack/unpack :)
<wieczyk>
gustav__: the camlbox need to do this self
<wieczyk>
(nice module bitmatch)
<pippijn>
bitmatch is nice
<pippijn>
but too verbose for my purposes
<gustav__>
let v : mytype = camlbox_get b 0;; <- Doesn't work or ever set the correct type. However this does -> let v = (camlbox_get b 0 : mytype);; <- TOTAL: the type interpretation is broken. I've done this myself on occasion in some interpreters... for my custom languages.
<gustav__>
Can't do it on l-side, but works on r-side.
<gustav__>
Netcamlbox contains things. I don't have to worry about that...
A_85 has joined #ocaml
<pippijn>
ok
<pippijn>
use it :)
<pippijn>
I'm just advertising my latest project
<gustav__>
I don't think any of these things will let me move a socket between threads/processes though. o_O
<pippijn>
no, that has nothing to do with marshalling
<pippijn>
but why do you want to do that?
<pippijn>
what are you working on?
<gustav__>
I want to keep one socket and let others copy and use it. Okay, that sounds really, really stupid.
<gustav__>
Well, some kind of high performance site. Website.
<gustav__>
Or package/framework for building such sites.
<gustav__>
I'm trying to move from PHP. :)
<pippijn>
website?
<gustav__>
Yes.
<pippijn>
I don't understand.. why do you need to move around sockets in a web server?
<Qrntz>
I would guess to impress visitors
<gustav__>
10000 concurrent HTTP port outgoing connections. That would mean 10000 sockets for the postgresql... If I could get it to 1, that would be better. They would be doing the same queries.
<pippijn>
what?
<gustav__>
With small differences.
<pippijn>
that doesn't make sense
<pippijn>
do you have 1 process per connection?
<pippijn>
you don't need more than 1 process per CPU, really
<gustav__>
Trying to make it so 50 connections can be on one process and share 1 connection to the DB.
<gustav__>
Something like that.
<pippijn>
why 50?
<pippijn>
why not 1000?
<gustav__>
The DB doesn't like to have 50 connection.
<gustav__>
Well, those are ratios.
<gustav__>
s/connection/connections/
<pippijn>
one process can have 1 listening socket and 1 connection to the DB
<pippijn>
if you have 8 CPUs (or logical cores) you can have 8 processes
<pippijn>
anything more doesn't make sense
<gustav__>
One idea is to have central Netcamlbox and send commands to that, like, lightMyBedLight or getAccountBalance, and it stays synchronized with the DB. I haven't really came up with any other idea.
<gustav__>
Right.
<pippijn>
ok
<pippijn>
I don't see the need for IPC in a web server
<gustav__>
Many connections can want that information and it's not necessary to read it from the DB. But sure, the DB could probably handle it some way... but IDK... just an idea.
<pippijn>
I think you're heavily over-engineering it
<gustav__>
A DB is easier to maintain than plain text files and OCaml programs writing to text files. It offers better data security. And manageability.
<pippijn>
yes
<pippijn>
you still don't need IPC to access a DB
<gustav__>
The step inbetween can offer business abstraction so to speak.
<pippijn>
oh boy
<gustav__>
Yeah, maybe I don't need that.
mrm has quit [Ping timeout: 264 seconds]
<gustav__>
Thing is, you can put funny things in there. Plumbing.
<pippijn>
plumbing? is that another buzzword I don't know?
<gustav__>
It's simply an abstraction, so.
<gustav__>
I think it's UNIX-speak.
<gustav__>
Pipes and all of that.
<pippijn>
ok
<pippijn>
sounds pretty fancy, all of this
<gustav__>
I don't really have a target with this, so...
<pippijn>
what are you doing?
<pippijn>
why don't you just write a simple web server and continue from there?
<gustav__>
I think generally business abstraction makes things clearer and easier to think about, when you're thinking about objectives. Business statements are simply: User A should be able to turn on User B's night stand lamp. So then there's a function called userATurnOnBsLamp.
<gustav__>
Apache 2 is fine.
<gustav__>
Or, Apache.
<gustav__>
It's stable and works.
<gustav__>
And writing that takes time. More parsing.
<gustav__>
Of text.
<gustav__>
Blargh.
<gustav__>
Not very fond of that.
<gustav__>
HTTP is a boring protocol.
<pippijn>
okay
<pippijn>
so you already have a http server
<gustav__>
Yep.
<pippijn>
okay, then what are you doing?
<gustav__>
Burning through valuable time.
<pippijn>
ok
<pippijn>
I'm out then, you can do that without me
<pippijn>
if you want to accomplish a goal, you can ask
<gustav__>
Well, I thought I'd make some kind of business intelligence interface, but, I have to make sure connection to the DB is safe... or doesn't overload the DB or something. But I think maybe I can just change parameters in the DB.
<gustav__>
With this, I mean business intelligence something like keeping track of personal relations. For instance, when you want to do something, who/which ones of your friends have the necessary resources. If you want to move, from your apartment, for instance. Or, go on a holiday. Who might be interesting to chose, at this or that time.
<pippijn>
I took one BI class years ago
<gustav__>
But I don't know if it's allowed to store that kind of information, like how many cars some person owns, in Sweden, where I live and keep my computers.
<pippijn>
and you lost me
<gustav__>
BI is just extracting some variable to a usable statement.
<pippijn>
I built up a natural resistance against BI
<pippijn>
gustav__: I know.. but I'm not interested :)
<gustav__>
Like 100, that means I have 100 dollar and that can be used to buy a bike.
<gustav__>
xD
<pippijn>
I'm going to look at some generated code now
<gustav__>
That's weird. I thought everyone liked it.
<gustav__>
xD
<pippijn>
much more fun
<gustav__>
Code is BI. ;)
<gustav__>
Did I ruin it for you? ;)
<gustav__>
:D :D
<pippijn>
enterprise service bean
<pippijn>
bus
<gustav__>
Aah. That's fun.
<gustav__>
xD
<pippijn>
(just throwing in some more buzz)
<gustav__>
Problem is that makes you think of Java, and that's not a whole lot of fun.
<gustav__>
Yeah.
<pippijn>
I should add some zealotry, too
<pippijn>
but I'm lazy now
<gustav__>
Lazy evaluation. There's a buzz word for ya.
<pippijn>
Lazy.force pippijn
<gustav__>
I'm really just trying to have some fun with OCaml but all this Oracle BI spam on Facebook keeps me thinking of that instead.
<gustav__>
I thought I might make a web game. And that needs DB and maybe some kind of not DB stuff behind it.
<pippijn>
if you're interested in BI, then go for it
<gustav__>
Yeah.
<pippijn>
I think ocaml is a good language for the heavy data processing you need to do for BI
<gustav__>
Now I told all my secrets to this channel so I don't have to do anything. I just watch some of you making this instead of me and making all my money. -.-"
<pippijn>
oh no
<pippijn>
definitely not
<pippijn>
I'm a compiler nerd
<gustav__>
Yep. I think so too. I wasn't really expecting that, and I think, but, that optimizing in OCaml would be hard. I can't really change what native code will execute. This Apache 2 module I'm using never compiles to native, anywhere I can see, even.
<gustav__>
I just hope it's fast.
<gustav__>
Well okay.
<pippijn>
oh
<gustav__>
I don't really care about the money, but I want to frickin' create something. :) Everyone else just keeps beating me to it.
<pippijn>
writing efficient ocaml code is sometimes tricky
<gustav__>
I haven't really got a good idea, I think.
<thizanne>
pd
<pippijn>
sometimes counter-intuitive
<thizanne>
sorry
<thizanne>
someone wanted to play with my compute
<thizanne>
r
<gustav__>
xD
<pippijn>
sometimes you think you optimised something but it's slower
<wieczyk>
Some one knowon F#?
Yoric has quit [Ping timeout: 260 seconds]
<pippijn>
but that's true for any language, really
<gustav__>
Yep.
<pippijn>
any language implementation that performs optimisations
<gustav__>
C or rather GCC seems to do a lot of crazy shit.
<pippijn>
perl, too
<gustav__>
wieczyk: Well, I've seen SOME, ... idk, what you want to know... It's C# with bells?
<pippijn>
I found that in ocaml, most of the time, the intuitive way to write something is the fastest way
<pippijn>
maybe it's just me..
<wieczyk>
gustav__: I would like to ask what someone who is ML programmer think about it (F# is very very similar to Ocaml).
<wieczyk>
gustav__: especially about member-extension to OCaml-records.
<Qrntz>
pippijn, except when the intuitive way involves making lots of copies ;-)
<gustav__>
If it was a real time language it could specify times for everything and the optimizer could optimize for some time that's defined... otherwise it will be on a case to case basis.
<pippijn>
Qrntz: copies of large objects, yes
<gustav__>
"fast" is never defined in gcc, or optimized.
<pippijn>
making copies of small objects is often faster than mutating them
<pippijn>
because caml_modify is a heavy operation
Xizor has joined #ocaml
<gustav__>
for(i=0;i<100;i++) x++; ;;;LET THIS TAKE 200ms <- compiler or system could throw anything at it to keep that dead line. But if it said 2s, it could just do some fancy things or whatever, put it off over the Internet, for instance?
<gustav__>
Send the code in a camlbox and then get the result.
<Qrntz>
pippijn, I'm aware
<gustav__>
wieczyk: Haven't looked at it since before I started looking at OCaml.
<Qrntz>
most objects that are likely to be small are copied by default, but I guess that depends on what you define by «small»
<gustav__>
https://85.226.66.182/~gustav/srm/ <- This is my system for making your friends do things for you. Putting together jobs. It takes some learning to use, though.
<gustav__>
"Social Relationship Manager" = srm.
<wieczyk>
Qrntz: are copied by gcc ?
<pippijn>
Qrntz: 3 words
<gustav__>
That's in PHP, though. The boring language.
<pippijn>
1 header word, 2 data words
<pippijn>
that's small
<gustav__>
wieczyk: I was hoping F# was Fortran, but was disappointed.
<pippijn>
and it's not worth making that mutable for efficiency
<pippijn>
this data structure is probably sub-optimal in ocaml
<pippijn>
Qrntz: yes
<Qrntz>
ah, yes
<Qrntz>
2-field records have the same representation
<pippijn>
yes
<pippijn>
I chose this for simplicity of implementation and transition from Stream
<pippijn>
but I'll change it to be immutable at some point in the near future
<gustav__>
C# has a lot of fancy things for async stuff but it doesn't let you have control. The control in OCaml is incredible.
<gustav__>
F# is closer to JavaScript in that respect, which, really blows.
<gustav__>
JavaScript in Firefox is terrible. "Threads" locking up the entire browser.
<pippijn>
ocaml has fancy stuff for async, too
<pippijn>
Lwt
<Qrntz>
the already mentioned JoCaml
xavierm02 has quit [Quit: Leaving]
<pippijn>
I use Lwt for all I/O things
<gustav__>
Could I make a language extension to use something like let qr = SELECT * FROM table WHERE a = b;;
<pippijn>
gustav__: yes
<gustav__>
Hmm...
<gustav__>
JoCaml looks sane.
<gustav__>
*judging...*
<pippijn>
but you probably want to do
<gustav__>
Granular control, is what I mean.
<Qrntz>
you can make a language extension to do pretty much anything
<pippijn>
let qr b = <:sql<SELECT * FROM table where a = $b$>>
<gustav__>
Yeah...
<pippijn>
using quotations
<Qrntz>
I think there was some Camlp4 thing that allowed you to write shell scripts that compiled to OCaml
<Qrntz>
don't remember the name of it now
<gustav__>
o_O
<pippijn>
language extensions are nice, but more fragile than quotations
<pippijn>
because you are not entirely free to do what you want
<pippijn>
it needs to fit into the rest of the grammar
<pippijn>
in quotations, you just get a string you can parse
<pippijn>
with any parser and any lexer
<gustav__>
I have to like rollback and look at what I want to do...
<pippijn>
I'm using quotations for json
<gustav__>
I just think that would be nice because it would close some exploits and it makes using SQL less tedious. But I don't know what others feel about that.
<gustav__>
netcgi2 seems to have some issues that needs sorting out first, in my perspective. It doesn't handle GET-parameters if the request is a POST. So I can't access GET parameters. Or what they're called.
Yoric has joined #ocaml
<gustav__>
Oh. That's really nice.
<gustav__>
Hmm...
<gustav__>
Pretty complicated.
<gustav__>
But granular, I guess.
<pippijn>
sadly, I need that granularity
<pippijn>
server messages can be in any format
<gustav__>
Usually you like to_json "[1,2,["hello"]]" -> [1,2,["hello"]]...eh, right, it's like the same syntax...
<gustav__>
HMM...
<gustav__>
:(
<pippijn>
they vary wildly
<pippijn>
because they were made to be passed from and to perl
<pippijn>
and in perl you just do
<gustav__>
A JSON object is a record in OCaml?
<gustav__>
Works like it, anyway.
<pippijn>
gustav__: not always
<thizanne>
not really
<gustav__>
JSON objects can't contain code.
walter|r has joined #ocaml
<gustav__>
Not when sent, I think, it usually doesn't, anyway.
<thizanne>
json objects are naturally dynamic, records are static
<pippijn>
json objects can't contain code
<pippijn>
but anyway
<pippijn>
in these server messages, some data comes in as arrays, some as objects
<pippijn>
it depends on what the author felt like on that particular day he designed a protocol element
<gustav__>
{"butt":"crack"} in JSON should become type butt = string;; let v={butt:"crack"};; right?
<pippijn>
hum
<pippijn>
no
<pippijn>
but I guess you mean the right thing
<gustav__>
The other way around.
<gustav__>
let v = {"crack":butt};;
<pippijn>
uhm
<pippijn>
type t = { butt : string } let v = { butt = "crack"
<gustav__>
netcgi2 seems to incomplete and it's too hard to commit to these projects.
<gustav__>
I've written patches before and had people ignore them.
Skolem has joined #ocaml
answer_42 has quit [Ping timeout: 246 seconds]
ontologiae has joined #ocaml
<gustav__>
Netcamlbox looks a bit dangerous, too. After I get 0, messages will go down 1, but/and if I get 0 again, I will get an exception saying the camlbox is empty.
<gustav__>
So I don't know what message is new. If I'm really unlucky I could get 0, delete 0, go for the next, and a new message would appear in 0... I'd have to check the entire range...
<gustav__>
Not transaction safe.
<gustav__>
camlbox_wait works.
<gustav__>
camlbox_wait works to purge the list and doesn't wait if there has been messages inbetween it... or since it was last run.
<gustav__>
Not sure if that's supposed to be the working order...
<gustav__>
It looks to be safe.
<gustav__>
Now I actually have to do something...
tautologico has quit [Quit: tautologico]
lolcathost has quit [Ping timeout: 265 seconds]
lolcathost has joined #ocaml
walter|r_ has joined #ocaml
Skolem_ has joined #ocaml
<gustav__>
Can I make a camlbox available by other users? A group?
walter|r has quit [Ping timeout: 240 seconds]
lolcathost has quit [Ping timeout: 256 seconds]
tautologico has joined #ocaml
Skolem has quit [Ping timeout: 246 seconds]
Skolem_ is now known as Skolem
Skolem_ has joined #ocaml
Skolem has quit [Ping timeout: 245 seconds]
Skolem_ is now known as Skolem
Skolem_ has joined #ocaml
ivan\ has joined #ocaml
Skolem has quit [Ping timeout: 246 seconds]
Skolem_ is now known as Skolem
Skolem has quit [Quit: Skolem]
<gustav__>
I think I'm getting a feel for this now.
Neros_ has quit [Remote host closed the connection]
Xizor has quit [Quit: So yes it's mIRC under wine under debian double peche capital. ;) I'll soon see in kfreeBSD.]
Submarine has quit [Remote host closed the connection]
<gustav__>
That was easy...
<gustav__>
What does "Unix.Unix_error(EAGAIN, "sem_wait", "")" mean?
<gustav__>
camlbox_wait throws it.
avsm1 has quit [Quit: Leaving.]
andreypopp has quit [Quit: sleep]
<gustav__>
Oh. It's already locked.
andreypopp has joined #ocaml
walter|r_ has quit [Remote host closed the connection]
walter|r has joined #ocaml
mcclurmc has quit [Ping timeout: 240 seconds]
mcclurmc has joined #ocaml
TechCel has joined #ocaml
<gustav__>
Well, it works now. I loop until I get a lock. That's probably very bad. But what's worse is I have bunch of camlboxes now. That's doing no good. I hope they disappear when I reboot. :F
lolcathost has joined #ocaml
avsm has joined #ocaml
avsm has quit [Ping timeout: 252 seconds]
<gustav__>
How do I get a microtime of the current time from OCaml?
TechCel has quit []
<pippijn>
gustav__: Unix.gettimeofday
<pippijn>
gives nanotime, I think
<gustav__>
Oh.
wormphle1m has joined #ocaml
<gustav__>
OH.
<pippijn>
ah no
<pippijn>
micro
<pippijn>
sorry
<gustav__>
Hum...
<gustav__>
Need better...
<pippijn>
why?
<gustav__>
I have to create unique names for the camlboxes.
<gustav__>
Time is the only thing I can think of.
<gustav__>
pid is shared.
<pippijn>
and gettimeofday is not good, because..?
<gustav__>
Or is it......
<pippijn>
gustav__: are you using real threads in ocaml?
wormphlegm has quit [Ping timeout: 268 seconds]
<gustav__>
I am compiling with -threads but I am not directly creating any threads.
<pippijn>
indirectly?
<pippijn>
do you need more than 1 camlbox per process?
<pippijn>
(if so, why?)
* pippijn
points at Thread.id
<pippijn>
but I also want to point out that if you're using kernel threads for anything, you're probably doing it wrong
<pippijn>
no matter what you're doing :)
<gustav__>
Using pid made it crash. I have to check it out tomorrow. Technically later today.
<pippijn>
crash?
<gustav__>
I'm not sure how or where or if threads are being created or used.
<gustav__>
Yep. In my program.
<gustav__>
Idk why.
<pippijn>
exception?
|jbrown| has quit [Ping timeout: 246 seconds]
<pippijn>
or hard crash?
<gustav__>
Yep. Empty camlbox.
<pippijn>
ok, that's fine
<gustav__>
I only got hard crashes when I did v() on a v=<poly>.
<pippijn>
makes sense
<gustav__>
I think my camlbox uses threads, I don't know, this program is executed from inside threads, at least...
<pippijn>
# print_endline (Obj.magic 123456);;
<pippijn>
rlwrap: warning: ocaml killed by SIGSEGV.
<gustav__>
Not sure how many calls this function gets, inside this one process.
<gustav__>
Oooo.
<pippijn>
Obj.magic is ('a -> 'b)
<gustav__>
Meh. Now it broke even though I didn't use pids...
<pippijn>
so what's wrong with using the time?
<gustav__>
GF is yelling at me to go to bed so I better do it.
<pippijn>
my girlfriend is 9000km away from me :(
<pippijn>
gustav__: good night
<gustav__>
Well, I can't create two camlboxes with the same name, and when I hold in CTRL+R sometimes the gettimeofday is equal to two requests.
<pippijn>
ah, yes
<gustav__>
Bye. Good night.
gustav__ has quit [Read error: Connection reset by peer]