<sc30317>
Is there a way I can statically store values in a list?
<sc30317>
using a function
<thelema>
not very.
<sc30317>
like let x = [~~~function~~~]
<sc30317>
not very what?
<thelema>
oh, you want a literal list, like [2;3;4;5]?
<sc30317>
yea
<thelema>
use semicolons to separate elements, [] at beginning and end
<sc30317>
well like I want to call the function create_winit(data)
<thelema>
[|1;2;3|] is an array
<sc30317>
and I want what is returned in that to be stored into something that I can access
<sc30317>
*returned by that
<thelema>
let ret = create_winit [1;2;3;4]
<sc30317>
but create_winit(anddata) creates a list of floats
<sc30317>
and when I do let ret = create_winit of that, it doesn't stay in the ret list
<sc30317>
nm it does
<sc30317>
ok here is my problem
<sc30317>
how can I pass data to ret externally
<sc30317>
like I want to do
<sc30317>
let ret trainData= create_winit(trainData)
<sc30317>
but when I do that, it doesn't store the values in ret
<sc30317>
and if I do
<sc30317>
let ret = create_winit(trainData)
<thelema>
correct - that makes a function
<sc30317>
ok, how can I pass in trainData without making a function?
<thelema>
let f x = x + 3
<thelema>
let x = 2 in let y = x + 1 in ...
<sc30317>
am I close with this?
<sc30317>
let ret = create_winit(x)
<sc30317>
let x = trainData in
<thelema>
nope, opposite order.
<sc30317>
that gives me a syntax error?
<thelema>
If you already have trainData as a value, just do [let ret = create_winit trainData in ...]
<sc30317>
you mean like this?
<sc30317>
let x = trainData in
<sc30317>
let ret = create_winit x in;;
Pepe_ has quit [Read error: Operation timed out]
Pepe_ has joined #ocaml
<thelema>
If you're going to use ;;, don't use in
<sc30317>
which should I be using?
<thelema>
let ret = create_winit trainData;;
<thelema>
you should be using in.
<sc30317>
but then I have to pass trainData to ret
<thelema>
? you're passing trainData to create_winit in order to create ret
<sc30317>
yea but if you do that then it is an unbound value
<thelema>
you don't have trainData?
<sc30317>
I do
<sc30317>
im confused
<sc30317>
ok, so for all of the functions I have had so far
<sc30317>
I have had to pass in trainData
<thelema>
bind whatever you have to train_data
<sc30317>
traindata is a matrix
<thelema>
let trainData = [[1;2;3];[4;5;6];[7;8;9]];;
<thelema>
let winit = create_winit trainData;;
<sc30317>
ok im trying
<sc30317>
ok i figured I would try to make a function to do this
<sc30317>
let creation (trainData) =
<sc30317>
let x = create_winit(trainData)
<sc30317>
;;
<sc30317>
but that doesn't work
<mrvn>
thelema: You should () your tuples. Makes it more readable.
<sc30317>
the reason I am trying not to bind anything to trainData is because trainData is going to be different in different situations
<mrvn>
sc30317: then you need to leafe it as argument to functions
<mrvn>
leave even
<sc30317>
mrvn, I don't understand what you are saying
<sc30317>
heres the issue
<sc30317>
I am given train data
<mrvn>
You can't have it as argument and bind it outside a function
<sc30317>
ok, then what should I do?
<mrvn>
sc30317: If it is bound before your function then just use it. If it is given later then you must pass it as argument
rwmjones has left #ocaml []
rwmjones has joined #ocaml
xavierbot has joined #ocaml
<rwmjones>
hmm
<rwmjones>
xavierbot, help
xavierbot has quit [Remote host closed the connection]
xavierbot has joined #ocaml
xavierbot has quit [Remote host closed the connection]
<sc30317>
mrvn, im still confused
<mrvn>
If you want your code for work for different matrixes then you need to always pass the matrix as argument.
<sc30317>
yes, I understand that
<sc30317>
and I am passing it as an argument
<sc30317>
from a separate .ocaml file
xavierbot has joined #ocaml
xavierbot has quit [Remote host closed the connection]
<mrvn>
And every matrix needs a differet vector to multiply with
<sc30317>
and I am creating that vector
<sc30317>
with create_winit
xavierbot has joined #ocaml
<mrvn>
so where is the problem?
<sc30317>
the problem is
xavierbot has quit [Remote host closed the connection]
<sc30317>
since I pass in the matrix from a separate ocaml file
<sc30317>
I can't bind that matrix to anything in my program
rwmjones is now known as xavierbot
<mrvn>
sc30317: You need to specify the module the matrix comes from. Every file creates a module by the same name as the file but with upper case first char.
<mrvn>
e.g. Anddata.anddata
<sc30317>
ok
xavierbot is now known as rwmjones
<sc30317>
is there a way I can generalize that more?
<sc30317>
such as
<sc30317>
I am going to have anddata, ordata, etc
<mrvn>
no
Amorphous has quit [Ping timeout: 276 seconds]
<mrvn>
The name is strictly decided by the filename and the name the data is bound to in that file.
<sc30317>
ok
<sc30317>
so how can I handle multiple different lists?
<mrvn>
by passing them in
<sc30317>
how?
<mrvn>
my_function Myfile.mydata
xavierbot has joined #ocaml
<sc30317>
I know
<rwmjones>
xavierbot, help
<sc30317>
but Myfile.mydata is just going to change when I do anddata, ordata, etc
* rwmjones
grumbles
xavierbot has quit [Remote host closed the connection]
<mrvn>
sc30317: and you have to change the call to match every time.
<sc30317>
ok
xavierbot has joined #ocaml
<rwmjones>
xavierbot, help
xavierbot has quit [Remote host closed the connection]
<thelema>
mrvn: where's my tuples?
<mrvn>
thelema: match [],[] -> ...
<thelema>
mrvn: ah. odd - I find it quite readable without ()
avsm has joined #ocaml
<thelema>
just like I don't [match (foo,bar) with ...], but [match foo,bar with...]
<mrvn>
So you only somtimes () your tuples or never?
<thelema>
when I need to, for precedence
<thelema>
(which is most of the time)
<mrvn>
which is why most people always use (). That way tuples look the same all the time and they can't forget to () them when needed.
<thelema>
If I'm matching a single value, I'll usually use () in patterns: [match pair with (2,3) -> ...], but for a tuple constructed within the match expression, somehow it's different
<thelema>
I'm just using the tuple construction as match shortcut, and there's no real tuple involved
<mrvn>
thelema: irelevant
<sc30317>
thelema, that function that we created earlier
<thelema>
sc30317: you could have a base case that throws away the last values
<rwmjones>
xavierbot, help
<xavierbot>
hello rwmjones, I am xavierbot 0.8, an OCaml toplevel
<xavierbot>
expr ;; evaluate expr in toplevel and print result
<xavierbot>
help help message
<xavierbot>
restart restart the toplevel
<xavierbot>
sleep go to sleep
<thelema>
mrvn: ;; can catch errors as well.
<xavierbot>
wake wake me up from sleep
<rwmjones>
ooops
<rwmjones>
xavierbot, ;;
<rwmjones>
fo ;;
<sc30317>
thelema, how would I go about doing that?
<mrvn>
thelema: only moves the point where the error is reported.
<thelema>
sc30317: [_] matches a list with one element in it (ignoring what the element is)
<thelema>
mrvn: useful when you miss an [in], and the error is reported 2 toplevel phrases away
xavierbot has quit [Remote host closed the connection]
<sc30317>
thelema, what?
<thelema>
sc30317: [] matches the empty list, [x] matches a list with one element, [x;y] matches a two element list, h::t matches a list with a head and a tail, etc.
<thelema>
sc30317: if you use _ instead of a variable name, the value won't be bound anywhere
<sc30317>
thelema, but wouldn't I want the value to be bound?
<mrvn>
sc30317: only if you want to
<thelema>
which is what's going on with the last part of the match - we're matching _ to catch everything else, and raise an error.
<mrvn>
sc30317: If you bind it to x and then never use it you get a warning that x is not used.
<sc30317>
oh ok
<mrvn>
.oO(except in tuples fo some reason)
<sc30317>
so I should actually put an x and a y in those []'s?
<mrvn>
in those [_], if you need the value
<sc30317>
im still confused
tmaeda is now known as tmaedaZ
<thelema>
sc30317: if you want the value of the single element in a 1-element list, use [x]. Since in this case you don't need that value, use [_]
<mrvn>
Then ask different questions. To "im still confused" we can only repeat what we said and that won't help you one bit.
avsm has quit [Quit: Leaving.]
<sc30317>
ok thelema
<sc30317>
and mrvn
<sc30317>
even when I do the [_], it tells me that they are different sized lists
<thelema>
do you want to remove the last element off both lists, or just one?
<thelema>
s/remove/ignore/
<sc30317>
for example,
<sc30317>
I am given a 4x4 and a 3x1 matrix
<sc30317>
i have to multiply a 3x4 and the 3x1 to make a 4x1
<sc30317>
*1x4
<sc30317>
restart
<mrvn>
why not just add 0.0 to the 3x1?
<sc30317>
mrvn, what?
<sc30317>
you mean make the last element 0.0?
<mrvn>
Extend the 3x1 matrix with 0.0 to make a 4x1
<mrvn>
Or rather the vector as it is a float list only.
<sc30317>
yea I could do that
<sc30317>
but I don't know how to do that
<sc30317>
oh mrvn
<sc30317>
I cant do that
<sc30317>
because I have to multiply the [4x3] x [3x1] to get the [4x1]
<sc30317>
do you see what I mean?
<mrvn>
Then there is nothing to ignore.
<sc30317>
except I am given a 4x4
<sc30317>
and I need to make it into a 4x3
<mrvn>
then write a function that removes the last element from a vector and apply that to every row.
<sc30317>
yea, how would I do that
<sc30317>
that is my question
<mrvn>
An empty list gives an error, a one element list gives an empty list, a list with head and tail gives a list with the head and the tail with the last element removed.
<mrvn>
Now put that into ocaml syntax
<sc30317>
ok let me try h/o
<sc30317>
for the empty list: if trainData = [] then failwith "Empty List"
<mrvn>
use pattern matching
pimmhogeling has quit [Ping timeout: 245 seconds]
<sc30317>
mrvn, I can't figure it out
<mrvn>
let remove_last = function [] -> failwith "Empty List" ...
<mrvn>
let rec even
<sc30317>
what is supposed to go into function []
<mrvn>
each row vector of your matrix
<mrvn>
remove_last takes a row vector and returns a row vector one shorter.
ikaros has quit [Quit: Leave the magic to Houdini]
<mrvn>
so you have the "empty list" case, now write the other two.
<sc30317>
ok im trying
<sc30317>
this language is extremely frustrating
<sc30317>
I could write this program in C in like 5 minutes
<thelema>
It's definitely a different way to think about things.
<mrvn>
You haveto stop think C and think more mathematical.
<thelema>
go ahead and write it the C way. let rec remove_last x = if x = [] then failwith "Empty list" else if List.length x = 1 then [] else ...
<sc30317>
thats what Im not good at ;P
<thelema>
You'll find more and more easier ways to write the same thing.
<mrvn>
thelema: *shiver*
<sc30317>
am I able to call another function in that function?
<sc30317>
never mind, don't need to
<mrvn>
sc30317: sure, but you only need to call the function itself
<thelema>
mrvn: I know, but he'll find easier ways with experience. If he gives up now in frustration, he'll never learn.
<sc30317>
ok
<sc30317>
let rec remove_last x =
<sc30317>
if x = [] then failwith "Empty list"
<sc30317>
else if List.length x = 1 then []
<sc30317>
else if List.length x = (List.length(List.hd x)) then failwith "SUCCESS"
<sc30317>
;;
<thelema>
?? List.length (List.hd x) doesn't make sense.
<mrvn>
sc30317: List.hd x is a float. It has no length.
<thelema>
unless x is a list of lists...
<sc30317>
x is a list of lists
<mrvn>
no.
<sc30317>
no what
<thelema>
let's try removing the last element of one sublist - one row
<mrvn>
remove_last should be 'a list -> 'a list
<thelema>
we can use that to remove the last element off every row.\
<sc30317>
ok
<mrvn>
sc30317: First build a simple function (remove last element from list). then use that function to build a larger one (remove last element from every row).
<sc30317>
ok let me try that
<sc30317>
I don't know how to remove something from a list?
<thelema>
create a list without that last element.
<mrvn>
sc30317: you actually can't. You need to build a new list that is one shorter.
<thelema>
for example [1.0] goes to []
<thelema>
[2.0;1.0] goes to [2.0]
<sc30317>
yea
<sc30317>
im not sure how to do that
<mrvn>
sc30317: recursively.
<thelema>
Ok, we'll do this inefficiently. List.rev reverses a list.
<mrvn>
sc30317: You handle the empty list and the one element list. Then every longer list you do recursively by removing the last element from the tail and then reattaching the head.
<thelema>
can you remove the last element using List.rev?
<mrvn>
thelema: hehe, good idea.
<sc30317>
how would you do so?
<thelema>
can you remove the first element off a list?
<mrvn>
sc30317: When you reverse a list what is the equivalent to removing the last element then?
<sc30317>
removing the head
<mrvn>
And how do you do that?
<sc30317>
I am assuming you make a new list
<thelema>
What does List.tail do?
<sc30317>
and then you start at the first element?
<sc30317>
List.tail prints the tail
<sc30317>
of the list
<thelema>
not quite. It's a function that returns the tail. What's the tail of a list?
<sc30317>
the last element within the list
<mrvn>
no, everything but the first
<sc30317>
oh ok
<sc30317>
so you reverse the list
<sc30317>
get the tail
<sc30317>
then reverse it again?
<mrvn>
yep
<sc30317>
ok
<thelema>
yup, that'll remove the last element from a list.
<mrvn>
sc30317: So how does that look when you put it together?
<sc30317>
something like this?
<sc30317>
let remove_last x =
<sc30317>
let reversed = rev(x)
<sc30317>
let minus_one = tl(x)
<sc30317>
let forward = rev(minus_one)
<sc30317>
;;
<thelema>
List.tl(reversed)
<mrvn>
you are missing "in"s
<sc30317>
ok h/o let me try again
<mrvn>
and a return value
<sc30317>
let remove_last x =
<sc30317>
let reversed = List.rev(x) in
<sc30317>
let minus_one = List.tl(reversed) in
<sc30317>
let forward = List.rev(minus_one) in
<sc30317>
return forward
<sc30317>
;;
<mrvn>
or in short form: let remove_last x = List.rev (List.tl (List.rev x))
<mrvn>
s/return//
<thelema>
there's no "return" command
<sc30317>
whats s/return//
<mrvn>
remove the return
<sc30317>
where do you add that in?
<thelema>
you don't have to say to return something - the last value in your function is automatically returned.
<mrvn>
s/foo/bar is a syntax used in sed that does a search&replace. foo is replaced by bar.
<sc30317>
how about that! it works
<mrvn>
sc30317: great. Now the next step. Applying that to the Matrix.
<sc30317>
now I have to do this recursively
<thelema>
Ok, now we have to remove the last off each row - let remove_lasts matrix = List.map remove_last matrix
<mrvn>
thelema: spoiler. :)
<thelema>
sc30317: don't do it recursively - just use List.map to apply the function to every row.
yakischloba has quit [Quit: Leaving.]
<thelema>
mrvn: yes, but it's quite easier this way.
<sc30317>
yes, that works!
<sc30317>
:D
yakischloba has joined #ocaml
<sc30317>
now more work to do
<sc30317>
hahaa
<mrvn>
sc30317: What does your 4x4 matrix represent? A camera direction and position?
<sc30317>
an input vector and a vector class
<sc30317>
now how can I store that value into its own matrix?
<sc30317>
let x = remove_lasts matrix ?
<thelema>
That's the idea.
<mrvn>
yes. But you never store values. you just bind names to them
<sc30317>
that gives me an unbound value?
slash_ has quit [Quit: Lost terminal]
<mrvn>
sc30317: you need the matrix first
<sc30317>
mrvn, I give the matrix
<thelema>
you give the matrix how?
<thelema>
I read something about an external file
<sc30317>
yea its an external file
<sc30317>
so when I enter ocaml
<sc30317>
I #use"mydoc.caml";;
<sc30317>
and then I
<sc30317>
#use"anddata.caml";;
yakischloba has quit [Ping timeout: 264 seconds]
<mrvn>
sc30317: every file declrares a module. you need to use the module name to access the values of a different module.
<thelema>
mrvn: not if he's doing #use
<thelema>
sc30317: you have to define your data first before you can use it.
<sc30317>
how do I define it?
<mrvn>
sc30317: reverse the use lines
<thelema>
if anddata.caml defines a matrix called 'matrix', you can refer to that in mydoc.caml and it'll work
<thelema>
(if you use the correct order)
<thelema>
the alternative is to use a big function and wrap everything that needs your input matrix inside one function, and call that function after you've loaded anddata
<sc30317>
thelema, I think thats probably what I have to do
<sc30317>
hold on, let me see if this is what you mean
<mrvn>
sc30317: what is wrong with using anddata first?
<sc30317>
nothing
<sc30317>
that is what is done
<sc30317>
but it might be ordata, it might be xordata, etc
<mrvn>
then you have to change the function call acordingly. There is no way ocaml can magically know what matrix to use.
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
Mr_Awesome has quit [Read error: Connection reset by peer]
<thelema>
In ordata, if he defines his input matrix 'ordata', he can call [process ordata] to run whatever processing needs to be done on ordata.
<sc30317>
what did you guys like to see code in? codedump?
<sc30317>
if the numbers are of the same sign (positive and negative) as the last row in the original matrix, you are done
<sc30317>
if not
<mrvn>
sc30317: why don't you split the test data into matrix and result verctor?
<sc30317>
then you add up the numbers that are incorrect
<sc30317>
mrvn, how would I go about doing that?
<mrvn>
e.g. type testdata = matrix * vector
<mrvn>
let testdata = (((1,2),(3,4)), (5,6))
<sc30317>
because I don't have that option
<sc30317>
mrvn, the testData is given to me in a separate ocaml file
<mrvn>
then as first step convert it to something useable.
<sc30317>
yes
<sc30317>
I agree :D
<mrvn>
I wouldn't even use lists for the vector and matrix.
<sc30317>
no?
<sc30317>
what would you use?
<mrvn>
array
<sc30317>
I am given a List
<sc30317>
and im not sure that I am allowed to use matrices
<sc30317>
I am only allowed to use the functional features of ocaml
<sc30317>
is a matrix a functional feature?
<mrvn>
matrix would be something you define
<sc30317>
so that means its not a functional feature?
<mrvn>
No.
<sc30317>
well then I can't use it
<mrvn>
no, it does not mean that
<sc30317>
oh ok
<sc30317>
well then I can use matrices
<sc30317>
but I have something that works, so why change it?
<mrvn>
Because when you have a larger project a function multiply : matrix -> vector -> vector looks better than multiply : float list list -> float list -> float list
<sc30317>
true
<mrvn>
You get nicer error messages too
<sc30317>
haha
<sc30317>
nice error messages are better
<sc30317>
but is it worth changing it in this instance?
<sc30317>
since I already have everything setup with lists?
<mrvn>
sc30317: the matrix type can still be a float list list
<thelema>
I'm familiar with the work on avoiding array bounds checks through a module that generates unique types...
<thelema>
ah, I've seen this one too - base10 encoding the dimension with phantom types. It's about as ugly.
<mrvn>
thelema: quite ugly to do butthe only way to o it for any dimension. You can do it nicer if you just want 2/3/4 dimensions.
<mrvn>
s/to o/to do/
<thelema>
the extra parameter to combine is priceless.
<thelema>
oops, n/m. misread
<thelema>
what is the difference between combine and map2?
<mrvn>
combine is a map2 with different argument order.
<mrvn>
I don't get the map2 implementation in that mail though. That should just call combine
<thelema>
ok, not much.
enthymeme has joined #ocaml
<mrvn>
And combine should use unsafe_get
yakischloba has quit [Quit: Leaving.]
<sc30317>
mrvn, I have a question
<sc30317>
I want to store the value of this function
<sc30317>
let x inData = multiply_test(remove_lasts inData, create_winit inData)
<sc30317>
how would I do so?
<sc30317>
it returns a matrix
<mrvn>
let t = x inData
<sc30317>
ok
<mrvn>
you don't store data, you just bind it to a name
<sc30317>
it says that inData is unbounded
<sc30317>
because I have to compare the values of that output matrix
<sc30317>
to something else
<mrvn>
sc30317: That is like in C foo(bar); when bar is not declared
<sc30317>
yea I understand that
<sc30317>
but how do you declare bar when it is from an external source
<mrvn>
then why do you keep doing it?
<sc30317>
that is what I am asking
<sc30317>
because in my file if I let t = x anddata
<sc30317>
it works finen
<mrvn>
sc30317: since you are using the interactive toplevel there is no external source
<sc30317>
but it may be ordata, xorgada
<mrvn>
if it is ordata then you need to write ordata. If it is xorgada then you need to write xorgada
<sc30317>
but I can't just write that in my code
<sc30317>
because it changes each time
<sc30317>
you see what I mean?
<sc30317>
I think i have an idea, ill get back
<mrvn>
There just is no solution to "magically do the right thing on your own"
<sc30317>
unfortunately
<sc30317>
could I do this?
<sc30317>
let function(trainData, lr, maxiterations, winit) =
<sc30317>
let t = x trainData
<sc30317>
;;
yakischloba has joined #ocaml
<mrvn>
if you correctthe syntax errors
<sc30317>
what is incorrect?
<mrvn>
the ;;
<sc30317>
then how does the let t = x trainData know that it is inside the "function"
<mrvn>
it just is
joshcryer has joined #ocaml
<sc30317>
well that gives me a syntax error
<mrvn>
in sublets you need to use in
<sc30317>
so like this?
<joshcryer>
Hey, I compiled ocaml on my server but didn't (can't) install it, can I compile an ocaml source from within the ocaml directory that it successfully compiled in?
<sc30317>
let sde3(trainData, lr, maxiterations, winit) =
<sc30317>
let t = x trainData in
<sc30317>
gives me an error
<mrvn>
in must be followed by an expression
joewilliams_away is now known as joewilliams
orbitz_ has joined #ocaml
rwmjones has quit [Ping timeout: 245 seconds]
jeddhaberstro has quit [*.net *.split]
sc30317 has quit [*.net *.split]
orbitz has quit [*.net *.split]
Chile has quit [*.net *.split]
willb has quit [*.net *.split]
sc30317 has joined #ocaml
willb has joined #ocaml
<joshcryer>
OK configure appears to accept a custom directory you can install to.
<joshcryer>
Can I do ./configure ~/public_html/ocaml ?
<mrvn>
do you mean ./configure --prefix=~/public_html/ocaml ?
<joshcryer>
Doh, yeah.
<joshcryer>
I meant to say -bindir but that is better.
Chile has joined #ocaml
<mrvn>
Anyone know about checksum functions? Say I have a chunk of memory that contains a checksum. Is there a checksum so that if I set mem.checksum <- 0 then (checksum mem) gives x and if I set mem.checksum <- x then (checksum mem) gives 0?
<mrvn>
Something better than xor?
valross has joined #ocaml
joshcryer has left #ocaml []
joewilliams is now known as joewilliams_away
Guest95631 has joined #ocaml
<mrvn>
nm, CRC does what I want
yakischloba has quit [Quit: Leaving.]
yakischloba has joined #ocaml
thrasibule has quit [Ping timeout: 276 seconds]
Submarine has joined #ocaml
ulfdoz has joined #ocaml
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
oc13 has joined #ocaml
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
smimou has quit [Ping timeout: 258 seconds]
smimou has joined #ocaml
yakischloba has quit [Quit: Leaving.]
ulfdoz has quit [Ping timeout: 245 seconds]
oc13 has quit [Quit: Leaving.]
oc13 has joined #ocaml
valross has quit [Quit: Ex-Chat]
ttamttam has joined #ocaml
Submarine has quit [Ping timeout: 258 seconds]
<mrvn>
I've changed the Digest module to include a more lowlevel interface to the md5 digest code and added stubs to the md5.c but when I compile ocaml now I get: Error: Error while linking boot/stdlib.cma(Digest):
<mrvn>
The external function `caml_md5_update_string' is not available
<mrvn>
The symbol is included in libcamrun.a: % nm byterun/libcamlrun.a | grep caml_md5_update_string
Yoric has joined #ocaml
<mrvn>
0000000000000a32 T caml_md5_update_string
<mrvn>
I don't get why it doesn't find the function. I declared them the same way as the old md5 function.
avsm has joined #ocaml
avsm1 has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
Yoric has quit [Quit: Yoric]
ikaros has joined #ocaml
f[x] has joined #ocaml
smimou has quit [Read error: Operation timed out]
smimou has joined #ocaml
lukasz has joined #ocaml
lukasz has quit [Quit: Lost terminal]
smimou has quit [Read error: Operation timed out]
smimou has joined #ocaml
_zack has joined #ocaml
Yoric has joined #ocaml
rwmjones has joined #ocaml
smimou has quit [Ping timeout: 268 seconds]
avsm1 has quit [Quit: Leaving.]
myu2 has joined #ocaml
oc13 has quit [Ping timeout: 260 seconds]
maattd has joined #ocaml
maattd has quit [Excess Flood]
maattd has joined #ocaml
smimou has joined #ocaml
filp has joined #ocaml
brooksbp has quit [Ping timeout: 246 seconds]
avsm has joined #ocaml
pimmhogeling has joined #ocaml
Alpounet has joined #ocaml
<Camarade_Tux>
mrvn: maybe bigarray isn't linked against md5.o (or something along that), you probably have to change the build system too
<Camarade_Tux>
(I guess Bigarray would depend on Digest otherwise)
<Camarade_Tux>
ok, saw the messages on the mailing-list ;-)
<mrvn>
Camarade_Tux: I did run into the reverse in my first patch. I wanted Digest to support Bigarray directly. But digest is stdlib and bigarray is otherlibs.
smimou has quit [Read error: Operation timed out]
<mrvn>
How expensive is enter_blocking_section() and leave_blocking_section()? Is it worth using them for a C stub that will take a while to complete but doesn't actually block?
avsm has quit [Ping timeout: 245 seconds]
smimou has joined #ocaml
th5 has joined #ocaml
rbancroft has quit [Ping timeout: 264 seconds]
myu2 has quit [Remote host closed the connection]
_zack has quit [Quit: Leaving.]
_zack has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
myu2 has joined #ocaml
rbancroft has joined #ocaml
Modius has quit [Read error: Connection reset by peer]
Modius has joined #ocaml
avsm has joined #ocaml
avsm1 has joined #ocaml
avsm has quit [Ping timeout: 276 seconds]
albacker has joined #ocaml
munga has joined #ocaml
smimou has quit [Read error: Operation timed out]
th5 has quit [Read error: Connection reset by peer]
smimou has joined #ocaml
mutewit has quit [Ping timeout: 260 seconds]
mutewit has joined #ocaml
_andre has joined #ocaml
mutewit has quit [Ping timeout: 260 seconds]
mutewit has joined #ocaml
myu2 has quit [Ping timeout: 264 seconds]
_zack has quit [Quit: Leaving.]
_zack has joined #ocaml
smimou has quit [Read error: Operation timed out]
f[x] has quit [Ping timeout: 268 seconds]
f[x] has joined #ocaml
smimou has joined #ocaml
myu2 has joined #ocaml
jimmyb2187 has left #ocaml []
jimmyb2187 has joined #ocaml
<mfp>
mrvn: it sets some variables and does pthread_mutex_lock/unlock + pthread_cond_signal
<mrvn>
mfp: Do you think it is worth it when computing the md5sum of 4k? 64k? 1M?
<mfp>
dunno, would have to benchmark POSIX locks
<mfp>
it's probably going to be very system-dependent
<mrvn>
Do you have an example of putting a pointer to a C struct into a custom block? I think I'm doing something trivial wrong.
<mrvn>
The Data_custom_val is the address of the pointer, so **
<mfp>
note that this is equivalent to a struct with 1 element, though
smimou has quit [Read error: Operation timed out]
<mfp>
so I'd do it as in my example since it's safer and allows to add further fields if needed later
<mrvn>
Would you define a struct for that?
<mfp>
such as the int finalized; field to avoid double-release of the C struct
smimou has joined #ocaml
<mfp>
why not
<mrvn>
There will never be more fields. The pointer is just an indirection so that the GC does not move the MD5 context around while it computes it without lock.
<mrvn>
And afaik the caml_md5_context_finalize() will never be called twice.
<mfp>
if the context cannot be finalized manually, that will hold indeed
<mfp>
in my ex, I allow manual release and have the finalizer as a safety net
<mrvn>
In caml_md5_final I specifically make a copy of the context that gets MD5Final'ed. Which it different from freeing the context, it just ends its usefullness.
<mrvn>
I could track if caml_md5_final was used on a context or not and check that in the other functions. But is that worth it?
<mrvn>
It is too bad ocaml has no notion of a function being destructive to its argument.
<flux>
you mean linear types or something else?
maattd has quit [Ping timeout: 256 seconds]
<mrvn>
By appyig a value to a function the type of the value itself is modified.
<flux>
I'm not sure that is a feature that is missed a lot..
<flux>
after all, ocaml is behaving under the pretense of being a functional language ;)
<mrvn>
Yeah. It is something that only makes sense in imperative context.
<mfp>
you can simulate it to some extent
<mfp>
with phantom types
<mrvn>
But take the "Digest.final : Digest.context -> Digest.t" as example. By finaling the md5 computation the context is used up.
<mfp>
and a val destructive : ([`Destructive] * 'a) value -> 'a
<mrvn>
Should be something like Digest.final : (`Open -> `Closed) Digest.context -> Digest.t
<mrvn>
mfp: How do you prevent destructive being used twice on a value?
<flux>
mrvn, how would use use it?
<mfp>
mrvn: it can't :-|
<flux>
in any case, linear or unique typing is something that attempts to solve that
<flux>
Clean uses those to represent the real world (instead of Monads)
<mrvn>
flux: In linear type it would be final : `Open context -> (`Closed context, t) or just -> t as a `Closed context should be unusable.
<mrvn>
flux: I would love to have phantom types for a class and have methods modify the phantom type the object has.
<mrvn>
E.g. I have a object that represents on disk data. obj#dirty marks the data is needing to be written to disk. And any function that modifies the data should only be allowed to work on a `Dirty class.
<flux>
mrvn, I wonder how it would work.. modify_phantom_type foo -- would that mean the type of 'foo' changes?
<mrvn>
yep.
<flux>
I don't think type systems like to do that a lot
<flux>
branching for example would be broken in that case in a way that it hasn't been broken before
<mfp>
unfortunately there's no way to prevent older references from escaping (especially in OCaml, with refs)
<mrvn>
With non objects you would write let foo = modify_phantom_type foo in
<flux>
if true then modify_phantom_type foo (* what is the type of foo now? *)
<mfp>
mrvn: if you discard the old binding, you could do that with functional objects
<flux>
(add 'else ()' if that isn't clear enough example)
<mfp>
BUT you need some discipline (let foo = xxx foo)
avsm1 has quit [Quit: Leaving.]
<mrvn>
flux: type error since the then and else paths return different types basically.
<mfp>
can't prevent let old = foo in let foo = destructive_update foo in ... use old (* bad *)
<mrvn>
mfp: true. Or it would be impossible hard to catch all those cases.
<mfp>
hmm
<mfp>
maybe some trivial camlp4
<mfp>
would do
<flux>
famous last words ;)
<mrvn>
mfp: Not so trivial for the if true then modify_type foo
<mrvn>
That would have to be transformed to let foo = if true then modify_type foo in
<mrvn>
And it still won't work for objects as a method of a class can not return a different type of the class.
myu2 has quit [Ping timeout: 264 seconds]
<mrvn>
# class ['a] foo = object(self) method make_unit = ((Obj.magic self) : unit foo) end;;
<mrvn>
class ['a] foo : object constraint 'a = unit method make_unit : 'a foo end
pimmhogeling has quit [Ping timeout: 245 seconds]
<mfp>
the pb is that it doesn't work with inheritance (no parameterized 'self)
<mfp>
but it could be done externally, with a ('phantom * 'a) value type
tmaedaZ is now known as tmaeda
<mrvn>
mfp: it doesn't work at all, period. As soon as you have a method that returns a certain type for the 'a it becomes constraint
<mfp>
mrvn: the idea is NOT to use ['a]
<mfp>
but an external phantom type
<mfp>
(needs more camlp4)
<mrvn>
external to the class you mean? That would work.
<mfp>
yes
<mrvn>
I don't get why the typesystems doesn't allow methods to return diffrent 'a foo objects though.
filp has quit [Quit: Bye]
Waleee has joined #ocaml
yakischloba has joined #ocaml
avsm has joined #ocaml
bzzbzz has joined #ocaml
smimou has quit [Ping timeout: 268 seconds]
smimou has joined #ocaml
f[x] has quit [Ping timeout: 240 seconds]
f[x] has joined #ocaml
<mrvn>
Now everything seems to work great:
<mrvn>
./foo 1 7.28s user 0.01s system 100% cpu 7.291 total
<mrvn>
./foo 2 8.75s user 0.02s system 196% cpu 4.474 total
<mrvn>
./foo 3 9.76s user 0.03s system 298% cpu 3.285 total
<mrvn>
./foo 4 10.69s user 0.04s system 371% cpu 2.891 total
<mrvn>
Not totaly linear increase of cpu usage with threads but near enough.
<mrvn>
The increase in time is odd though. Does Mutex.lock do a busy wait till the mutex can be locked?
<mrvn>
or the leave_blocking_section()?
<mrvn>
Grrr, I still get random segfaults.
wu_ has joined #ocaml
{newbie} has joined #ocaml
ttamttam has quit [Quit: Leaving.]
f[x] has quit [Ping timeout: 248 seconds]
f[x] has joined #ocaml
wu_ has quit [Quit: leaving]
pimmhogeling has joined #ocaml
_unK has joined #ocaml
_zack has quit [Quit: Leaving.]
Waleee has quit [Ping timeout: 258 seconds]
f[x] has quit [Ping timeout: 240 seconds]
Waleee has joined #ocaml
tmaeda has quit [Ping timeout: 258 seconds]
tmaeda has joined #ocaml
<flux>
thelema, hmm, some BatString functions like split say that they throw Invalid_string, but that exception doesn't seem to be in the interface..
<flux>
infact, the function seems to raise Not_found anyway :) (which is better IMO)
<thelema>
ah, mistaken docs.
<thelema>
I removed the Invalid_string exception because I thought it was dumb. I guess I didn't fix the docs.
<thelema>
documentation fixes being checked in now
avsm has quit [Quit: Leaving.]
Smerdyakov has joined #ocaml
slash_ has joined #ocaml
mutewit has quit [Ping timeout: 264 seconds]
ikaros has joined #ocaml
ttamttam has joined #ocaml
{newbie} has quit [Quit: {newbie}]
Smerdyakov has quit [Ping timeout: 252 seconds]
Smerdyakov has joined #ocaml
brooksbp has joined #ocaml
mutewit has joined #ocaml
Submarine has joined #ocaml
ikaros_ has joined #ocaml
smimou has quit [Read error: Operation timed out]
ikaros has quit [Ping timeout: 248 seconds]
Smerdyakov has quit [Ping timeout: 252 seconds]
Yoric has quit [Quit: Yoric]
bzzbzz has quit [Quit: leaving]
Smerdyakov has joined #ocaml
oc13 has joined #ocaml
avsm has joined #ocaml
smimou has joined #ocaml
ygrek has joined #ocaml
derdon has joined #ocaml
bzzbzz has joined #ocaml
Smerdyakov has quit [Quit: happy trails]
tmaeda is now known as tmaedaZ
ygrek has quit [Ping timeout: 245 seconds]
smimou has quit [Read error: Operation timed out]
krankkatze has joined #ocaml
Yoric has joined #ocaml
enthymeme has joined #ocaml
krankkatze has quit [Ping timeout: 248 seconds]
krankkatze has joined #ocaml
smimou has joined #ocaml
Yoric has quit [Quit: Yoric]
emias has quit [Quit: Reboot because of Lüftertausch.]
tmaedaZ is now known as tmaeda
rwmjones has quit [Ping timeout: 245 seconds]
itewsh has joined #ocaml
Camarade_Tux has quit [Quit: Lost terminal]
Camarade_Tux has joined #ocaml
Camarade_Tux has quit [Client Quit]
Camarade_Tux has joined #ocaml
<flux>
cool, I got my first 8500-line error message from ocaml
<schme>
What says line #5436 ?
<flux>
wasted it already
<schme>
bummer :)
<flux>
but it was basically the signature of the ocamlgraph module
<schme>
ehehehe.
rwmjones has joined #ocaml
jcaose has joined #ocaml
Yoric has joined #ocaml
avsm has quit [Quit: Leaving.]
jcaose has quit [Quit: Leaving]
tmaeda has quit [Ping timeout: 258 seconds]
ikaros_ has quit [Ping timeout: 260 seconds]
ikaros_ has joined #ocaml
tmaeda has joined #ocaml
ulfdoz has joined #ocaml
tmaeda is now known as tmaedaZ
{newbie}_ has joined #ocaml
avsm has joined #ocaml
Waleee has quit [Ping timeout: 256 seconds]
Waleee has joined #ocaml
avsm has quit [Client Quit]
brooksbp_ has joined #ocaml
<derdon>
rwmjones: hello
brooksbp has quit [Ping timeout: 246 seconds]
Waleee has quit [Ping timeout: 276 seconds]
pimmhogeling has quit [Ping timeout: 265 seconds]
Yoric has quit [Ping timeout: 268 seconds]
ttamttam has quit [Quit: Leaving.]
Submarine has quit [Ping timeout: 246 seconds]
oc13 has quit [Read error: Operation timed out]
_andre has quit [Quit: /puff]
derdon has quit [Quit: derdon]
Modius has quit [Quit: I'm big in Japan]
brooksbp has joined #ocaml
emias has joined #ocaml
brooksbp_ has quit [Ping timeout: 268 seconds]
itewsh has quit [Quit: There are only 10 kinds of people: those who understand binary and those who don't]
mbishop has quit [Ping timeout: 276 seconds]
pimmhogeling has joined #ocaml
mbishop has joined #ocaml
albacker has quit [Quit: Leaving]
{newbie}_ has quit [Quit: {newbie}_]
ulfdoz has quit [Ping timeout: 276 seconds]
ikaros_ has quit [Read error: Operation timed out]