ikaros has quit [Quit: Leave the magic to Houdini]
metasyntax has quit [Quit: ♫ In our sky there is no limits, and masters we have none; heavy metal is the only one! ♫]
dnolen has quit [Quit: dnolen]
Yoric has quit [Quit: Yoric]
dnolen has joined #ocaml
rwmjones has quit [Read error: Operation timed out]
rwmjones has joined #ocaml
dnolen has quit [Quit: dnolen]
lopex has quit [Ping timeout: 250 seconds]
grettke has joined #ocaml
gildor has quit [Ping timeout: 250 seconds]
gildor has joined #ocaml
Cyanure has quit [Remote host closed the connection]
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
ulfdoz_ is now known as ulfdoz
grettke has quit []
lopex has joined #ocaml
lewis1711 has joined #ocaml
pantsd has quit [Read error: Operation timed out]
pantsd has joined #ocaml
sepp2k has joined #ocaml
surikator has joined #ocaml
alexyk has quit [Quit: alexyk]
alexyk has joined #ocaml
alexyk has quit [Read error: Connection reset by peer]
tauntaun has quit [Quit: Ex-Chat]
alexyk has joined #ocaml
alexyk has quit [Read error: Connection reset by peer]
npouillard has quit [Ping timeout: 248 seconds]
pension has left #ocaml []
npouillard has joined #ocaml
alexyk has joined #ocaml
<lewis1711>
so I am tooling around defining an infix binary function, ( +$ ). except right now whenever I have something like "a +$ b +$ c" I get an infinite recursion. what's the way around this?
alexyk has quit [Read error: Connection reset by peer]
surikator has quit [Quit: surikator]
surikator has joined #ocaml
alexyk has joined #ocaml
alexyk has quit [Read error: Connection reset by peer]
alexyk has quit [Read error: Connection reset by peer]
<surikator>
@lewis1711 your pattern matching is not complete
<surikator>
@lewis1711 your _ case isn't working as you want
<surikator>
@lewis1711 there's no pattern matching for Mult or Div or Sub
<lewis1711>
hmm. how should it be done?
<lewis1711>
oh yes
EM03 has joined #ocaml
<surikator>
@lewis1711 do you understand what's causing the infinite loop?
<lewis1711>
it keeps going to the wild card, i imagine
<lewis1711>
though i figured in the example I used it should go to the one above the wild card and resolve that way
<surikator>
@lewis1711 your example is equivalent to "Mult (Const 2., Var "x") +$ (Const 3.0);;" (after the first +$ is computed)
<surikator>
such case is not in the list of patterns
<surikator>
so it will use the last case
<lewis1711>
ahh
<lewis1711>
of course
<surikator>
but this last case maps "Mult (Const 2., Var "x") +$ (Const 3.0);;" precisely to "Mult (Const 2., Var "x") +$ (Const 3.0);;"
<surikator>
and it never returns
<lewis1711>
So i'd need to write a lot more patterns... which lends me to believe i am going about this in the wrong way in the first place
<lewis1711>
May have to rethink this one altogether. perhaps two types, one for symbol and one for an expression
alexyk has joined #ocaml
<surikator>
i think it depends on what you want... do you want a representation for any polynomial?
<surikator>
and then what do you want to do with them? simplification?
<surikator>
(it's also a bit strange that your operation is called +$ but it can deal with multiplication too...)
<lewis1711>
simplifcation. would mainly like to be able to write functions for equations where i don't know all the variables, and get at a partially complete answer as a result
<lewis1711>
that was jsut to simplify "x + x = 2x" but I guess it doesn't belong there you're right
<surikator>
yes, but then you miss x+2x = 3x
<surikator>
and all the others
<lewis1711>
ah, indeed
<lewis1711>
is there a way to return an unapplied function?
<lewis1711>
that'd make things simpler
<surikator>
yes, there is, sure
<lewis1711>
"(Var "x") +$ (Const 3.0)" could just return itself
<lewis1711>
for example
alexyk has quit [Quit: alexyk]
<surikator>
ok, that's where i'm not getting what you want.... you're considering "(Var "x") +$ (Const 3.0)" to be a function? is that the function which takes some number (x) and returns (x+3)?
joewilliams_away is now known as joewilliams
<surikator>
it would be easier for me if you just gave me an example of what you want. you would like to write "2x+y+5" (in your notation of Var/Const and +$, of course) and get what?
<surikator>
the function "let f x y = 2*x+y+5"?
<lewis1711>
hmm, a better example is maybe
<lewis1711>
yes]
<lewis1711>
something like that
<lewis1711>
let f x y = x +$ y;; f (Const 2.0) (Sym "x") => 2.0 +$ (Sym "x")
<surikator>
ok, i'm confused now...
<surikator>
that function you wrote is just the infix idea... what you really want (I suppose) is to define the +$ function...
<lewis1711>
yes. I'm not doing that? :(
<surikator>
the function "let f x y = x +$ y" is just saying that you take x and y and return x +$ y
<lewis1711>
yes. if I know x and y compute it, if not return the partially computed function
<lewis1711>
let f x y z = x +$ y +$ z;; f (Const 3.0) (Const 4.0) (Var "x") => 7.0 +$ (Var "x")
<surikator>
to define a function you need to fix how many arguments it will have
<surikator>
here you're using f with 3 args... above you were using 2
<surikator>
i think your definition of "f" there is not the best angle for your problem. you want (as you stated in the beginning) to define an infix operator +$... and you want to compute as much of the expression as possible
<lewis1711>
F was an example function, with which I would use +$
<surikator>
ah
<surikator>
sorry
<lewis1711>
to get a simplified result when I didn't know the numerical value
<lewis1711>
no worries
<surikator>
ok
<lewis1711>
let rec ( +$ ) a b = match (a, b) with
<lewis1711>
am trying something like that, but then I need to make the function signature a valid sym type
<surikator>
yep
<surikator>
it won't work if you return functions for +$
<surikator>
because of the types
<surikator>
but... you realise that the general problem is not solvable with a simple +$ function... in your f example above if you choose "f (Const 3.0) (Var "x") (Const 4.0)", it won't be able to simplify
<surikator>
it would need to know of commutativity of addition
<surikator>
or some simplification techniques
<lewis1711>
yeah, I'd need more functions
<lewis1711>
anyway I had better go and get some other stuff done. hopefully I'll figure out this function type stuff eventually
<lewis1711>
ty surikator
lewis1711 has left #ocaml []
vivanov has joined #ocaml
lopex has quit []
<orbitz>
I have type t = int * int;; let foo = (1, 2), does the ocmpiler know foo is a t?
avsm1 has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
emmanuelux has quit [Read error: Operation timed out]
surikator has quit [Quit: surikator]
ygrek has joined #ocaml
EM03 has quit [Ping timeout: 250 seconds]
EM03 has joined #ocaml
<EM03>
ocaml with textmate is not fun :\
joewilliams is now known as joewilliams_away
alexyk has joined #ocaml
<alexyk>
I'm using bigarray to interface with C. I include <caml/bigarray.h> in stubs, compile OK; linking shows things missing such as "_caml_atom_table", "_caml_code_area_start", "_caml_code_area_end". What do I need to add to ocamlopt line to link right?
<adrien>
do you link against the bigarray module?
<alexyk>
adrien: I use -package bigarray, among others, should it do it for me?
<alexyk>
with findlib
<alexyk>
I first create a library lib.cmxa with ocamlmklib which includes .o files. I then compile/link using lib.cmxa as the first file and then some .ml ones
<alexyk>
I wonder if lib.cmxa comes too early in linking before ocamlopt defines the main program, is it possible?
Snark has joined #ocaml
<adrien>
alexyk: you use -linkpkg?
<alexyk>
yes
Oejet has joined #ocaml
<alexyk>
ok, I changed library creation to ocamlmklib for all cmo, cmx, .o if present. It now wants -lsgraph where sgraph has no .o... I supply sgraph.cmxa, which worked before ocmalmklib, with ocamlc -a -o sgraph.cmxa. Why would it need -lsgraph?
Associat0r has quit [Ping timeout: 255 seconds]
<adrien>
sgraph, what is it? the library you're binding to?
<alexyk>
in fact, I have sgraph.a in the local directory, it;s the one I build with ocamklib now
<alexyk>
I tried passing --ccopt -L., but it still is not working
<adrien>
it's possible that ocamlmklib overwrites some files
<alexyk>
before ocamlnklib, I created sgraph.cmxa with ocamlc -a -o sgraph.cmxa, there was no .a at all
<adrien>
if you are building foo.ml and want ocamlmklib to create libfoo.a, you'll have a conflict iirc
<alexyk>
sgraph uses no C, no .o, I need to sgraph.a
<alexyk>
I need no sgraph.a, but ocamlmklib creates it
<adrien>
actually, you need it ;-) (but I don't remember the details)
<adrien>
and make sure that ocamlmklib doesn't create files with the same name as other compilation steps, that means appending something like "_stubs" to the output (-o) name
Oejet has left #ocaml []
<adrien>
what are you writing bindings to?
<alexyk>
ok, sgraph.a is there; similar problem, shorter line, for -lanygraph: ocamlfind ocamlopt -g -inline 100 -ccopt -L. -package batteries,tokyo_cabinet,otoky,json-wheel,getopt,unix,bigarray -linkpkg lib.cmxa anygraph.cmxa save_graph.ml -o save_graph.opt
<alexyk>
ld: library not found for -lanygraph
<alexyk>
I bind to a single C file with a single function taking two bigarrays and returning a float
<alexyk>
so you see above, anygraph.cmxa exists, now made with ocamlmklib, so anygraph.a is present. Who needs -lanygraph which cannot be found?
<adrien>
iirc you can do that with "cc -c foo.c" and then add "foo.o" to the ocamlopt call, it's simpler than ocamlmklib and worked well when I last tried it
<adrien>
maybe someone is aware of a drawback to that method?
<rproust>
orbitz: the compiler knows foo is of type int * int and it knows that the two types are equal
<rproust>
orbitz: you can do "let foo : t = (1,2)" if you want the type to be printed as "t" (and if you hide the type in a module and want foo to be of the abstract type)
<alexyk>
adrien: so I reordered things, provide a lib.a with my .o files to ocamlopt, it still cannot find "_caml_atom_table", etc. When I compile .o, I only gave -I`ocamlc -where`, but the symbols are named properly, are they provided by ocamlopt or I need something explicit?
<adrien>
ocamlopt calls ld and it should call it with the required arguments: you can check that with the -verbose switch
<adrien>
nm shows your symbols as "common symbols" but I don't understand what it means =/
<alexyk>
I also don't have "_CAMLreturn", which I need
<adrien>
ok, you built your own makefiles to compile the bindings?
<alexyk>
yes
<adrien>
it's really tricky: you could try with OCamlMakefile instead: you'll have to define a few variables and it'll manage everything else
<adrien>
I think oasis should work well for that too
Yoric has joined #ocaml
boscop has joined #ocaml
Associat0r has joined #ocaml
lamawithonel has quit [Ping timeout: 246 seconds]
lamawithonel has joined #ocaml
ikaros has joined #ocaml
eye-scuzzy has quit [Quit: leaving]
eye-scuzzy has joined #ocaml
<alexyk>
I cannot include <caml/memory.h> since it reports that caml__frame is undefined... where does it come from in 3.12.0?
Tianon has quit [Read error: Operation timed out]
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
eye-scuzzy has quit [Ping timeout: 260 seconds]
alexyk has quit [Quit: alexyk]
alexyk has joined #ocaml
cthuluh has quit [Ping timeout: 260 seconds]
<alexyk>
how do we return a single C double to OCaml? There's no Val_double...
cthuluh has joined #ocaml
eye-scuzzy has joined #ocaml
<adrien>
caml_copy_double if I remember correctly
<adrien>
for caml/memory.h, I don't know and I'm a bit surprised, but are you sure it's the issue, I think you can have issues with caml__fram if you CAMLreturn without using CAMLlocalX/CAMLsomething for arguments and local values
<adrien>
(you might want to take a look at the corresponding code for the macros, if that's the issue, it'll show why you need to use both in pairs)
ikaros has quit [Quit: Leave the magic to Houdini]
ikaros has joined #ocaml
<alexyk>
adrien: yes, solved by adding CAMLparam2, including memory. Now can compile with ocamlopt -shared!
<adrien>
=)
<alexyk>
Can I call an OCaml function using an external C function from repl?
<alexyk>
to test
<alexyk>
or I have to natively compile a test...
<adrien>
yes
<alexyk>
yes what?
<adrien>
repl
<adrien>
but I think you have to start it with "-I ."
<adrien>
you should test as native and bytecode too however
<alexyk>
where do I put -|?
<alexyk>
and how do I load the code defining the external into repl? When I load stub.cmo it;s OK, but when I try to load the driverm it says the external is not available
<adrien>
ocaml -I ., uppercase 'i', not '|'
<adrien>
it should load a .so automatically iirc
<alexyk>
ocaml for repl doesn't take -I :(
<adrien>
my "ocaml" command accepts it, what are you using exactly?
<alexyk>
it accepts -I .
<alexyk>
ocaml 3.12.0
<adrien>
yeah, it needs a folder to add to the path =)
<alexyk>
ah ok
<alexyk>
missed it the first time
<alexyk>
but it doesn't load my dll
<adrien>
"external function is not available"?
Cyanure has joined #ocaml
<alexyk>
yep
<adrien>
yours or the library one?
<adrien>
I mean: typically, when binding a function, you write an intermediate one: is it the intermediate one that is not available or the other one?
<alexyk>
the intermediate one
<adrien>
I think the .cma has to specify what to load in its header but I don't remember that part well, sorry
<alexyk>
hmm -- I call it the same name as the C one, is it OK?
<adrien>
don't think so, it should have told you there was a conflict however
<adrien>
the intermediate ones are typically prefixed with "ml_"
<adrien>
actually, no conflict
<alexyk>
ok
<alexyk>
I think it now loads :) I was loading cmo, not cma
<adrien>
good =)
oriba has joined #ocaml
alexyk has quit [Quit: alexyk]
hsuh has joined #ocaml
lamawithonel has quit [Ping timeout: 248 seconds]
lamawithonel has joined #ocaml
sepp2k1 has joined #ocaml
sepp2k has quit [Ping timeout: 255 seconds]
oriba has quit [Quit: Verlassend]
ikaros_ has joined #ocaml
ikaros has quit [Ping timeout: 250 seconds]
lopex has joined #ocaml
ikaros_ has quit [Ping timeout: 250 seconds]
adlsaks has joined #ocaml
ikaros_ has joined #ocaml
adlsaks has quit [Ping timeout: 240 seconds]
adlsaks has joined #ocaml
adlsaks has quit [Remote host closed the connection]
ikaros_ has quit [Read error: Connection reset by peer]
brendan has quit [Read error: Operation timed out]
edwin has joined #ocaml
brendan has joined #ocaml
emmanuelux has joined #ocaml
Associat0r has quit [Quit: Associat0r]
ikaros_ has joined #ocaml
emmanuelux has quit [Ping timeout: 248 seconds]
ygrek has quit [Ping timeout: 246 seconds]
ygrek has joined #ocaml
Yoric has quit [Quit: Yoric]
edwin has quit [Quit: Leaving.]
edwin has joined #ocaml
surikator has joined #ocaml
<surikator>
@orbitz the compiler won't know, but it will allow you to do anything with foo that you can do with t
<surikator>
@orbitz it will also allow you to do with it anything that you can do with int*int... which may not be your intention. if you really want to impose the type t on foo, you should do let foo : t = (1,2)
<surikator>
@orbitz but everything will be OK if you don't and use foo in a t context
surikator has quit [Client Quit]
Cyanure has quit [Remote host closed the connection]
yezariaely has joined #ocaml
tauntaun has joined #ocaml
alexyk has joined #ocaml
<alexyk>
I get exec format error if I compile and link with ocamlopt -shared -o progname... it links fine then doesn't run... why?
trigen has quit [Read error: Connection reset by peer]
<adrien>
what do you think -shared does?
<alexyk>
adrien: I assumed it links dynamically... but I found now the root of all problems -- my C had its own main, triggereed by a #define for testing! Now I removed that and things run.
<alexyk>
or started to run)
<adrien>
-shared is meant to produce .cmxs files
<adrien>
loadable modules, not executables with a main()
tauntaun has quit [Quit: Ex-Chat]
mcclurmc_ has quit [Quit: Leaving.]
mcclurmc_ has joined #ocaml
mcclurmc_ has quit [Ping timeout: 255 seconds]
yezariaely has left #ocaml []
joewilliams_away is now known as joewilliams
avsm1 has quit [Quit: Leaving.]
hsuh has quit [Quit: hsuh]
philtor has joined #ocaml
lopex has quit []
lopex has joined #ocaml
Smerdyakov has joined #ocaml
Yoric has joined #ocaml
oriba has joined #ocaml
BiDOrD has quit [Read error: Operation timed out]
BiDOrD has joined #ocaml
emmanuelux has joined #ocaml
wormphlegm has joined #ocaml
avsm has joined #ocaml
Snark has quit [Quit: Ex-Chat]
wormphlegm has quit [Read error: Connection reset by peer]
wormphlegm has joined #ocaml
mcclurmc_ has joined #ocaml
oriba has quit [Read error: Connection reset by peer]
Smerdyakov has quit [Quit: Leaving]
hsuh has joined #ocaml
tauntaun has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
<alexyk>
thelema: Array.map2i is imssing
<alexyk>
while Array.iter2i is present
adrien is now known as Camarade_Tux
wormphlegm has quit [Read error: Connection reset by peer]
avsm has quit [Quit: Leaving.]
tauntaun has quit [Ping timeout: 255 seconds]
ygrek has joined #ocaml
philtor has quit [Read error: Operation timed out]
alexyk has quit [Quit: alexyk]
surikator has joined #ocaml
joewilliams is now known as joewilliams_away
myu2 has quit [Remote host closed the connection]
enthymeme has joined #ocaml
Camarade_Tux is now known as adrien_
adrien_ is now known as adrien
dnolen has joined #ocaml
dnolen has quit [Excess Flood]
dnolen has joined #ocaml
tauntaun has joined #ocaml
Cyanure has joined #ocaml
coucou747 has joined #ocaml
lopex has quit [Ping timeout: 264 seconds]
lopex has joined #ocaml
Cyanure has quit [Remote host closed the connection]
sepp2k1 has quit [Quit: Leaving.]
surikator has quit [Quit: surikator]
alexyk has joined #ocaml
surikator has joined #ocaml
mnabil has joined #ocaml
Associat0r has joined #ocaml
Associat0r has quit [Changing host]
Associat0r has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
ikaros_ has quit [Quit: Leave the magic to Houdini]
mnabil has quit [Remote host closed the connection]
surikator has quit [Quit: surikator]
edwin has quit [Remote host closed the connection]