companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.05.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.05/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
maxton_ has joined #ocaml
ziyourenxiang has quit [Ping timeout: 248 seconds]
dreadedfrog has joined #ocaml
malina has quit [Ping timeout: 255 seconds]
dreadedfrog has quit [Ping timeout: 240 seconds]
andreas_ has quit [Quit: Connection closed for inactivity]
drtop has quit [Ping timeout: 246 seconds]
maxton_ has quit [Read error: Connection reset by peer]
maxton_ has joined #ocaml
enterprisey has joined #ocaml
sh0t has quit [Remote host closed the connection]
dreadedfrog has joined #ocaml
SomeDamnBody has joined #ocaml
<SomeDamnBody> Has anybody used the Gml module of ocamlgraph to export and import graphs?
maxton has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
dreadedfrog has quit [Ping timeout: 248 seconds]
kevinqiu has joined #ocaml
kevinqiu has quit [Ping timeout: 255 seconds]
silver has quit [Read error: Connection reset by peer]
enterprisey has quit [Ping timeout: 240 seconds]
enterprisey has joined #ocaml
_berke_ has quit [Remote host closed the connection]
mfp__ has quit [Ping timeout: 276 seconds]
mengu has quit [Quit: Leaving...]
SomeDamnBody has quit [Remote host closed the connection]
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 240 seconds]
al-damiri has quit [Ping timeout: 276 seconds]
al-damiri has joined #ocaml
lostman has quit [Ping timeout: 276 seconds]
mars0i[m] has quit [Ping timeout: 276 seconds]
mars0i[m] has joined #ocaml
lostman has joined #ocaml
ristos has quit [Quit: Connection closed for inactivity]
pierpa has quit [Quit: Page closed]
swalk has quit [Quit: swalk]
KeyJoo has quit [Ping timeout: 255 seconds]
jlongster has joined #ocaml
swalk has joined #ocaml
sapristi has joined #ocaml
<sapristi> hey
dreadedfrog has joined #ocaml
<sapristi> anyone using outshine-mode on emacs ?
dreadedfrog has quit [Ping timeout: 260 seconds]
ygrek has joined #ocaml
jlongster has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kevinqiu has joined #ocaml
maxton_ has quit [Read error: Connection reset by peer]
swalk has quit [Quit: swalk]
kevinqiu has quit [Ping timeout: 240 seconds]
_whitelogger has joined #ocaml
sapristi has quit [Quit: Leaving]
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 268 seconds]
jao has quit [Ping timeout: 258 seconds]
MercurialAlchemi has joined #ocaml
dreadedfrog has joined #ocaml
raphaelss has quit [Quit: leaving]
dreadedfrog has quit [Ping timeout: 240 seconds]
dreadedfrog has joined #ocaml
govg has quit [Ping timeout: 255 seconds]
dreadedfrog has quit [Ping timeout: 240 seconds]
govg has joined #ocaml
kevinqiu has joined #ocaml
kevinqiu has quit [Ping timeout: 240 seconds]
MercurialAlchemi has quit [Ping timeout: 276 seconds]
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 260 seconds]
MercurialAlchemi has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
dreadedfrog has joined #ocaml
TheLemonMan has joined #ocaml
dreadedfrog has quit [Ping timeout: 258 seconds]
samrat_ has joined #ocaml
ygrek has quit [Ping timeout: 248 seconds]
manizzle has quit [Remote host closed the connection]
enterprisey has quit [Read error: Connection reset by peer]
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 260 seconds]
Simn has joined #ocaml
andreas_ has joined #ocaml
kevinqiu has joined #ocaml
dreadedfrog has joined #ocaml
kevinqiu has quit [Ping timeout: 255 seconds]
dreadedfrog has quit [Ping timeout: 255 seconds]
kakadu has joined #ocaml
kakadu has quit [Ping timeout: 240 seconds]
kakadu has joined #ocaml
kevinqiu has joined #ocaml
kevinqiu has quit [Ping timeout: 258 seconds]
samrat_ has quit [Ping timeout: 276 seconds]
dreadedfrog has joined #ocaml
freusque has joined #ocaml
argent_smith has joined #ocaml
<shepard> Good morning everyone! (at least to those who live not too far away from Belgium)
<shepard> Does someone know how to make Re2 regexps non greedy?
<shepard> I tried to add `Longest_match false to the options, but it didn't do ^^
zpe has joined #ocaml
<Leonidas> shepard: you could try to add '?' to them, as with all regex implementations?
<shepard> The options are given as a list of variants, but maybe I can type the regex in the usual form as /blabla/?, I will try :-)
<shepard> Nope, this syntax does not seem to be accepted :-(
cranmax has joined #ocaml
kevinqiu has joined #ocaml
<shepard> I found a way :-) I had to define a non-capturing group and I could set the option U (non-greedy) inside that group ==> (?:(?U).*)
kevinqiu has quit [Ping timeout: 248 seconds]
dreadedfrog has quit [Ping timeout: 260 seconds]
copy_ has joined #ocaml
barcabuona has joined #ocaml
zpe has quit [Remote host closed the connection]
Algebr has joined #ocaml
mfp__ has joined #ocaml
<Leonidas> Anyone knows how I can satisfy the Jane Street Async Udp.sendto signature?
<Leonidas> I am not sure what kind of Fd.t I am supposed to pass in
flo2 has joined #ocaml
<flo2> What would be the most efficient way to check if a float could actually be expressed as an integer, like 5.0 as 5?
zpe has joined #ocaml
dreadedfrog has joined #ocaml
<dxtr> x % 2 == 0?
<dxtr> err
<dxtr> mod_float x 2.0 == 1
<dxtr> Or something
zpe has quit [Remote host closed the connection]
<johnelse> let is_int x = fst (modf x) = 0.
<johnelse> ...is what I would probably do
dreadedfrog has quit [Ping timeout: 240 seconds]
<dxtr> Oh there was something like that
<dxtr> Neat
<johnelse> I had to check :)
<dxtr> That makes this so much easier
<dxtr> Also, my modulo math was wrong
<dxtr> (mod_float x 1.0) = 0;;
<copy_> Leonidas: The socket's fd (same as in C, see `man sendto`)
<Leonidas> copy_: the confusing thing is that I don't supply these but rather I get a function which is passed an Fd, an iobuf and an address
<copy_> Yes, that's odd. I don't remember the reason, but in my program I just write `let sendto_sync = Or_error.ok_exn @@ Udp.sendto_sync ()` in the top level and it never failed
ziyourenxiang has joined #ocaml
<shepard> dxtr, mod_float returns a float, so it would rather be mod_float x 1. = 0. :-) Additionally I'm not sure about the negative case. Maybe -0. is different from 0. in the float type ^^
<copy_> Leonidas: Commented
<shepard> indeed mod_float (-1.) 1. gives -0.
<shepard> but 0. = -0. gives true
<shepard> and 0. == -0. gives false
<theblatte> #floatslife
<johnelse> beware, 0. == 0. also gives false
<johnelse> although let x = 0. in let y = x in x == y gives true
<shepard> nice note, I didn't know :)
MercurialAlchemi has quit [Ping timeout: 246 seconds]
jbrown has joined #ocaml
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 276 seconds]
kevinqiu has joined #ocaml
kevinqiu has quit [Ping timeout: 246 seconds]
cranmax has quit [Quit: Connection closed for inactivity]
sam____ has quit [Ping timeout: 255 seconds]
swalk has joined #ocaml
TheLemonMan has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
al-damiri has joined #ocaml
dreadedfrog has joined #ocaml
malina has joined #ocaml
dreadedfrog has quit [Ping timeout: 240 seconds]
<Leonidas> copy_: thanks. Took me some time off to get what the signature means.
<Leonidas> copy_: but I can't get to pass it an Iobuf, it complains that Iobuf.of_string "foo" cannot be generalized.
<Leonidas> ok, Iobuf.read_only fixed it
swalk has quit [Quit: swalk]
ristos has joined #ocaml
sapristi has joined #ocaml
<sapristi> hello
<reynir> hello
<shepard> hi
_andre has joined #ocaml
<sapristi> I'm currently using emacs with outshine (and outline) modes
<sapristi> they enable somehow to edit comment as org-mode and give an org structure to the source file
<sapristi> that's nice but it doesn't really support multiline comment
<sapristi> do you guys know of something similar ?
samrat_ has joined #ocaml
dreadedfrog has joined #ocaml
<Leonidas> copy_: heh, for me it throws the ok_exn every time because unimplemented Bigstring.sendto_nonblocking_no_sigpipe
<copy_> Huh, is that platform-specific?
dreadedfrog has quit [Ping timeout: 276 seconds]
samrat_ has quit [Ping timeout: 248 seconds]
<Leonidas> copy_: it says to try to compile on Linux: https://discuss.ocaml.org/t/sending-udp-on-macos-fails/636
<Leonidas> but I can't believe this is correct, there must be *something* wrong
kevinqiu has joined #ocaml
zpe has joined #ocaml
kevinqiu has quit [Ping timeout: 260 seconds]
malina has quit [Remote host closed the connection]
Algebr has quit [Ping timeout: 276 seconds]
silver has joined #ocaml
jlongster has joined #ocaml
silver_ has joined #ocaml
dreadedfrog has joined #ocaml
silver has quit [Ping timeout: 248 seconds]
cranmax has joined #ocaml
kevinqiu has joined #ocaml
dreadedfrog has quit [Ping timeout: 260 seconds]
<reynir> adrien: \o/ I got prose running
<adrien> reynir: oh, great, whas was going on?
<reynir> huh?
aciniglio has joined #ocaml
kevinqiu has left #ocaml ["ERC (IRC client for Emacs 24.5.1)"]
zpe has quit [Remote host closed the connection]
sh0t has joined #ocaml
swalk has joined #ocaml
FreeBirdLjj has joined #ocaml
aciniglio has quit [Ping timeout: 260 seconds]
FreeBirdLjj has quit [Ping timeout: 255 seconds]
<kakadu> It seems that namespace for OCaml are desirable. https://github.com/prose/prose
<kakadu> namespaces*
TheLemonMan has joined #ocaml
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 240 seconds]
MercurialAlchemi has quit [Ping timeout: 248 seconds]
MercurialAlchemi has joined #ocaml
dreadedfrog has joined #ocaml
Denommus has joined #ocaml
Denommus has quit [Client Quit]
aciniglio has joined #ocaml
Denommus has joined #ocaml
zpe has joined #ocaml
silver_ has quit [Read error: Connection reset by peer]
sepp2k has joined #ocaml
<cranmax> Hi, I've got one 'float option list list' that is: [[Some 2. ; Some 4.]; [Some 2. ; Some 5.]; [None]]
<cranmax> And I want to sum 2+2 and 4+5 so the result must be a list [4. ; 9]
zpe has quit [Remote host closed the connection]
<cranmax> Yesterday, with the help and code of octachron , I have written the next function
zpe has joined #ocaml
kino has joined #ocaml
<cranmax> But it returns a float, so it sums all the numbers, and it gives me 13.
zpe has quit [Ping timeout: 248 seconds]
<kino> Hi, I started OCaml a few month ago and I'm running into some problems now.
<kino> Basically, I'm writing a compiler for a language that compiles down to Javascript. Right now, I'm generating Javascript code by text, which both inefficient and messy.
<kakadu> cranmax: It seems that you want to apply the same action to an every element of an initial list, right?
<kakadu> AH, wait
<kino> So I've taken a look to find a library that implemented a JS AST - only thing I found is Facebook's flow parser. I've downloaded it through OPAM, but I can't figure how to use it in my own project.
<kakadu> You want to add nth element of an every list?
<kakadu> kino: did you succeeded at linking all together?
<kino> kakadu: No, I can't figure out that part actually :)
<kino> Documentation is inexistant
<kakadu> kino: which build system do you use?
<kino> ocamlbuild
<cranmax> kakadu : I want to sum the first element with the first elemtns of all, the second element with all the seconds elements, this is what i want now, in the future maybe to sum the n element with all the n elements :)
<kino> inexistent*
<kakadu> kino: basically you need to add `true: package(blabla)` into the _tags file
<kakadu> cranmax: can you take a value of type 'a list list and return 'a list which will be a list of all head lements of every list?
<kino> Is the name of the package the same thing as in `opam list`?
<kakadu> not really. Use ocamlfind list
<kino> Seems it is in this case c:
<cranmax> kakadu: I think that can be fine to deconstruct both lists and do two lists in this case of [2. ; 2.] And [4. ; 5.] And the sum it
<kino> Thanks!
<kino> I'm having trouble actually using the code in my project. Can't seem to find the right thing to open, and I can't get merlin to give me anything related
<kakadu> Does you package have documentation?
<kakadu> your*
<kakadu> (there is a general method but documentation will be simplier)
<kino> No it doesn't
<kino> That's why I'm having a hard time and turning to you guys :)
sapristi has quit [Remote host closed the connection]
<kakadu> Does your package has some .cmi files intalled? ls `ocamlfind query blabla`/*.cmi
sapristi has joined #ocaml
<kino> Yes it does!
<kakadu> If there is no such files you can find which library you are trying to link with and search for *.cma files
<kino> Thanks, I got it
<kakadu> and later use `ocamlobjinfo lib.cma`
<kakadu> Also I think that your .merlin file knows about new library merlin should give you completions out of box
<kakadu> if* your merlin file...
<kino> I think it did, but I couldn't find the name of the interfaces
<kino> Which you helped me find
<kino> So thanks a lot!
FreeBirdLjj has joined #ocaml
<kakadu> cranmax: Are you kind of resolved this?
<cranmax> kakadu: not now, I don't know how to do it
<kakadu> Can you extract only head elements of the lists and sum them?
<cranmax> kakadu: yes what matters is the result, but I don't know how to do it
<kakadu> I do not understand what you do not understand
<kino> Does opam downloads source as well as cmi files?
<kakadu> kino: cmis are compiled files
<kino> Yes - So if I want source, I've got to download it from github?
govg has quit [Ping timeout: 260 seconds]
<kakadu> kind of. There is also `opam source`
<kakadu> kino: There are also programs like ocamlbrowser http://kakadu.github.io/lablqml/images/qocamlbrowser1.png
<kino> Sweet
<kino> Does your program works offline?
<kakadu> yes
<kakadu> only on installed files
<kakadu> there is also non-Qt but ncurses one: ocp-browser
<kakadu> there is also an original Tcl/Tk version
<cranmax> kakadu: imagine this list of lists [[ 1 ; 2] ; [ 3 ; 4]] so i want to sum the first elements of both lists 1 + 3 and the seconds elements of both lists 2 + 4
<kino> Sweet
<kino> Doesn't map2 do the job?
<sapristi> cranmax, what are some other usecases that you want to treat ? And why do you have a float list list and not a (float*float) list ?
<kakadu> cranmax: Are you familiar with functions from the List module? https://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html
Orion3k has quit [Ping timeout: 268 seconds]
<kino> kakadu: Is ocp-browser the ncurses one?
<cranmax> sapristi : I don't know really, I load one .csv file with the CSV library then I map the list with float_of_string and it outputs a float list list
<kakadu> kino: it seesm so
<kino> Ok cool
<cranmax> kakadu: not much but I'll look into it
<sapristi> cranmax, yes it seems map2 is exactly what you are looking for, except for the [None;] at the end, so you might you to remove it from your list before using map2
<kino> kakadu: That stuff's amazing
<kino> Exactly what I didn't know I needed
rostero has quit [Quit: Connection closed for inactivity]
barcabuona has quit [Quit: WeeChat 1.9]
sapristi_ has joined #ocaml
Algebr has joined #ocaml
sapristi__ has joined #ocaml
<cranmax> sapristi: how can I remove it? :)
sapristi has quit [Ping timeout: 240 seconds]
kino has quit [Ping timeout: 240 seconds]
sapristi_ has quit [Ping timeout: 268 seconds]
<sapristi__> cranmax, you could recursively treat your list and remove items like [None;]
<sapristi__> i be gone now
Denommus` has joined #ocaml
tane has joined #ocaml
Denommus has quit [Remote host closed the connection]
ome has quit [Ping timeout: 246 seconds]
<cranmax> sapristi__: okay thanks!
sapristi__ has quit [Ping timeout: 260 seconds]
ome has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
jao has joined #ocaml
maxton_ has joined #ocaml
Orion3k has joined #ocaml
Denommus` has quit [Ping timeout: 255 seconds]
Ragora has joined #ocaml
maxton_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Orion3k has quit [Ping timeout: 255 seconds]
dreadedfrog has quit [Ping timeout: 240 seconds]
rostero has joined #ocaml
dreadedfrog has joined #ocaml
maxton_ has joined #ocaml
aciniglio has quit [Read error: Connection reset by peer]
dreadedfrog has quit [Ping timeout: 240 seconds]
maxton_ has quit [Client Quit]
dreadedfrog has joined #ocaml
Orion3k has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
dreadedfrog has quit [Ping timeout: 240 seconds]
maxton_ has joined #ocaml
maxton_ has quit [Client Quit]
Denommus has joined #ocaml
Soni has quit [Ping timeout: 246 seconds]
Soni has joined #ocaml
copy[m] has joined #ocaml
maxton_ has joined #ocaml
raphaelss has joined #ocaml
FreeBirdLjj has joined #ocaml
nightmared has quit [Ping timeout: 276 seconds]
nightmared has joined #ocaml
copy_ has quit [Quit: Connection closed for inactivity]
Denommus has quit [Quit: leaving]
sam____ has joined #ocaml
florian has joined #ocaml
<florian> What is the correct way to unit test Lwt based code?
aantron_ has joined #ocaml
<aantron_> florian: typically you create a tester program. each test calls Lwt_main.run to finish some promise, in the course of finishing which your code is triggered
dakk has joined #ocaml
samrat_ has joined #ocaml
sz0 has joined #ocaml
fredcy has quit [Quit: ZNC - http://znc.in]
andreas_ has quit [Quit: Connection closed for inactivity]
tane has quit [Quit: Leaving]
Algebr has quit [Ping timeout: 268 seconds]
fredcy has joined #ocaml
dreadedfrog has joined #ocaml
tane has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
vbmithr_ is now known as vbmithr
vbmithr has quit [Quit: leaving]
vbmithr has joined #ocaml
cranmax has quit [Quit: Connection closed for inactivity]
TheLemonMan has joined #ocaml
aantron_ has quit [Remote host closed the connection]
aantron_ has joined #ocaml
ygrek has joined #ocaml
zv has quit [Ping timeout: 240 seconds]
esas has joined #ocaml
mengu has joined #ocaml
andreas_ has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
hcarty has joined #ocaml
dakk has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 255 seconds]
florian has left #ocaml ["Leaving"]
axiles has quit [Ping timeout: 248 seconds]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
aantron_ has quit [Remote host closed the connection]
aantron_ has joined #ocaml
axiles has joined #ocaml
_andre has quit [Quit: leaving]
dreadedfrog has quit [Ping timeout: 240 seconds]
jbrown has quit [Remote host closed the connection]
cranmax has joined #ocaml
infinity0_ has joined #ocaml
infinity0_ has quit [Changing host]
infinity0 is now known as Guest91799
infinity0 has joined #ocaml
samrat_ has quit [Ping timeout: 240 seconds]
enterprisey has joined #ocaml
tane has quit [Quit: Leaving]
enterprisey has quit [Remote host closed the connection]
enterprisey has joined #ocaml
sh0t has quit [Ping timeout: 240 seconds]
mali has joined #ocaml
sepp2k has quit [Ping timeout: 255 seconds]
dejanr has joined #ocaml
mengu has quit [Remote host closed the connection]
sam____ has quit [Ping timeout: 255 seconds]
sapristi__ has joined #ocaml
aantron_ has quit [Quit: leaving]
enterprisey has quit [Remote host closed the connection]
Simn has quit [Quit: Leaving]
argent_smith has quit [Quit: Leaving.]
mengu has joined #ocaml
peterpp__ has joined #ocaml
slack4 has joined #ocaml
flo2 has quit [Remote host closed the connection]
flo2 has joined #ocaml
flx_ has joined #ocaml
Ergatis has joined #ocaml
jao has quit [Disconnected by services]
jao has joined #ocaml
Ragora has quit [Remote host closed the connection]
flux has quit [Write error: Broken pipe]
igitoor_ has quit [Excess Flood]
bernardo1pc has joined #ocaml
m4farrel_ has joined #ocaml
AdmWiggin has joined #ocaml
flx_ is now known as flux
rixed_ has joined #ocaml
hnrgrgr_ has joined #ocaml
igitoor has joined #ocaml
qmmm has joined #ocaml
cow-orker has quit [Write error: Broken pipe]
rixed has quit [Write error: Broken pipe]
cow-orke1 has joined #ocaml
Nazral has quit [Remote host closed the connection]
beanmachine has joined #ocaml
bacam_ has joined #ocaml
cthuluh_ has joined #ocaml
aniou_ has joined #ocaml
j0sh_ has joined #ocaml
sheijk has joined #ocaml
haesbaer1 has joined #ocaml
mjacob_ has joined #ocaml
eagleflo_ has joined #ocaml
chelfi1 has joined #ocaml
mami has joined #ocaml
jerith_ has joined #ocaml
Nazral has joined #ocaml
haesbaert has quit [Write error: Broken pipe]
j0sh has quit [Write error: Broken pipe]
chelfi has quit [Write error: Broken pipe]
gallais has quit [Write error: Broken pipe]
slack3 has quit [Write error: Broken pipe]
relrod has quit [Excess Flood]
aniou has quit [Write error: Broken pipe]
sheijk_ has quit [Write error: Broken pipe]
benmachine has quit [Write error: Broken pipe]
eagleflo has quit [Write error: Broken pipe]
aegray_ has quit [Write error: Broken pipe]
bernardofpc has quit [Write error: Broken pipe]
ahf has quit [Excess Flood]
_habnabit has quit [Excess Flood]
tianon has quit [Remote host closed the connection]
bacam has quit [Remote host closed the connection]
qmm has quit [Remote host closed the connection]
micro_ has quit [Remote host closed the connection]
jerith has quit [Remote host closed the connection]
dmbaturin has quit [Remote host closed the connection]
jlouis has quit [Remote host closed the connection]
mjacob has quit [Remote host closed the connection]
relrod_ has joined #ocaml
relrod_ has quit [Changing host]
relrod_ has joined #ocaml
ahf has joined #ocaml
m4farrel has quit [Write error: Broken pipe]
hnrgrgr has quit [Remote host closed the connection]
cthuluh has quit [Remote host closed the connection]
mami_ has quit [Remote host closed the connection]
_habnabit has joined #ocaml
relrod_ is now known as relrod
infinity0 has quit [Remote host closed the connection]
hannes` has joined #ocaml
infinity0 has joined #ocaml
mami has joined #ocaml
mjacob_ has joined #ocaml
mjacob_ has quit [Changing host]
mami has quit [Changing host]
hannes has quit [Remote host closed the connection]
iZsh has quit [Ping timeout: 269 seconds]
igitoor has quit [Changing host]
igitoor has joined #ocaml
dmbaturin has joined #ocaml
andreas_ has quit [Quit: Connection closed for inactivity]
aegray has joined #ocaml
iZsh has joined #ocaml
jlouis has joined #ocaml
whoman has joined #ocaml
micro_ has joined #ocaml
gallais has joined #ocaml
micro_ is now known as Guest76389
hannes` is now known as hannes
Totoro42 has joined #ocaml
<Totoro42> Hi
<Totoro42> I've got a question about functionnal paradigm
<Totoro42> i've heard that functionnal paradigm is about
<whoman> functions
<Totoro42> building your software on functions
<Totoro42> yes
<Totoro42> and that imperative style is prohibited
<Totoro42> but how do you do instructions ?
<whoman> imperative style is the order of composed functions
<Totoro42> the order of composed functions ? i don't get it, what do you mean
<whoman> a(), b(), ... ocaml can do this like normal line-by-line order of function evaluation that we call imperative
<whoman> 'functional paradigm' is mostly about immutable data, not changing state.
<whoman> the prohibition in "pure" functions are to not change data which does not belong to the function
<whoman> in a way, a function is the OOP objects and structs that imperative styles use for representing their programs and data
<Totoro42> Oh you mean that, the only allowed primitive is function ?
<Totoro42> meaning that functions can get input parameters, call functions, and return a value
<Totoro42> Meaning that the only memory which have a change of state is the stack ?
<whoman> well... data is treated as constant functions
kakadu has quit [Remote host closed the connection]
<Totoro42> okay
<whoman> sequential programming of imperative lists of procedures, is a type of data (list of functions)
<whoman> an "imperative" language compiler would generally only accept those lists of functions, and execute them in order
pierpa has joined #ocaml
<Totoro42> whoman, cause what is quite hard for me is
<whoman> but for functional paradigm, that limitation does not exist inside the program itself, but only when communicating with the outside world (keyboard, input, graphics, output)
<Totoro42> imagine that you have 3 instructions encapsulated in a function
<whoman> (so a functional program is more like a mathematical formula; easier to "prove" its correctness and behavior)
<Totoro42> function a() { do_b; do_c; do_d; }
<whoman> yes, alright, i am imagining
<Totoro42> how can i turn that in functionnal programming ?
<whoman> (a (b (c (d))))
<whoman> sorry, in reverse
<whoman> (d (c (b (a))))
<_y> well, in any practical programming language, there is the sequencing operator “;”
<whoman> b needs value of a, so a is evaluated, then c needs b, and so on
<Totoro42> whoman, i don't get it
<_y> that includes so-called functional languages
<whoman> Totoro42, have you used C?
<Armael> you have a sequencing operator in ocaml
<Totoro42> whoman, yes i do
<Armael> you can do a (); b(); c ()
<Armael> to execute a () then b () then c ()
<Totoro42> Yes, Armael, but it is not pure functionnal programming isn't it ?
<whoman> Totoro42, ok, so it is : function a() { do_d(do_c(do_b())) }
<Totoro42> let's do that as purist
<Armael> Totoro42: why not
<Totoro42> functionnal programming do not allow it
<Armael> yes it does?
<_y> Totoro42, then as whoman said, if you want your action a to be of any use, you must remember its “effect” somehow, so you have to pass a “state” value from function to function
<Totoro42> oh i see
<Totoro42> actually what i don't get is
<Totoro42> how to do c equivalent in functionnal
<_y> a keyword here is “(state) monad”, from the haskell coolness
<whoman> or "finite state machine" (FSM) from erlang and other places
<whoman> the semicolon operator (';') may be what you are looking for, Totoro42
<whoman> as Armael and _y said
<Totoro42> what is a monad ?
peterpp__ has quit [Ping timeout: 240 seconds]
<whoman> state transformer
<_y> Totoro42, it is a terminology from category theory (a mathematical theory)
<whoman> like unix pipe, kinda.
<_y> it is used pervasively in the world of the pure functional language called Haskell
swalk has quit [Quit: swalk]
<_y> (a monad is a monoid in the category of endofunctors, they say)
DrWhax_ is now known as DrWhax
raphaelss has quit [Ping timeout: 240 seconds]
AdmWiggin is now known as tianon
<_y> well that word “monad” may be pedantic for what it is, in our case (the state monad) it really only means that it allows you to wrap a program in order to add a state (simulation of a mutable variable) to it, mostly by passing an additional state parameter to every function involved
<whoman> stereo, mono ?
<_y> if you want to know more about it, try and search the web for Monad and/or Haskell (any Haskell tutorial would introduce you to monads at some point)
<Totoro42> you're right
<Totoro42> actually my first aim was that i head
<Totoro42> heard*
<Totoro42> that functionnal paradigm was the child of lambda calculus
swalk has joined #ocaml
<Totoro42> which was a pure branch of mathematics
<Armael> "pure" ??
<Armael> what do you mean by "pure" in this context?
<whoman> branch /= trunk - what part of a tree is pure
<Totoro42> homotopy types theory is based on lambda calculus
<Totoro42> which is from that point of view
<Totoro42> a foundation of all math architecture
<Totoro42> homotopy type theory is an alternative to ZFC theory
<Totoro42> making it an alternative root for maths
<_y> but a more simpler way of sequencing things in a functional setting is by chaining “let … in” constructs
<Totoro42> Actually my question is
<_y> the sequencing operator “;” may be seen as mere syntactic sugar for this
<Totoro42> so if i do
<Totoro42> a;b;
<Totoro42> it is equivalent to
<Totoro42> let a in {let b in {...}}
<Totoro42> ?
<_y> and in OCaml, which is impure, this allows to sequence side effects (ie· the sequencing has a visible effect, it is not only a matter of order of internal computation)
<Totoro42> Okay
<Totoro42> cause my question is much more about philosophy of the langage
<_y> s/more simpler/much simpler/
<Totoro42> in c i do
<Totoro42> a;b;
<Totoro42> but maybe in functionnal programming this do have any sense at all
<Totoro42> but my question is, how can you do something equivalent
<whoman> how do we know what order our english words are read or written? =)
<_y> Totoro42, actually as for the syntax it would be “let _ = a in let _ = b in …”, but otherwise you get it, yeah
<Armael> assuming "a" here is a C statement, in OCaml it would be an expression
<Armael> so you use let to give an name to the value it produces
<Totoro42> okay
<Armael> expressions that just do stuff and produce no useful value (e.g. printing to the screen) return the "unit" value, ()
<_y> (that “_ = a” is a binding, it allows you to store and name the result of the expression a)
<Armael> so the equivalent of f(1, 3); g(42); would be let () = f(1, 3) in let () = g(42) in ...
<Armael> assuming f and g to be C functions with return type "void"
<Totoro42> okay i see
<Totoro42> and know
<Armael> and in that case, you can use ";" in OCaml
<Totoro42> and now* sorry
<Armael> and write f(1, 3); g(42)
<Totoro42> what is the functionnal equivalent of let in
<Armael> (this is valid OCaml syntax, and can be seen as a shorthand for let () = ... in)
<Armael> err, let..in is a functional programming construct
<Totoro42> it exists in Haskell ?
<_y> Totoro42, as for the φlosoφ of the language, since we are discussing on the #ocaml channel we gave you the idiomatic approach in the OCaml language
<Armael> yes
<Totoro42> Okay
<Totoro42> do it exists in lambda calculus ?
<_y> for Haskell, just go and check out these monads
<Armael> let .. in simply allows you to give names to intermediates expressions
<Totoro42> i see
<whoman> alias/where
<Totoro42> but do that exists in lambda calculus ?
<Armael> let can be encoded by a lambda & function application in untyped or simply-typed λ-calculus
<Armael> but it is a primitive construct in ML
<Armael> (for typing-related reasons)
<Totoro42> yes i understood
<Totoro42> but my aim was to know
<Totoro42> if i can convert it in lambda calculus
<Armael> which lambda calculus?
<Armael> (if you mean untyped lambda-calculus, then the answer is yes)
<Totoro42> i didn't knew that there was various lambda calculus
raphaelss has joined #ocaml
ziyourenxiang has quit [Ping timeout: 240 seconds]