adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.08 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.08/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
h11 has quit [Quit: The Lounge - https://thelounge.chat]
h11 has joined #ocaml
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
sarahzrf has joined #ocaml
<sarahzrf> hey!
<dmbaturin> Hi sarahzrf!
<sarahzrf> i keep meaning to play around with ocaml a bit, and i decided just earlier to rewrite a toy parser i did in haskell into ocaml
<sarahzrf> one thing i wanna do is replace my endlessly repeated type variables with type arguments to a module functor
<sarahzrf> but i'm wondering if i can do one better - first, here's the types i'm about to translate https://benzrf.com/uploads/c0916f3f5e3ad5f5.png
<sarahzrf> (type constructors are prefix instead of suffix, "data" is for defining a new algebraic data type, "type" is for a type alias, surrounding square brackets means a list)
<sarahzrf> (hopefully most of the rest is pretty transparent)
<dmbaturin> Wait, what exactly you want to make into a reusable parameter?
<sarahzrf> er, sorry, that was unclear yeah - my code is parametric over what type of tokens are being used for terminal and nonterminal symbols (n and t there), which seems like a perfect use case for functors
<sarahzrf> as haskell, the types are just littered with n's and t's, which would be cool to get rid of when i do this in ocaml
<dmbaturin> Note that "functors" in ML are parameterized with module signatures, not types, so it will only make your code longer unless there are also a bunch of functions associated with each type of tokens.
<sarahzrf> hmm
<dmbaturin> It's more the same role as type classes, just explicit.
<sarahzrf> oh no yeah i'm aware
<sarahzrf> and yeah, strictly speaking this wouldnt save much room
<sarahzrf> but it would simplify a lot of type signatures
<sarahzrf> is it not common practice to use functors to surround code where a giant block of declarations involves the same kind of type variable?
<sarahzrf> that seems like it would be convenient
<sarahzrf> er, i guess it depends on what kind of declarations they are, but
<sarahzrf> okay yeah i think i had one or two examples in mind and falsely generalized :)
FreeBirdLjj has joined #ocaml
<dmbaturin> You shouldn't hesitate to look in the prelude^W pervasives for examples by the way. It's quite readable. https://github.com/ocaml/ocaml/blob/trunk/stdlib/map.ml
<sarahzrf> oh yeah, i googled just a minute ago -
<dmbaturin> Standard library. Map is not in pervasives. :)
<sarahzrf> why is that OrderedType and not ORDERED_TYPE? what's the convention?
<dmbaturin> Bob Harper has a working capslock, but Xavier Leroy didn't. That's the only explanation that comes to mind. ;)
<sarahzrf> oh, it's an sml vs ocaml thing
<sarahzrf> hmm, i thought i saw the allcaps convention in ocaml examples .-.
<dmbaturin> Module names must start with a capital letter, but I haven't seen many all caps examples.
FreeBirdLjj has quit [Ping timeout: 245 seconds]
<dmbaturin> sarahzrf: I've recently give my toy project half-decent error reporting using Menhir's new approach, if you are interested. https://github.com/dmbaturin/bnfgen/tree/master/src The bnf_parser_messages.ml is autogenerated from bnf_parser.messages, which is generated by menhir --list-errors and filled by hand. I should make dune do it by itself.
<dmbaturin> * gave
<dmbaturin> * given
<sarahzrf> oh nice
keep_learning_M has joined #ocaml
<dmbaturin> Too bad the technique is poorly applicable to the non-toy project I wanted to give proper error reporting, its legacy grammar is so ambiguous that even with something more far-seeing than LR(1) it would be hard to produce meaningful error messages. Well, it's the first time anyone made a parser that truly understands that grammar in the first place.
<dmbaturin> The predecessors made two incomplete parsers for different tasks that cheated in different ways to pretend they are working.
<dmbaturin> sarahzrf: For something less offending to your haskeller feelings: https://github.com/dmbaturin/soupault/blob/master/src/soupault.ml#L128 this is ppx_monadic in action. :)
<sarahzrf> what is let%m ?
<dmbaturin> It's a syntax extensions that turns le%m x = f y in ... into f y >>= (fun x -> ...), like the do notation.
<dmbaturin> Using the bind from the current scope. Not as bad as it sounds, since there are local module imports (let open M in ...).
rgrant has joined #ocaml
AtumT has quit [Quit: AtumT]
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
mfp has quit [Ping timeout: 268 seconds]
companion_cube has quit [Remote host closed the connection]
ocabot has quit [Remote host closed the connection]
eskatrem has quit [Read error: No route to host]
rgrant is now known as [rg]
<sarahzrf> hah
<dmbaturin> Sometimes I feel like an infomercials host when talking about ML modules. ;)
<dmbaturin> But wait, there's more. Call now and get qualified record fields for free (M.{x=foo; y=bar}) without even opening the module.
_whitelogger has joined #ocaml
jao has quit [Ping timeout: 248 seconds]
kvda has joined #ocaml
[rg] has quit [Quit: [rg]]
<sarahzrf> you dont need to sell me on modules dont worry
<sarahzrf> i read robert harper say that they're vitally important and then his overbearing force of neckbeardery imprinted it upon my brain that it was true
<sarahzrf> hmm, "neckbeardery" can be parsed in too many different ways... but i'm not sure which word i wanted
<dmbaturin> I'm no match for Dr. Harper, but I'm practicing.
<dmbaturin> Since his blog is sadly dead (and he says he has no plans to revive it), I'm thinking of making a version of "dynamic languages are static languages" that people who haven't seen a sum type can read.
<sarahzrf> i think reading his blog single handedly set back my efforts to become less toxic on the internet by like a year :(
<sarahzrf> hmm, that's easy to misunderstand: not i got mad at him, but because he gave me so much new fuel for being a smug tool
<sarahzrf> ahhh THAT'S the word i wanted, "smug tool"
<dmbaturin> Sometimes I think I should try to be more toxic. Apparently that's how you get your work recognized. ;)
<sarahzrf> :-\
keep_learning_M has quit [Quit: This computer has gone to sleep]
gravicappa has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
rgrant has joined #ocaml
keep_learning_M has joined #ocaml
rgrant is now known as [rg]
dhil has joined #ocaml
_whitelogger has joined #ocaml
<sarahzrf> it is long past bed time
<sarahzrf> i was just about to close my laptop actually
<sarahzrf> good night :I
_whitelogger has joined #ocaml
[rg] has quit [Quit: [rg]]
dhil has quit [Ping timeout: 244 seconds]
hio has joined #ocaml
rgrant has joined #ocaml
rgrant is now known as [rg]
[rg] has quit [Quit: [rg]]
niklasl3 has left #ocaml [#ocaml]
_whitelogger has joined #ocaml
cranix has joined #ocaml
<cranix> hello
<cranix> i'm running freshly updated fedora-30 and i would like to install cow with opam
<cranix> opam wants to builds his own version of ocamlfind
<cranix> and it fails
<cranix> on compilation
<cranix> liblto_plugin.so not found
<cranix> i exhausted all ways to debug this problem
<cranix> i ran opam update and opam upgrade
<cranix> but this not helped
zapashcanon_ has left #ocaml [#ocaml]
zapashcanon has joined #ocaml
<zapashcanon> it's just that it can't find liblto_plugin.so, it's not opam related, make sure you have it somewhere on your system, should be the case if you installed gcc, then make sure it's at the expected location
<cranix> zapashcanon: i have gcc up and running
<cranix> zapashcanon: i asked fedora guys, but they were not able to help me
<zapashcanon> do you have liblto_plugin.so somewhere ?
<cranix> zapashcanon: what is this library?
<zapashcanon> I don't know
<zapashcanon> but you should have it
<cranix> both duckduckgo and goole gave me only unrelevant microcontroller-toolchain related thing
<cranix> can i install ocamlfind from system repository
<cranix> and thend force opam to use this version?
<zapashcanon> it's gcc related
<cranix> opam insists on building his own version
<zapashcanon> the lib
<zapashcanon> can't you just look for the file on your computer ?
<cranix> i did not found one
<cranix> and did not managed to find package that will containt it
<cranix> nor any information what this library is
<cranix> zapashcanon: can i force opam to use ocamlfind and similar tools from system repo
<cranix> not building his own?
<cranix> or is there a simple way to build this library in say docker and then move it to my machine?
<zapashcanon> locate liblto_plugin.so
mfp has joined #ocaml
<cranix> not found
<Armael> mmh are you using the system opam switch?
<Armael> (if you run `opam switch`, what's the name of the current switch?)
<cranix> Armael: no what is this switch?
<Armael> a switch that uses the system compiler, but it's a bad idea to use it
<cranix> why it is bad idea to use it?
<Armael> because it can break the switch whenever you upgrade your system packages
<Armael> it's better to use a switch where opam compiles its own ocaml compiler
<cranix> ok
<cranix> makes sense
<cranix> what is 'switch'?
<cranix> Armael: would be possible to tell opam to use ocamlfind, ocamlbuild and related programs installed from system repo instead of his owns build?
<Armael> I don't think it's possible, and it would be a bad idea for the same reason (that would break the switch whenever you upgrade your system)
<cranix> ok
<cranix> i will try to find this missing library
<cranix> if it will be in non-standard location how i can help opam find it?
Guest8026 has joined #ocaml
Haudegen has joined #ocaml
Guest8026 has quit [Remote host closed the connection]
<Leonidas> are you sure you installed the necessary development packages?
<Leonidas> liblto_plugin.so sounds like something that would be part of the compiler
<Leonidas> dnf provides '*liblto_plugin.so'
<cranix> Leonidas: Error: No matches found
<cranix> sorry typo in command
<cranix> found quite a lot packages with gcc
<cranix> for various architectures
<cranix> Leonidas: i have this package already installed in system
<cranix> opam switch
<cranix> default ocaml-system.4.07.0 default
<cranix> how i can tell opam where this library is located?
<Leonidas> cranix: so where is the file?
<Leonidas> I think you shouldn't use the system switch, but it's been said already by other people
Haudegen has quit [Ping timeout: 244 seconds]
<cranix> /usr/libexec/gcc/x86_64-redhat-linux/9
<cranix> opam depext tells me that all dependencies are installed
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<cranix> i'm trying LD_LIBRARY_PATH
<cranix> no luck
<cranix> Leonidas: what i should set?
<cranix> i checked env file and did not noticed any env variable for libraries and did not found any...
<cranix> i have setted LIBRARY_PATH
<cranix> this same effect
<Leonidas> cranix: opam switch create ocaml-base-compiler.4.08.0
<cranix> Leonidas: i ran this
<cranix> failed
<cranix> C compiler cannot create executables
<cranix> but my /usr/bin/gcc is working
<Leonidas> sudo yum groupinstall "Development Tools"
<cranix> when run standalone
<Leonidas> or something like this
<Leonidas> dnf groupinstall "Development Tools"
<Leonidas> dnf groupinstall "C Development Tools and Libraries"
<Leonidas> gcc might be working but not able to create binaries still
<Leonidas> since e.g libc-dev is missing
<cranix> i'm trying this...
<cranix> only perf will be installed...
<cranix> done
<Leonidas> hmm, that's not much
<cranix> this same problem with opam switch
<Leonidas> can you post the configure log somehwere?
<cranix> i will try to install just Developement Toos
<cranix> post configure log of what?
<cranix> i will first install Developement Tools
<Leonidas> when creating a switch, it shows "C compiler cannot create executables" and I want to know how it determines this
<cranix> ok
<cranix> one minute
<cranix> where i can find configure log?
<Leonidas> cranix: if you download the tarball of ocaml and run ./configure you can find the log in config.log
<Leonidas> how to get that in opam I don't directly know
<cranix> find .opam|grep config.log nothing found
<cranix> i have found it
<cranix> can not execute cc1 no such file or directory
<cranix> let's add symlink
<cranix> no luck
<cranix> unrecognize command line option -quite -auotbas
<cranix> -autobase conftest
<cranix> cc1 o
<cranix> told this
Haudegen has joined #ocaml
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
jao has joined #ocaml
ShalokShalom has joined #ocaml
FreeBirdLjj has joined #ocaml
zolk3ri has joined #ocaml
ShalokShalom has quit [Remote host closed the connection]
ygrek has joined #ocaml
ocabot has joined #ocaml
companion_cube has joined #ocaml
<Leonidas> cranix: looks like your system is missing the compiler (cc1 is the compiler part of gcc)
<cranix> Leonidas: i have present both gcc
<cranix> that *is* working
<cranix> and i have cc that is symlink
<cranix> but opam supplies strange flags to it
<cranix> that are not recogized
<cranix> as i wrote about
<cranix> *above
<Leonidas> cranix: but gcc != cc1, if you've symlinked it then it is wrong
tane has joined #ocaml
<cranix> so what cc1 should be?
TC01 has quit [Read error: Connection reset by peer]
TC01 has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
ziyourenxiang has quit [Ping timeout: 245 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
FreeBirdLjj has joined #ocaml
Haudegen has quit [Ping timeout: 245 seconds]
FreeBirdLjj has quit [Ping timeout: 272 seconds]
narimiran has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 258 seconds]
keep_learning_M has quit [Quit: This computer has gone to sleep]
narimiran_ has joined #ocaml
narimiran has quit [Ping timeout: 272 seconds]
Serpent7776 has joined #ocaml
<sarahzrf> is there a way to create a signature like "type foo; type bar = Baz of foo * foo; ..." where the types of subsequent declarations involve bar, without forcing every implementation of this signature to repeat the definition of bar
rgrant has joined #ocaml
rgrant is now known as [rg]
<dmbaturin> sarahzrf: Implementations can't avoid having conrete types fully specified. I'm not quite sure when such a signature would be easily reusable though.
<sarahzrf> well, im probably not writing idiomatic code rn
<sarahzrf> im just havin some fun experimenting with language features i dont normally get to use
Haudegen has joined #ocaml
<sarahzrf> oh huh, * is a built-in syntax on types but + isn't?
<sarahzrf> odd
<cranix> Leonidas: dnf provides cc1 nothing found
jao has quit [Ping timeout: 245 seconds]
zolk3ri has quit [Remote host closed the connection]
<dmbaturin> cranix: What wants cc1 again?
<dmbaturin> sarahzrf: You want built-in syntax for what? By *, you mean 'a * 'b syntax for tuples?
<dmbaturin> Or something else?
<sarahzrf> dmbaturin: yeah
<sarahzrf> i tried doing 'a + 'b for a sum type :b
<dmbaturin> Foo of 'a | Bar of 'b
<sarahzrf> ah no i know how to define a sum type
<sarahzrf> i was just remarking on the fact that there's a * but not a +
<dmbaturin> You can't have a sum type without explicit data constructors, and I can't see how 'a + 'b could work. :)
<sarahzrf> well, i thought maybe they'd be called Inl and Inr or something
<sarahzrf> coq has a notation + for its standard sum type & it calls the constructors inl and inr i think
<dmbaturin> ...or it could produce a magical GADT.
<Armael> dmbaturin: 'a + 'b would just be ('a, 'b) sum = Inl of 'a | Inr of 'b
<dmbaturin> Yeah, I got it, but isn't it a recipe for confusion?
<Armael> heh, maybe
<dmbaturin> There's already the result type isomorphic to it, too. :)
[rg] has quit [Quit: [rg]]
<dmbaturin> Also, menhir --compile-errors src/parser.messages src/parser.mly dumps the output to stdout and lacks a -o option. How can I make it into a dune rule?
<Armael> I think there's a with-stdout-to dune rule or something similar
<dmbaturin> By the way, am I the only one who thinks dune docs are poorly structured and need a revamp?
<sarahzrf> hmm, how come functor application requires parens
<sarahzrf> er, well, i guess it's futile to ask about that kind of thing when type application is postfix
<dmbaturin> After designing a few concrete syntaxes, I mostly gave up on trying to rationalize other people's decision in this area. :)
<sarahzrf> after writing haskell for years i recoiled at the idea of postfix type application but i sat down and tried typing out "int list ref" and went "...wtf i love this"
<sarahzrf> ...which makes a lot of sense when i remember that one of my other opinions is that function application being written prefix is probably a massive historical technical debt
<dmbaturin> How do you want it written?
<sarahzrf> postfix!
<sarahzrf> that way composition isn't backwards!
<sarahzrf> OOP languages have the right idea with method calls
<dmbaturin> x |> f |> g (* :) *)
<sarahzrf> when im fucking around in a ruby repl it's far more natural to keep chaining new methods at the end than when im fucking around in a haskell repl and i have to keep jumping back to the beginning of the line and adding a new function
<sarahzrf> oh shoo
<dmbaturin> Also, the $ is @@
<sarahzrf> what about .
<dmbaturin> f @@ g x
<dmbaturin> No . for you, not in pervasives. For some reason. I don't find that I need it often though.
<sarahzrf> huhhh
<sarahzrf> maybe ocaml is not so much like haskell then
<dmbaturin> Well, you can always make one if needed, and I alternative libs provide it.
<sarahzrf> i was gonna make some kind of joke that maybe f(x) notation was invented by islamic mathematicians so my complaints were already addressed since arabic is RTL but then i remembered reading that it's due to euler or sth
<dmbaturin> Curiously, really old ML code is often "pascal with first class functions and ADTs" rather than "haskell with references" style.
<sarahzrf> i feel like id heard of that somehow
<sarahzrf> er, gotten that impression* somehow
<sarahzrf> ML originated as a scripting language for a proof assistant, right
<dmbaturin> A while ago someone unearthed the source of the pre-SML ML. The very original ML is hard to even reconstruct exactly because the papers tell little about the ways it was written and used.
<sarahzrf> huh
<dmbaturin> ...what I find annoying about Python is how many functiona are -> unit
<sarahzrf> oh man, you're gonna hate C
<dmbaturin> I avoid C whenever I can, though not only for this reason.
<dmbaturin> I love how much dirty work ctypes does for me. I made a shared library to expose ocaml code to python without writing a line of C by hand.
<sarahzrf> pff
<dmbaturin> Most end users don't even know there's a caml under their bed now.
<cranix> dmbaturin: opam
<cranix> for building compiler
nicklaf has joined #ocaml
<dmbaturin> cranix: Fedora 30? I'm on 29, so I wonder...
<dmbaturin> I should update to 30 I guess.
<nicklaf> does anybody have an idea of where to start debugging regressions in ocaml programs that segfault?
<dmbaturin> cranix: Could you paste the complete log?
<nicklaf> the problem is probably in a c library dependency
gravicappa has quit [Ping timeout: 245 seconds]
narimiran_ has quit [Ping timeout: 244 seconds]
jnavila has joined #ocaml
<cranix> dmbaturin: one minute
<cranix> dmbaturin: log from fail of opam install cow?
<cranix> or from building switch?
Serpent7776 has quit [Quit: leaving]
<dmbaturin> cranix: From the one that fails. :)
jnavila has quit [Ping timeout: 246 seconds]
<cranix> both fail
<cranix> this is beginning of problem
jao has joined #ocaml
jnavila has joined #ocaml
nicklaf has quit [Ping timeout: 248 seconds]
nicklaf has joined #ocaml
wagle has quit [Read error: Connection reset by peer]
wagle has joined #ocaml
<dmbaturin> Armael: Thanks, I got with-stdout to do the trick. Somewhat ugly but it works: https://bpaste.net/show/4XMg
<octachron> cranix, fedora-related documentation seems to indicate that you need gcc-c++
<dmbaturin> In 29 it's a part of gcc package itself though it seems.
Haudegen has quit [Ping timeout: 245 seconds]
jao has quit [Remote host closed the connection]
dhil has joined #ocaml
<oni-on-ion> 29...
<dmbaturin> oni-on-ion: It's still supported.
jnavila has quit [Ping timeout: 246 seconds]
<oni-on-ion> 2.9 ?
<dmbaturin> If I wanted the very latest packages no matter the cost, I'd install arch. ;)
<oni-on-ion> ahh fedora
tane has quit [Quit: Leaving]
jao has joined #ocaml
jao is now known as Guest27582
Guest27582 is now known as jao
Haudegen has joined #ocaml
jao has quit [Remote host closed the connection]
jao has joined #ocaml
nicklaf has quit [Read error: Connection reset by peer]
<Leonidas> cranix: dnf provides '*cc1' since the * is expanded by dnf
Haudegen has quit [Ping timeout: 245 seconds]
Haudegen has joined #ocaml
dhil has quit [Ping timeout: 245 seconds]
Haudegen has quit [Remote host closed the connection]
Haudegen has joined #ocaml
hio has quit [Quit: Connection closed for inactivity]
rgrant has joined #ocaml
Haudegen has quit [Ping timeout: 245 seconds]
rgrant is now known as [rg]
_whitelogger has joined #ocaml
traviss has joined #ocaml
keep_learning_M has joined #ocaml