ched_ has quit [Read error: 101 (Network is unreachable)]
ched_ has joined #ocaml
mishok13 has quit [Success]
alexyk has quit []
alexyk has joined #ocaml
mishok13 has joined #ocaml
vpalle has quit [Read error: 104 (Connection reset by peer)]
ikaros has quit [Read error: 60 (Operation timed out)]
seafood has joined #ocaml
alexyk has quit []
monadic_kid has quit ["Leaving"]
ched__ has joined #ocaml
ched_ has quit [Read error: 110 (Connection timed out)]
ulfdoz has quit [Read error: 60 (Operation timed out)]
alexyk has joined #ocaml
mishok13 has quit [Read error: 145 (Connection timed out)]
willb1 has quit [Read error: 110 (Connection timed out)]
willb1 has joined #ocaml
_JFT__ has joined #ocaml
_JFT__ has quit [Remote closed the connection]
seafood has quit [Read error: 110 (Connection timed out)]
<jli>
let (@@) f x = f x;; that's interesting
_JFT_ has quit [Read error: 110 (Connection timed out)]
ched__ has quit [Read error: 110 (Connection timed out)]
ched__ has joined #ocaml
travisbrady has joined #ocaml
willb1 has quit [Read error: 54 (Connection reset by peer)]
willb1 has joined #ocaml
Alpounet has joined #ocaml
pants2 has joined #ocaml
jamii__ has quit [Read error: 110 (Connection timed out)]
ched__ has quit [Read error: 101 (Network is unreachable)]
ched__ has joined #ocaml
pants1 has quit [Read error: 113 (No route to host)]
jeddhaberstro has joined #ocaml
Alpounet has quit [Remote closed the connection]
Alpounet has joined #ocaml
willb2 has joined #ocaml
willb1 has quit [Read error: 110 (Connection timed out)]
ched_ has joined #ocaml
ched__ has quit [Read error: 110 (Connection timed out)]
jeddhaberstro_ has joined #ocaml
jeddhaberstro has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
seafood has quit []
ched_ has quit [Read error: 101 (Network is unreachable)]
ched_ has joined #ocaml
Alpounet has quit ["Quitte"]
verte has joined #ocaml
seafood has joined #ocaml
ched__ has joined #ocaml
ched_ has quit [Read error: 110 (Connection timed out)]
<thelema_>
jli: I usually use [ let (|>) x f = f x ]
alexyk has quit []
ched_ has joined #ocaml
ched__ has quit [Read error: 110 (Connection timed out)]
jeddhaberstro_ has quit []
ched__ has joined #ocaml
seafood has quit [Read error: 110 (Connection timed out)]
ched_ has quit [Read error: 110 (Connection timed out)]
alexyk has joined #ocaml
seafood has joined #ocaml
alexyk has quit []
ched_ has joined #ocaml
ched__ has quit [Read error: 110 (Connection timed out)]
alexyk has joined #ocaml
alexyk has quit []
alexyk has joined #ocaml
ched__ has joined #ocaml
ched_ has quit [Read error: 110 (Connection timed out)]
jbjohns has joined #ocaml
alexyk has quit []
Associat0r has joined #ocaml
<flux>
thelema_, not quite the same thing. do_majik @@ function "a" -> 42
willb2 has quit [Read error: 104 (Connection reset by peer)]
willb2 has joined #ocaml
angerman has joined #ocaml
sporkmonger has quit []
seafood has quit []
ched__ has quit [Read error: 101 (Network is unreachable)]
ched__ has joined #ocaml
mishok13 has joined #ocaml
bernardofpc has joined #ocaml
<bernardofpc>
hello
<bernardofpc>
I have seen the example type 'a listf = Val of 'a | Func ('a -> 'a) * 'a listf
<bernardofpc>
I would have like the same, but for the "true" coomposition, that is
<bernardofpc>
type 'a listf = Val of 'a | Func ('b -> 'a) * 'b listf
<bernardofpc>
but ocaml says "unbound parameter 'b"
<flux>
and this is not a solution for you? type ('a, 'b) listf..
<bernardofpc>
do you have any ideas how to make such a list of compatible functions ?
<flux>
there is one way to express the type, but I don't think it's going to be helpful for you at all
<bernardofpc>
but then which type do I pose for the recurrence ?
<flux>
hm?
<bernardofpc>
i'd say type ('a, 'b) listf = Val of 'a | Func ('b -> 'a) * ('b, 'c) listf
<bernardofpc>
my idea is that "a listf" is something of type a
<bernardofpc>
so a val of a is ok
<bernardofpc>
or a function that eats something, and gives me an "a" is also good
<bernardofpc>
but ocaml doesn't like "something" as I have written :(
<flux>
well, let me give this, perhaps it'll clear your thought: type 'a listf = Val of 'a | Func of 'a func and 'a func = { f:'b . ('b -> 'a) * 'b listf }
<flux>
but the thing is, it's difficult to have a function with that type (forall 'b, exists 'a)
<bernardofpc>
yes
<bernardofpc>
the idea is for example
<bernardofpc>
i have len : 'a list -> int
<bernardofpc>
then I have buildlist : 'a tree -> 'a list
<bernardofpc>
and finaly 'a readdata : string -> 'a tree
<bernardofpc>
then I'd like to build Func (len, Func(buildlist, Func(readdata, "blah blah ...")))
<bernardofpc>
or the same, but for algebraic calculations
<flux>
can't the argument to Func be (unit -> 'a) ?
<bernardofpc>
(where I may have a group, then it's center, then some numerical invariant, then...)
<flux>
and then provide it something like fun () -> buildlist arg
<bernardofpc>
in fact, I'm a mathematician learning OCaml
<bernardofpc>
At the moment, I have no 'real' application in mind, but just the idea to use the typing in Caml to build a list of "composable functions" in a given order
<bernardofpc>
(say, very abstract one...)
<flux>
I'm thinking perhaps Coq would be more willing to bend into exotic types :)
<totom>
Ultimately I think you need to provide all the types
<bernardofpc>
flux: I'll take a look
<flux>
usually that kind of needs are encoded with a unit-function which contains the real function call
<totom>
like type 'a comp1 = 'a, type ('a, 'b) comp2 = 'a comp1 -> 'b, etc.
<totom>
'a 'b 'c comp3 = 'a 'b comp2 -> 'c
<bernardofpc>
well, that doesn't fit the principle of a calculation...
<bernardofpc>
because I'd have to define taht infinetly
<totom>
unless you use some kind of abstract type '_a, but I don't think this is possible in a type definition
<bernardofpc>
but my type is something like "Lazy", but in practice, it's terminal, ...
<bernardofpc>
no, unfortunatly, OCaml doesn't like '_b in types
<bernardofpc>
but perhaps the *true* solution would just define the composition, which has the good type...
<bernardofpc>
but that gives me no way to group all functions in a single place
<bernardofpc>
(like a list)
ched_ has joined #ocaml
ched__ has quit [Read error: 110 (Connection timed out)]
mlh has quit [anthony.freenode.net irc.freenode.net]
rumbleca has quit [anthony.freenode.net irc.freenode.net]
mlh has joined #ocaml
rumbleca has joined #ocaml
brendan has quit [Read error: 60 (Operation timed out)]
brendan has joined #ocaml
<totom>
strange
<totom>
even polymorphic variants don't work
<totom>
let rec comp = function
<totom>
`Val x -> x
<totom>
| `Fun (f, x) -> f (comp x)
<totom>
returns val comp : ([< `Fun of ('b -> 'b) * 'a | `Val of 'b ] as 'a) -> 'b = <fun>, which constrains the type of f to 'b -> 'b
<flux>
I think you need to use recursive modules
<flux>
because the type of 'comp' is decided too early for this case
komar_ has joined #ocaml
ched__ has joined #ocaml
ched_ has quit [Read error: 101 (Network is unreachable)]
jeanbon has joined #ocaml
ulfdoz has joined #ocaml
seafood has joined #ocaml
schme has joined #ocaml
Associat0r has quit []
Ched has joined #ocaml
monadic_kid has joined #ocaml
jamii__ has joined #ocaml
monadic_kid is now known as snk_kid
sanguine1 is now known as sanguinev
ched__ has quit [Read error: 101 (Network is unreachable)]
rjack has joined #ocaml
Camarade_Tux has joined #ocaml
_zack has joined #ocaml
Associat0r has joined #ocaml
OChameau has joined #ocaml
mpwd has quit []
_zack has quit ["Leaving."]
Camarade_Tux has quit ["Leaving"]
Camarade_Tux has joined #ocaml
mpwd has joined #ocaml
mpwd_ has joined #ocaml
randart_ has joined #ocaml
mpwd has quit [Read error: 110 (Connection timed out)]
randart has quit [Read error: 110 (Connection timed out)]
Yoric[DT] has joined #ocaml
bind_return has joined #ocaml
<totom>
I don't understand how it works, but it works :-)
Ched has quit [Remote closed the connection]
Associat0r has quit []
seafood has quit [Read error: 54 (Connection reset by peer)]
seafood has joined #ocaml
rjack has quit ["leaving"]
OChameau has quit [Read error: 110 (Connection timed out)]
mpwd_ has quit [Read error: 104 (Connection reset by peer)]
mpwd has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Read error: 110 (Connection timed out)]
ulfdoz_ is now known as ulfdoz
Associat0r has joined #ocaml
_zack has joined #ocaml
snk_kid has quit ["Leaving"]
ikaros has joined #ocaml
Ched has joined #ocaml
mpwd_ has joined #ocaml
jeff_s_ has joined #ocaml
Lomono has joined #ocaml
mpwd has quit [Read error: 113 (No route to host)]
verte has quit ["~~~ Crash in JIT!"]
itewsh has joined #ocaml
komar_ has quit [Remote closed the connection]
seafood has quit []
komar_ has joined #ocaml
komar_ has quit [Remote closed the connection]
komar_ has joined #ocaml
mpwd_ has quit [Read error: 104 (Connection reset by peer)]
<mrvn>
let rec housewive = function [] -> leave_shop () | item::list -> let rec goto item = if there then () else bein find_tight_spot (); talk_to_neighbour (); goto item; end in goto item; housewive list (* Average housewive while shopping *)
komar_ has quit [Remote closed the connection]
komar_ has joined #ocaml
_zack has quit ["Leaving."]
mpwd has joined #ocaml
<Yoric[DT]>
mrvn: :)
<mrvn>
I always find it amazing how they always manage to find the spot where they halt all traffic and then pause.
<thelema_>
hmm, I want to extract a substring from a BigArray.Array1.map_file...
Ched has quit [Read error: 110 (Connection timed out)]
Ched has joined #ocaml
<thelema_>
hi Yoric[DT]. How's it going?
<Yoric[DT]>
Fine, thanks.
<Yoric[DT]>
Overworked, as usual.
<Yoric[DT]>
How do you do?
<thelema_>
well. I didn't get the mylife.com job, tho.
<thelema_>
I should be working on my resume, but instead I'm rewriting cdb in ocaml.
kaustuv has quit [Read error: 113 (No route to host)]
komar_ has quit [Remote closed the connection]
komar_ has joined #ocaml
komar_ has quit [Remote closed the connection]
Associat0r has quit []
ikaros has quit [Read error: 54 (Connection reset by peer)]
ikaros has joined #ocaml
mpwd has quit []
sgnb has quit [Read error: 104 (Connection reset by peer)]
sgnb has joined #ocaml
mpwd has joined #ocaml
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
AxleLonghorn has joined #ocaml
MAcks_ has joined #ocaml
mishok13 has quit [Read error: 113 (No route to host)]
Associat0r has joined #ocaml
Associat0r has quit [Client Quit]
jeddhaberstro has joined #ocaml
randart_ is now known as randart
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
mishok13 has joined #ocaml
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
robocop has joined #ocaml
<robocop>
hello.
<jeff_s_>
hi
<robocop>
do you what the best solution to create a server in ocaml and communicate with tcp ?
<robocop>
*+know
<robocop>
netclient in ocamlnet ?
<robocop>
or other ?
<flux>
I've used plain Unix-module
<flux>
but perhaps ocamlnet (or Lwt?) is nice
<robocop>
okey.
<flux>
using the Unix-module has the prerequisite of understanding how the socket api works
<flux>
knowledge possibly carried over from programming C
<flux>
in any case, examples of doing socket programming in C can be helpful
<flux>
do you know that already?
<robocop>
I just want to comminicate with a erlang programm.
<flux>
ookay.. do you know the protocol it uses?
kaustuv_ has quit ["ERC Version 5.3 (IRC client for Emacs)"]
<flux>
maybe using the few functions the Unix-module provides for creating servers is sufficient
<flux>
having inter-process communation between those can be more difficult, though
<flux>
usually networking programs in Unix are built around a select-loop to handle concurrwnt connections (or, alternatively, each connection is handled by a separate connection)
<robocop>
hum, okey. I will look the Unix module.
<flux>
good luck :)
<robocop>
ha, it's a big module :o
<robocop>
do you have an exemple to use it with tcp ?
<flux>
indeed
<flux>
hmm
<flux>
no :-)
<robocop>
okey :)
Associat0r has joined #ocaml
Associat0r has quit [Read error: 104 (Connection reset by peer)]
marmottine has joined #ocaml
<flux>
what kind of abilities do you require?
<flux>
accepting incoming connections, making outbound ones?
<flux>
if only the first one and you are on a linux host (also, you are the superuser of the host), you make us@@mau make use of inetd
<robocop>
No, there is only on client, who send a message. Ocaml execute a function with this function, and resend the message at the erlang client.
<robocop>
*one
<flux>
it will make network serbives run your binary with stdin/stdout connected to the network socket
<robocop>
*whith this message.
cgizmo has joined #ocaml
itewsh has quit [Connection timed out]
itewsh has joined #ocaml
<thelema_>
robocop: you want an ocaml program to accept connections from the client and pass them on (modified) to the erlang server?
<robocop>
yes thelema_.
mpwd has quit [Read error: 110 (Connection timed out)]
sporkmonger has joined #ocaml
<thelema_>
let sock_in = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 12345 in
<thelema_>
let (input, addr) = accept sock_in in
<thelema_>
err, Unix.accept
<thelema_>
oh yeah, you'll need [Unix.listen sock_in 10] first to get it started listening.
* thelema_
makes an example program
<cgizmo>
thelema_: would that work for a program that need to handle many concurrent connections ?
<thelema_>
look in that part of the [Unix] docs for the needed functions
<cgizmo>
or fast conenection disconnection ?
<cgizmo>
i'm developing the erlang server with robocop
<cgizmo>
erlang client*
<cgizmo>
and the point is basically the client catches some input
<cgizmo>
passes it on to the ocaml program, who accepts
<thelema_>
it'll queue up to 10 connections, probably the first thing to do when you've accepted is to fork, and have the child process handle the network, and the parent go back to accepting
<cgizmo>
then disconnects
<cgizmo>
and this over and over again
<thelema_>
Camarade_Tux: good call.
<cgizmo>
thelema_: ok, thanks
AxleLonghorn has left #ocaml []
<Camarade_Tux>
thelema_ :)
<thelema_>
yeah, go to pleac - it's got a lot of good code.
<thelema_>
probably better tested than what I'm coming up with off the top of my head
mishok13 has quit [No route to host]
itewsh has quit [Success]
itewsh has joined #ocaml
Yoric[DT] has quit [Read error: 113 (No route to host)]
BiDOrD has quit [Read error: 110 (Connection timed out)]
BiDOrD has joined #ocaml
mitkok has joined #ocaml
cgizmo has left #ocaml []
mitkok has quit [Remote closed the connection]
ikaros has quit [Read error: 110 (Connection timed out)]
<robocop>
ptin cho.
<flux>
robocop, where was the IRC-module you were using?
<flux>
robocop, ah, I missed an argument. fun sender destination str -> print_endline str
jm has joined #ocaml
julm has quit [Read error: 110 (Connection timed out)]
<flux>
robocop, well, atleast I guess you learned what that kind of error message can indicate :)
<thelema_>
does anyone know how expensive Bigarray.*.map_file is?
<flux>
I doubt any more expensive than any system call?
<flux>
or do you mean how expensive is mmap?
<thelema_>
if it's reasonable to map_file often with an offset instead of twiddling chars into int32s
<thelema_>
how expensive is mmap?
<robocop>
yes flux, sorry.
<flux>
I suppose it can be "somewhat expensive", it needs to mess with memory management; possibly flush TLB
<flux>
thelema_, benchmark, benchmark and benchmark?-)
<thelema_>
I'm trying to avoid writing more code - benchmark would require writing both.
<flux>
:)
<flux>
thelema_, well, as a point to consider: some web servers use mmapping to push stuff to clients, atleast prior the invention of sendfile
<flux>
but if you're doing hundeds or thousands of mmaps a second.. well, hard to tell
<mrvn>
mmap and malloc should cost the same in terms of TLB costs
<flux>
mrvn, good point
<mrvn>
in the end malloc does mmap too
<flux>
in theory if you haven't used memory used by mmap prior the call, there's no need to flush TLB
<flux>
but there is still the cost of manipulating page tables
<mrvn>
mmap needs that too
Yoric[DT] has joined #ocaml
<thelema_>
probably not thousands, but it'll probably be cheaper to just grab the four bytes I need and shift them into an int32 than to have four map_files around so I can do unaligned access.
<sanooj>
thelema_: how many files do you need to access?
<mrvn>
You can not mmap a file at offset 1/2/3 anyway.
<flux>
robocop, while true?-o
<flux>
robocop, it just goes into an infinite loop right there..
<thelema_>
mrvn: maybe I can't, but map_file allows for a byte offset from the beginning of the file - maybe the offset is handles in ocaml?
<robocop>
flux: Yes, but I had to test always if a new message is posted, no ?
<thelema_>
sanooj: just one, but I need unaligned access
<robocop>
*post
<mrvn>
man mmap: "offset must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE)."
<flux>
robocop, no. your function gets called when the message comes
<mrvn>
it will probably just throw an exception if you give an off offset
<sanooj>
thelema_: any reason why you can't mmap the entire file for the entire duration of the server?
<robocop>
flux: Ha okey.
<robocop>
but it doen't works.
<flux>
what doesn't work?
<thelema_>
sanooj: I am, as a bigarray of chars, but I have to pull int32s out of this data a lot, and I was thinking that it'd be better to do that through a int32 bigarray
<flux>
oh, right
<mrvn>
thelema_: You have 2 choices: read bytes and shift them together or memcpy
<flux>
robocop, I think at certain point (after you've done your stuff) you're supposed to call event_loop
<sanooj>
thelema_: ah, I see. you're sending those four bytes over the network right?
<thelema_>
sanooj: no, no network here - cdb implementation
<sanooj>
thelema_: because basically 4 byte reads vs. one int32 read is not going to register at all if you have any i/o in the picture.
<sanooj>
ah.
<mrvn>
thelema_: The best thing would be to make sure the data is aligned.