adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.07.1 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.07/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml | Due to ongoing spam, you must register your nickname to talk on the channel
spew has quit [Quit: Connection closed for inactivity]
tristero has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
oni-on-ion has quit [Quit: Leaving]
ziyourenxiang__ has joined #ocaml
mfp has quit [Ping timeout: 255 seconds]
AnAverageHuman has joined #ocaml
jao has quit [Ping timeout: 255 seconds]
AtumT has quit [Quit: AtumT]
tormen has joined #ocaml
tormen_ has quit [Ping timeout: 246 seconds]
xuib has quit [Quit: xuib]
gravicappa has joined #ocaml
_whitelogger has joined #ocaml
al-damiri has joined #ocaml
silver has joined #ocaml
kvda has joined #ocaml
ygrek has quit [Ping timeout: 244 seconds]
AnAverageHuman has quit [Ping timeout: 256 seconds]
Birdface has joined #ocaml
zv has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oni-on-ion has joined #ocaml
kvda has joined #ocaml
kvda has quit [Client Quit]
gravicappa has quit [Ping timeout: 268 seconds]
crowley95 has quit [Ping timeout: 245 seconds]
oni-on-ion has quit [Quit: Leaving]
crowley95 has joined #ocaml
Birdface has quit [Ping timeout: 240 seconds]
mildtaste has joined #ocaml
Bahman has joined #ocaml
Birdface has joined #ocaml
Birdface has quit [Max SendQ exceeded]
Birdface has joined #ocaml
zv has quit [Ping timeout: 240 seconds]
Birdface has quit [Remote host closed the connection]
Birdfacee has joined #ocaml
Keodedad has joined #ocaml
Birdfacee has quit [Ping timeout: 255 seconds]
zv has joined #ocaml
dhil has joined #ocaml
Birdface has joined #ocaml
freyr69 has joined #ocaml
bernard22300 has joined #ocaml
barockobamo has joined #ocaml
bernard22300 has left #ocaml [#ocaml]
ziyourenxiang__ has quit [Ping timeout: 245 seconds]
Birdface has quit [Remote host closed the connection]
Birdface has joined #ocaml
gravicappa has joined #ocaml
Keodedad has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<rwmjones> caml_alloc_string (from C) allocates a zeroed string? ... I think not?
<def`> No
<def`> At least there is no such guarantee.
ziyourenxiang has joined #ocaml
pierpal has quit [Ping timeout: 255 seconds]
<rwmjones> yup, that's a shame, introduces a CVE in my code :-(
<rwmjones> in fact it says it in the documentation, now I've found that ...
<rwmjones> "caml_alloc_string(n) returns a string value of length n characters. The string initially contains garbage. "
<rwmjones> oh well
kjak has quit [Ping timeout: 246 seconds]
<def`> Because you want to guarantee that some information is erased?
<def`> this point was mentioned in a report about application of OCaml for secure application (LaFoSec report, in french though).
<def`> If you want that kind of guarantee, you should rather allocate outside the OCaml heap, to guarantee that collecton and compaction won't leave duplicate of your data around.
<def`> (Similar concerns apply to the OS: you should allocate secure memory that can't be swapped to store secret information)
Keodedad has joined #ocaml
mfp has joined #ocaml
<rwmjones> def`: yeah our server could return random heap memory back to the client :-(
freyr69 has quit [Remote host closed the connection]
al-damiri has quit [Quit: Connection closed for inactivity]
Birdface has quit [Ping timeout: 276 seconds]
gahr has quit [Quit: leaving]
silver has quit [Read error: Connection reset by peer]
silver has joined #ocaml
gahr has joined #ocaml
Birdface has joined #ocaml
Birdface has quit [Remote host closed the connection]
Birdface has joined #ocaml
freyr69 has joined #ocaml
kakadu has joined #ocaml
dannysantos has joined #ocaml
<dannysantos> hi people
<dannysantos> I'm new to ocaml and am trying to program in liquidsoap
<dannysantos> I have this doubt:
<dannysantos> s=map_metadata(add_title,s) . I want add_title function to receive another argument (for example: v). would s=map_metadata((add_title self v),s) be correct?
<dannysantos> map_metadata is a liquidsoap function and add_title function is made by me
<dannysantos> the argument of add_title is not explicit so when I want to add a second argument I don't know how to call the function
Keodedad has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<octachron> You can use anonymous function to adapt the function, for instance "fun self -> add_title self v"
<dannysantos> i need to learn a bit more
<dannysantos> thanks
hannes` has left #ocaml [#ocaml]
hannes has joined #ocaml
carlosdagos has joined #ocaml
Birdface has quit [Remote host closed the connection]
dannysantos has left #ocaml ["Leaving"]
Birdface has joined #ocaml
Birdfacee has joined #ocaml
Birdface has quit [Read error: Connection reset by peer]
Birdface has joined #ocaml
Birdfacee has quit [Ping timeout: 252 seconds]
Keodedad has joined #ocaml
Birdface has quit [Ping timeout: 258 seconds]
Keodedad has quit [Ping timeout: 276 seconds]
ggole has joined #ocaml
jerith_ is now known as jerith
Netsu has joined #ocaml
<Netsu> Hi there! Is there any way to get from the shell the `dirs` value from `dune` (declared in project's dune file, actually), like dune printenv *something*?
Birdface has joined #ocaml
amosbird has joined #ocaml
<amosbird> Hi, is ocaml static typed?
<def`> yes
<Leonidas> amosbird: yes
ygrek has joined #ocaml
_whitelogger has joined #ocaml
jmiven has quit [Quit: co'o]
jmiven has joined #ocaml
yomimono has quit [Ping timeout: 250 seconds]
pioneer42 has joined #ocaml
yomimono has joined #ocaml
<amosbird> hmm, should I add a paren to the pattern? | Ascii 'a' | Ascii ('1'|'2' as c) when ctrl && conf.fitmodel != FitPage ->
<amosbird> so that 'a' is also governed by the when clause?
<octachron> The when clause already applies to the whole case. However, there is an issue with the variable `c` which is not bound in `Ascii 'a'`.
<amosbird> ok
spew has joined #ocaml
<amosbird> do you guys use https://github.com/moosotc/llpp?
Denommus has joined #ocaml
pioneer42 has left #ocaml [#ocaml]
dhil has quit [Ping timeout: 252 seconds]
jao has joined #ocaml
yomimono has quit [Ping timeout: 250 seconds]
<def`> I do when I am on macOS, but that is completely unrelated from my use of OCaml :P
<flux[m]> I use llpp occasionally
xuib has joined #ocaml
<amosbird> flux[m]: do you have problems when opening links in llpp?
<amosbird> it only prints the link instead of opening
icecr4ck has left #ocaml ["WeeChat 2.4"]
<flux[m]> I haven't probably even tried
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 244 seconds]
chindy_ has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
chindy has joined #ocaml
<Leonidas> I haven't tried, I just use mupdf which already superficially resembles less
al-damiri has joined #ocaml
notnotdan has quit [Ping timeout: 245 seconds]
richi238 is now known as richi235
dhil has joined #ocaml
okuu has joined #ocaml
<amosbird> hmm, ok
<amosbird> how can I check if a string's 7th character is '/'? if not, prepend it with state.path?
<companion_cube> if s.[6] <> '/' then String.concat state.path s else s /
<companion_cube> minus the final /
<amosbird> minus?
<amosbird> what's this @@ operator?
<amosbird> Help.gotouri conf.urilauncher @@ String.sub s 7 (String.length s - 7)
<companion_cube> `let s = if s.[6] = '/' then s else Filename.concat state.path s`
<companion_cube> `@@` is like `$` in haskell: it has right precedence, so `f @@ g @@ h @@ x` is `f (g (h x))`
<amosbird> Help.gotouri conf.urilauncher if s.[6] <> '/' then String.concat state.path @@ String.sub s 7 (String.length s - 7) else s
<amosbird> is this correct?
<amosbird> hmm, let s = if s.[6] <> '/' then String.concat state.path @@ String.sub s 7 (String.length s - 7) else s in
yomimono has joined #ocaml
freyr69 has quit [Remote host closed the connection]
<companion_cube> well you'll have to test it
Birdfacee has joined #ocaml
<amosbird> companion_cube: I mean it doesn't compile
<amosbird> let path = Filename.dirname state.path in
<amosbird> Help.gotouri conf.urilauncher @@ Filename.concat "file://" path @@ String.sub s 7 (String.length s - 7)
<amosbird> this also fails..
<amosbird> Error: This expression has type string but an expression was expected of type 'a -> 'b
q9929t has joined #ocaml
<companion_cube> Filename.concat takes 2 args, you're giving it 3 args
<amosbird> hmm..
<amosbird> now I'm using two args, resulting Error: This expression has type string but an expression was expected of type string list
<companion_cube> well the compiler should give you the precise location where things go wrong
<amosbird> yeah, but I have no idea what's wrong about it....
q9929t has quit [Client Quit]
<companion_cube> check the types
<companion_cube> if you're using String.concat it takes a list of strings as its second argument
<amosbird> hmm, how can I pass those args as a list?
<companion_cube> String.concat "/" [a;b;c]
Jesin has quit [Quit: Leaving]
<amosbird> thanks
ziyourenxiang has quit [Ping timeout: 250 seconds]
<adrien> I'm reading data from a socket and then parsing it using Yojson.Safe.from_string; my issue is that the length of the data is unknown which makes me use a 4096-bytes buffer as output from the network and input to yojson but then yojson tries to read too far in the string
<adrien> I have a 4096-bytes string which I fill with 200 bytes of meaningful data and then I'm handing the string to yojson which complains about garbage after the 200 bytes
<adrien> is there a way to solve that without making a copy of the string merely to show a different length?
<companion_cube> can you let yojson manage the socket by itself?
<companion_cube> there are functions to read from a lexbuf and Bi_input or whatever
<companion_cube> (to read multiple json values)
<adrien> there's from_lexer but it seems bit overkill
<adrien> at least the strings should be small enough and short-lived enough to not be a performance issue (well, I don't even need perforamnce there but it's frustrating)
<companion_cube> if you don't know how long they are, not sure how you expect it to work?
<adrien> I know once they've been read :P
<adrien> I'm reading datagrams, not a stream, so I get the length from Unix.recv
<companion_cube> ah ok
<companion_cube> well String.sub ?
<adrien> that's what I've done for now but I would have preferred to be able to mutate the string length
Jesin has joined #ocaml
<companion_cube> I'm surprised you have strings of the wrong length in the first place
<companion_cube> don't you read into a fixed-size buffer?
<adrien> 4096 bytes each time
<companion_cube> and then you convert from Bytes to String?
Bahman has quit [Ping timeout: 255 seconds]
<adrien> actually I have a mix of String and Bytes (I'm on 4.02)
<companion_cube> :/
<adrien> so I Bytes.create and use String everywhere else :D
<companion_cube> good luck :p
<companion_cube> I don't touch unsafe-string stuff anymore
<adrien> well, are there really differences for such things?
<companion_cube> yes?
<companion_cube> bytes = mutable horror, string = nice clean value
<adrien> :D
<adrien> well
<companion_cube> I mean, ok, maybe yojson should have `from_buf: ?off:int -> ?len:int -> bytes -> t`
<companion_cube> but it's not the same as `from_string`
<adrien> http://pastebin.notk.org/pastebin.php?show=m4cd3371d <- using bytes, and when it blocks you just need to "echo x | nc -u 127.0.0.1 1234"
Bahman has joined #ocaml
<adrien> actually I now remember why shortening strings in place is a bad idea (java does or did it): if your string/bytes is 1M-long and you "shorten" it in-place to 12 bytes, you'll still keep the original 1M-long value in memory
<adrien> do that a few times and you'll use much more memory than expeced
<adrien> expected*
<Netsu> Is there any way to build only certain OPAM packages by OPALINE? https://github.com/jaapb/opaline/issues/3
<Netsu> *to install, I mean, for sure
TheLemonMan has joined #ocaml
Birdfacee has quit [Ping timeout: 264 seconds]
Bahman has quit [Quit: Ave atque vale]
<amosbird> what's wrong with this? | Ascii 'i' when ctrl || Right when alt ->
nahra has joined #ocaml
<Netsu> *Solved, nevermind)
Denommus has quit [Quit: restarting Emacs]
Jesin has quit [Quit: Leaving]
Denommus has joined #ocaml
Denommus has quit [Client Quit]
<amosbird> what's wrong withs this syntax | Ascii 'i' when ctrl | Right when alt ->
Denommus has joined #ocaml
barockobamo has quit [Remote host closed the connection]
<theblatte> amosbird: you can't have 2 "when" clauses, so you need `| Ascii 'i' when ctrl -> ... | Right when alt -> ...` (or if you can `| Ascii 'i' | Right when some other condition -> ...`)
<octachron> amosbird, "when" guard can be only added to case (| Something ... when ... -> ...), not invidual patterns.
AtumT has joined #ocaml
Birdfacee has joined #ocaml
ocabot has quit [Remote host closed the connection]
companion_cube has quit [Remote host closed the connection]
okuu has quit [Ping timeout: 250 seconds]
<amosbird> thanks
<amosbird> hmm, how can I make this search function case insensitive? https://la.wentropy.com/_Bry
<amosbird> or better, smart case
ocabot has joined #ocaml
companion_cube has joined #ocaml
<octachron> amosbird, it looks like your function is already case insensitive, what is the issue? (beyond the fact that you are using Str rather than ocaml-re, tyre or anything else ...)
ggole has quit [Quit: Leaving]
oni-on-ion has joined #ocaml
<amosbird> hmm, ok
<amosbird> I'm trying to make the search fuzzier
Netsu has quit [Ping timeout: 256 seconds]
Birdfacee has quit [Ping timeout: 264 seconds]
<amosbird> does ocaml provide fuzzy matching support?
<companion_cube> there are libs for that
<companion_cube> (mine is "spelll" but whatever)
Birdfacee has joined #ocaml
okuu has joined #ocaml
Denommus has quit [Remote host closed the connection]
Serpent7776 has joined #ocaml
<amosbird> cool
Birdfacee has quit [Ping timeout: 276 seconds]
Birdfacee has joined #ocaml
dhil has quit [Ping timeout: 276 seconds]
yomimono has quit [Ping timeout: 258 seconds]
Jesin has joined #ocaml
Jesin has quit [Remote host closed the connection]
Birdfacee has quit [Remote host closed the connection]
Jesin has joined #ocaml
Fardale_ is now known as Fardale
gravicappa has quit [Ping timeout: 276 seconds]
dhil has joined #ocaml
okuu has quit [Ping timeout: 250 seconds]
AtumT has quit [Ping timeout: 258 seconds]
AtumT has joined #ocaml
nahra has quit [Quit: ERC (IRC client for Emacs 25.1.1)]
nahra has joined #ocaml
dhil has quit [Ping timeout: 255 seconds]
AtumT has quit [Read error: Connection reset by peer]
AtumT has joined #ocaml
HarryGeek has joined #ocaml
kakadu_ has joined #ocaml
<HarryGeek> hello
<oni-on-ion> hi
HarryGeek has left #ocaml ["bye"]
AtumT has quit [Quit: AtumT]
kjak has joined #ocaml
kjak has quit [Ping timeout: 250 seconds]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
kakadu_ has quit [Remote host closed the connection]
r3s1stanc3 has left #ocaml ["WeeChat 2.4"]
kjak has joined #ocaml
kjak has quit [Client Quit]
kjak has joined #ocaml
Haudegen has joined #ocaml
okuu has joined #ocaml
okuu has quit [Client Quit]
okuu has joined #ocaml
breitenj has quit [Ping timeout: 252 seconds]
breitenj has joined #ocaml
Birdface has quit [Ping timeout: 276 seconds]
Serpent7776 has quit [Quit: leaving]
dmiles has quit [Ping timeout: 255 seconds]
okuu has quit [Remote host closed the connection]
okuu has joined #ocaml
okuu has quit [Remote host closed the connection]
okuu has joined #ocaml
dmiles has joined #ocaml
Haudegen has quit [Read error: Connection reset by peer]
ygrek has quit [Ping timeout: 250 seconds]
<cmk_zzz> For some reason opam install unix.lwt as version dev. How can I found the package which caused the dev version to be pulled in?
AnAverageHuman has joined #ocaml
okuu has quit [Remote host closed the connection]
okuu has joined #ocaml
<oni-on-ion> cmk_zzz, hmm
<oni-on-ion> opam list --depends-on=unix.lwt
<oni-on-ion> dont see what is "unix.lwt" though, opam says no such package, just lwt, lwt_log, lwt_react
<cmk_zzz> yes, I got cohttp-lwt-unux, condiut-lwt-unix and faraday-lwt-unix
<cmk_zzz> so perhaps one of them
<cmk_zzz> yes, and I mean lwt.unix not unix.lwt.
<oni-on-ion> yeah its just lwt -- the .unix is because of your system i think
<cmk_zzz> Ok, so perhaps I am doing something wrong. `ocamlfind query lwt -l gives version "dev`". but `opam list -i lwt` gives 4.2.0
<cmk_zzz> so when I try to install a package (stog) it fails because it says lwt.unix is version dev but requires v > 2.5.0
<cmk_zzz> stog's configure script uses ocamlfind to find the installed versions.
<oni-on-ion> ohh thats a nice lib i may need too in the future =)
<oni-on-ion> hmm
<oni-on-ion> i think you may want to add another opam switch, for the project that needs stog, if there are two versions of lwt required. i am new to opam and havent myself used lwt yet
ziyourenxiang has joined #ocaml
<cmk_zzz> yes, perhaps. stog works with the switch I got if I hack around the configure script though :D. Most of my evaluation of ocaml always end up fighting with incompatible packages, and trouble installing software in opam :/
<oni-on-ion> im gonna install it and see what happens
<oni-on-ion> it brings along 28 packages with it. will be a couple minutes =)
<oni-on-ion> oh hey look
<oni-on-ion> i had utop open in the other window, and i did a #list;;
<oni-on-ion> it shows lwt.unix (version: dev)
<oni-on-ion> (and i just found a funny bug with utop. i left at 18:33 and now it is 19:55. i just now entered a utop command and it still said 18:33 until i entered another one. hmmmm=)
pyon has joined #ocaml
okuu has quit [Remote host closed the connection]