Eskatrem has quit [Remote host closed the connection]
pierpal has joined #ocaml
tormen has joined #ocaml
tormen_ has quit [Ping timeout: 240 seconds]
pierpa has quit [Quit: Page closed]
brettgilio has joined #ocaml
caltelt has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
<sshine>
reynir, cool§
<sshine>
is there a neater way to write: List.filter ~f(fun (foo, bar) -> bar > 0)?
<sshine>
whoops, ~f:
brettgilio has quit [Read error: Connection reset by peer]
thomas_scrace has joined #ocaml
thomas_scrace has quit [Ping timeout: 252 seconds]
jbrown has quit [Ping timeout: 240 seconds]
_whitelogger has joined #ocaml
Rosslaew has joined #ocaml
zlsyx has quit [Read error: Connection reset by peer]
zlsyx has joined #ocaml
KeyJoo has joined #ocaml
brettgilio has joined #ocaml
thomas_scrace has joined #ocaml
zlsyx has quit [Read error: Connection reset by peer]
zlsyx has joined #ocaml
thomas_scrace has quit [Ping timeout: 252 seconds]
brettgilio has quit [Quit: Konversation terminated!]
Rosslaew has quit [Remote host closed the connection]
Rosslaew has joined #ocaml
sz0 has joined #ocaml
trochdewei has joined #ocaml
trochdewei has quit [Quit: Leaving]
TC01 has quit [Ping timeout: 244 seconds]
TC01 has joined #ocaml
zlsyx has quit [Quit: Leaving...]
orbifx has joined #ocaml
bartholin has joined #ocaml
Rosslaew has quit [Remote host closed the connection]
Rosslaew has joined #ocaml
AltGr has joined #ocaml
Rosslaew has quit [Remote host closed the connection]
Rosslaew has joined #ocaml
Haudegen has joined #ocaml
sagotch has joined #ocaml
AltGr has quit [Disconnected by services]
freyr69 has joined #ocaml
orbifx has quit [Ping timeout: 252 seconds]
<sagotch>
I guess that it has already been discussed many time, but why isn't there a Array.make without values initialization? (Like Array.create_float)
<sagotch>
I guess it would be okay to pass a dummy value to get the needed length.
c4rc4s_ has joined #ocaml
c4rc4s has quit [Read error: Connection reset by peer]
c4rc4s_ is now known as c4rc4s
<def`>
sagotch: because it would be unsound?
<sagotch>
unsound?
<def`>
let x = Array.make_without_init 1 in x.(0)
<ZirconiumX>
Uninitialised variables, I think def` means
<gikiam>
UNDEFINED BEHAVIOR
<gikiam>
:>
<gikiam>
not exactly
<sagotch>
Just dont write this
<def`>
lol
<ZirconiumX>
That's not a solution
<ZirconiumX>
Which is why it doesn't exist
<ZirconiumX>
Alternatively you can turn the initialisation function into useful logic
<def`>
also it is not possible to implement in presence of float array specialization
<sagotch>
I am turning a hashtbl into an associative array. I cannot use init
<sagotch>
why float array specialization is a problem?
<reynir>
one way of "just dont write this" is to make it impossible
_andre_ has joined #ocaml
_andre has quit [Ping timeout: 264 seconds]
nicoo has quit [Ping timeout: 250 seconds]
nicoo has joined #ocaml
<sagotch>
I known, and I agree, but this is okay to have unsafe operation (unsafe getter and setters are available) if you know what you are doinf
<def`>
if you know what you are doing, then just use Obj.magic()
<sagotch>
def`: it would be Array.make_without_init 1 [], so type and length are known,
<def`>
what does that mean?
<sagotch>
I don't get the unsound problem
<def`>
My expression above has type 'a, for any 'a, that's what unsound means.
<ZirconiumX>
The whole point of the type system is to make illegal states unrepresentable
<sagotch>
yes, but with a dummy parameter you know the type of the array
<def`>
Then just use Array.make ?
<ZirconiumX>
And if you have a dummy parameter, you might as well use it to initialise something
<def`>
If you ignore unsoundness issues, float array specialization means that an array has a different representation in memory if it stores float. There is a representation for float, and one for anything-but-float.
<def`>
Here you would have some causality breaks because the representation would have to be chosen when the type of the array becomes known (that does not make much sense :)).
<def`>
which can happen (dynamically) arbitrarily long after allocations in you rmodel.
<emily>
have you profiled it as being a bottleneck in your application?
<sagotch>
Of course that it will never be a bottleneck
<emily>
hard to justify adding unsafety (potentially to the level of a security vulnerability) for something that will never be a bottleneck
<def`>
sagotch: what are you trying to achieve? You have a dummy value but you just want to skip the initialization?
<sagotch>
Yes
<def`>
It won't change the asymptotic complexity of your program, so why bother?
<def`>
The caml_initialize in your example could be made slightly more efficient, if that happens to be a bottleneck
<def`>
Open a mantis issue.
<sagotch>
"hard to justify adding unsafety (potentially to the level of a security vulnerability) for something that will never be a bottleneck"
<sagotch>
That's true
<def`>
There is one thing worrying about that caml_initialize, it seems easy to make the remembered set grow as big as the array that is being initialized with that, so it doubles the amount of work. That's a trade-off.
<def`>
If you know the type is not going to be float and that you will not read an uninitialized field, then Array.make len (Obj.magic ()) is ok.
<def`>
In your example, Array.make_without_init 1 [], [] is a constant so there is no initialization either.
<sagotch>
Hum... in what case does it go through the final else loop?
<ZirconiumX>
Does unit actually have a runtime representation, or is it completely elided by the type system?
<def`>
for a block
<def`>
"bla", (1,2), etc
<def`>
ZirconiumX: unit is represented as the constant 1
<def`>
The type system is just there to rule out incorrect program, types are not used to change runtime representation (even the float array specialization do not deal with types)
<def`>
However, when unit is used like "void" would be in C, it is elided (because it does not have to be represented at all).
<def`>
Using (String.make 0 ' ', []) will likely be young however.
<def`>
The reason is that because ("", []) is a literal constant, the compiler will optimize it (it does not need to be allocated).
jao has joined #ocaml
Eskatrem has joined #ocaml
<Eskatrem>
Hi, I am trying to compile a file, but `#load graphics.cma` at the first line is causing a syntax error
<_y>
while i see the issue with type soundness, i feel that initializing your array with a dummy value is a “value hack” of the same order of magnitude as returning −1 instead of None
<_y>
it may make you believe that your array is initialized whereas it actually isn’t, which may prevent you from catching bugs where you read a cell which has not been given a meaningful value yet
<_y>
but i guess that for that, you would have to use a wrapper datatype “'a option array” with an exception‐raising “get” method, with a huge performance penalty
<sagotch>
hum... a unitialized_array type could force you to use `Obj.magic` to use it as an array. You would then know that you should be very careful here.
<_y>
a datatype which brings Obj.magic into normal use sounds like a very bad idea
<sagotch>
def`: I should have understood it wrong, is Array.make n (String.make 0 ' ', []) likely to be faster than Array.make n ("", [])?
<_y>
but well you may have array_of_uninitialized_array (wow, that’s so hard to spell) which would raise an exception if your array is not fully initialized
<sagotch>
How would you known?
<_y>
well as the implementor of your abstract datatype, you know how it is implemented :p
<def`>
without float array specialization, it is possible to do the hack :P (with a special repr for "null")
<_y>
either 'a option array, or terrible hacks around float arrays, or who-knows-what
<def`>
sagotch: uhhh, it is too complicated to really say which one is faster. Just consider that caml_initialize is fast.
<def`>
the other case does a minor collection.
mfp has joined #ocaml
<def`>
Our discussion is quite pointless, these problems are not really relevant :P
<sagotch>
C'est vrai
<sagotch>
But I needed to know, sorry ^^
dacid has joined #ocaml
<_y>
def`, which hack would be possible without the float array optimization, which is not possible today?
<def`>
The truth is that reality is a bit more complex :) and I think this part could be marginally optimized, but hmm, that's not really worth the effort unless you come with a test case that really degenerates.
<emily>
_y: i agree that constant initialisers for arrays are disappointing
<emily>
rust manages to do a bit better in this area fwiw
<reynir>
There's also Array.init
jaar has joined #ocaml
<_y>
def`, i never looked into the GC, does it understand null pointers (NULL, as in zero),ç or would null pointers make it crash?
thomas_scrace has quit [Ping timeout: 252 seconds]
<def`>
_y: null pointers make it crash, but that could be "fixed"
<Eskatrem>
sorry, nobody can help me to compile a file where I load a module?
<Ulrar>
Wait, you can't do "open X as Y" in ocaml ?
<Ulrar>
Spent too much time on haskell ..
<ZirconiumX>
File I/O in OCaml is fairly imperative
<Eskatrem>
if I do `open Graphics;;` I get the compile error `Error: Could not find the .cmi file for interface graphics_test.mli.`. If I do `#loadd "graphics.cma"` it says I have a syntax error
<bartholin>
#load
<Eskatrem>
yes, #load
<Eskatrem>
(not #loadd - the syntax error is at the first character anyway)
<bartholin>
in the toplevel?
<Eskatrem>
what do you mean, toplevel?
thomas_scrace has quit [Ping timeout: 250 seconds]
Haudegen has quit [Remote host closed the connection]
<bartholin>
Eskatrem: on a terminal, type ocaml to launch the ocaml toplevel (the command-line ocaml interpreter).
<def`>
Ulrar: module Y = X
thomas_scrace has joined #ocaml
<Eskatrem>
bartholin: ah, in the interpreter it works, it's when I am trying to compile the file with ocamlc
<bartholin>
ok
<Eskatrem>
if I run "ocaml myfile.mli" it works
<Ulrar>
def`: Oh right
<Ulrar>
thanks
<sagotch>
For graphics module, I think that youb should add graphics.cm(x)a to your compilation line
<bartholin>
Eskatrem: remove the #load "graphics.cma" line (put it in your .ocamlinit file), then ocamlc graphics.cma file.ml -o program
<_y>
def`, oh i see :-) if you use your datatype with immediate values (int, bool, …) will the GC be fine with the fact that you mix pointers and immediate values in an array?
<bartholin>
(generated program name is what you write after -o)
<_y>
also, i guess that you could add a dynamic check that the array returned by Array.make is not a float array, and throw Float_array_are_not_supported
<Eskatrem>
bartholin: I have to compile the .mli file before that no? when running your instruction I get: "Error: Could not find the .cmi file for interface graphics_test.mli."
<bartholin>
Eskatrem: is graphics_test.ml your source code file?
kini has quit [Remote host closed the connection]
<Eskatrem>
bartholin: yes
<def`>
_y: this test would have to take place in set
<bartholin>
graphics_test.mli should be an empty file
<def`>
_y: That's sketchy but ok with current implementation
<def`>
:P
<Eskatrem>
it's the code I put on pastebin. I removed the #load "graphics.cma" and put that in .ocamlinit
<bartholin>
for now
<Eskatrem>
ok, so I have my .ml file with the code. I create a .mli file with nothing in it, then I run `ocamlc graphics.cma graphics_test.ml -o program" ??
<bartholin>
the .mli file is optional
<Eskatrem>
ok, but when I do that, I get the error: "Error: Could not find the .cmi file for interface graphics_test.mli."
<bartholin>
oh ok
<bartholin>
Eskatrem: ocamlc graphics.cma graphics_test.mli graphics_test.ml -o program
kini has joined #ocaml
<Eskatrem>
graphics_test.mli is empty?
<bartholin>
yes
<Eskatrem>
wow, that one worked
<bartholin>
you put in the .mli file the stuff you declared in the .ml file (let () = ... does not count), so there is nothing.
sagotch has quit [Quit: Leaving.]
<bartholin>
now you can do ./program
<Eskatrem>
bartholin: do you know where to find about it - I googled before asking this stuff but I couldn't find anything
<xvilka>
Eskatrem: just start with dune project from the beginning
<Eskatrem>
so far I found ocaml quite neat and really fast, it's a shame it can be so complicated to build something
<xvilka>
Eskatrem: it is not, with dune
<Eskatrem>
xvilka: I believe you, but dune is not the default "ocaml builder"
<xvilka>
Eskatrem: cargo is not default "rust builder" too, but everyone uses it. In OCaml it is similar
<Eskatrem>
fair enough
Rosslaew has quit [Remote host closed the connection]
Rosslaew has joined #ocaml
Rosslaew has quit [Remote host closed the connection]
Rosslaew has joined #ocaml
sagotch has joined #ocaml
Rosslaew has quit [Ping timeout: 260 seconds]
neatonk has joined #ocaml
ziyourenxiang has joined #ocaml
sagotch has quit [Client Quit]
keep_learning has quit [Ping timeout: 252 seconds]
Rosslaew has joined #ocaml
<def`>
yes, there was not a consensus until a few months ago, but since everybody agreed that dune is ocaml builder :P (fairly recent but lot of traction)
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
thomas_scrace has quit [Ping timeout: 245 seconds]
thomas_scrace has joined #ocaml
<_y>
yes, i was surprised to find it under ocaml/ on github, rather than janestreet/
sagotch has joined #ocaml
silver has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
* emily
finds the (apparent?) recent momentum in the ocaml community heartening (as a former haskell user)
<dmbaturin>
emily: Haskell survivor? :)
<dmbaturin>
Recently someone who tried to cross-compile my project found that dune doesn't appear to follow the (mode (bytes)) directive properly. I need to reproduce it myself of course.
<emily>
survivor is quite the word for it ^^
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
Rosslaew has quit [Ping timeout: 260 seconds]
Denommus` has joined #ocaml
<flux[m]>
IMO dune is really the first ocaml build system that's both easy to configure but also flexible. I think with my minimal exposure ;-), but certainly beats dealing with myocamlbuild.ml. everyone should just switch to is ASAP :)
<flux[m]>
certainly a boon that it's also composable.
<flux[m]>
what I miss that dune doesn't by default just build some default target like make does. you basically need to accompany a ./make.sh along the project or instruct it in the README.md. not just for your users' sake (who has users anyway?!) but yourself sake when you return to the project after a long hiatus ;-).
<flux[m]>
my make.sh says dune build -j 8 @install; ln -sf _build/install/default/bin/ibt ibt - I guess dune is not able to do those steps automatically with plain configuration?
Denommus has quit [Ping timeout: 252 seconds]
<_y>
i do not find dune flexible
<flux[m]>
what did you want it to do?
<_y>
maybe that’s because what i try do to is not The Right Way
<_y>
but i feel like it has been designed for a very precise workflow
<_y>
“opinionated” in dune’s description is the keyword
<_y>
but still it’s a thousand times better than having to talk to the actual compiler :-}
<flux[m]>
I guess I'll see when porting old projects to that
<flux[m]>
I never quite got my _tags and myocamlbuidl.ml right for a project involving multiple directories, multiple phases (ml -> bytecode -> ml + c + h -> compile) dependencies working correctly.
brettgilio has joined #ocaml
<discord>
<mseri> @flux[m] you should be able to say dune exec ibt.exe and have it compiled if needed and run by dune itself
<flux[m]>
that's a nice feature though not what I'm really looking for
<flux[m]>
I mean who really runs their program via their build system, unless it's for the test cases?-)
<discord>
<mseri> Fair enough, but why do you need the executable on the root of your project
<flux[m]>
well, root might be overkill, but it's something a non-ocaml-coding admin might expect to happen when they build software. plain bin/ibt would be appropriate as well.
<flux[m]>
but it's nice how it does come with 'dune install' AND uninstall
<flux[m]>
and dune install --prefix=$HOME works mostly as I hope
<discord>
<mseri> I see, but I think it would be probably enough to specify this on the readme if it is really an issue. I think keeping the workspaces clean and separate is a benefit of dune compared for example to oasis
<discord>
<mseri> I think also cargo does the same now that I think of it
<discord>
<mseri> I wonder what else
erkin has quit [Remote host closed the connection]
Bronsa has quit [Remote host closed the connection]
Bronsa has joined #ocaml
al-damiri has joined #ocaml
KeyJoo has quit [Ping timeout: 240 seconds]
spew has joined #ocaml
brettgilio has quit [Quit: Konversation terminated!]
thomas_scrace has quit [Ping timeout: 240 seconds]
sagotch has quit [Quit: Leaving.]
thomas_scrace has joined #ocaml
sagotch has joined #ocaml
jbrown has joined #ocaml
johnelse_ has quit [Ping timeout: 250 seconds]
aciniglio has joined #ocaml
thomas_scrace has quit [Ping timeout: 272 seconds]
mfp has quit [Ping timeout: 240 seconds]
aciniglio has quit [Ping timeout: 252 seconds]
sagotch has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
gareppa has joined #ocaml
Evel-Knievel5 has joined #ocaml
klx``22 has joined #ocaml
Evel-Knievel5 has quit [Killed (Sigyn (Spam is off topic on freenode.))]
Eskatrem` has joined #ocaml
klx``22 has quit [Remote host closed the connection]
__idiot__ has joined #ocaml
Eskatrem has quit [Ping timeout: 272 seconds]
__idiot__ has quit [Remote host closed the connection]
Hoosilon18 has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
Hoosilon18 has quit [Ping timeout: 240 seconds]
thomas_scrace has joined #ocaml
freyr69 has quit [Remote host closed the connection]
mfp has joined #ocaml
FreeBirdLjj has joined #ocaml
Xe16 has joined #ocaml
Xe16 has quit [Ping timeout: 240 seconds]
Bonn33320 has joined #ocaml
Bonn33320 has quit [Remote host closed the connection]
<_y>
flux[m], i should have added that i only have a very short experience with dune
<_y>
the two issues i ran into are: (1) hiding internal modules (to be fair, the namespacing problem is not dune’s guilt; but abstraction is not only about namespacing, and that issue feels really weird, for a language which praises so much its module system geared towards abstraction)
<orbifx>
folk, I'm naming a package, can't decide between logarion-httpd or logarion-web
jnavila has joined #ocaml
jnavila has quit [Client Quit]
<orbifx>
It's the "web" server module for logarion
<orbifx>
Any thoughts?
brettgilio has joined #ocaml
<thizanne>
logarion-webserver
JeanMax has joined #ocaml
<companion_cube>
ok so anyone knows how to tell dune to compile a C library?
<companion_cube>
I mean, to invoke some `action` before it builds an OCaml library
<companion_cube>
(e.g. to build a local C library)
<companion_cube>
the way deps can be specified is really… basic)
<orbifx>
thizanne: I had just gone the other way. Care to throw in a reason, before I go rename everything? :P
<orbifx>
companion_cube: I think I may have done this a long time ago, no longer remembering if and how... :/
<companion_cube>
this is really terrible
<orbifx>
my memory, your situation, or both? :P
<companion_cube>
my situation
<companion_cube>
well I made horrible hacks to have it build the lib anyway, but now it's all a nightmare of .so and all
<companion_cube>
I need to find how to statically link the C library into the stubs' .so
jack5638 has quit [Ping timeout: 245 seconds]
<thizanne>
orbifx: I don't have a strong opinion and you're the author anyway, but it seemed clearer to me so I was throwing it just in case you did not think about it
<orbifx>
thizanne: that's why I was asking. I'm split about it and wanted a nudge someway. Some days I think it's a narrow to think the web as http+html, but it's what it has become
<orbifx>
companion_cube: how do you feel about Makefiles? :P
<companion_cube>
right now I feel like they're pretty nice -_-
<companion_cube>
well I don't know the low level OCaml compilation commands, though, when it comes to using C stubs
<orbifx>
I think my solution was to wrap the whole process in a Makefile, which would call gcc or jbuilder (At the time)
jack5638 has joined #ocaml
<companion_cube>
still doesn't help me link statically my .a into the stubs .so
<companion_cube>
well, I can disable dynlink for now… toplevel be damned
<orbifx>
are you not producing the .so with gcc?
<companion_cube>
no, with rustc… :s
<orbifx>
can't you tell that to statically link?
<companion_cube>
I mean it's produced, but I don't want it, I'd rather merge it into the stub .so
<companion_cube>
thing is: I can make a foo.a and foo.so, that's fine
<companion_cube>
but then `dune runtest` doesn't know about foo.so so it fails to link it in the test program (and probably also in the toplevel)
bartholin has quit [Remote host closed the connection]