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
enterprisey has joined #ocaml
spew has joined #ocaml
marcux has quit [Ping timeout: 240 seconds]
jbrown has quit [Ping timeout: 240 seconds]
marcux has joined #ocaml
Soni has quit [Excess Flood]
Soni has joined #ocaml
marcux has quit [Ping timeout: 240 seconds]
marcux has joined #ocaml
iitalics has joined #ocaml
jsoo has joined #ocaml
jsoo has quit [Client Quit]
mfp__ has quit [Ping timeout: 260 seconds]
pierpa has quit [Quit: Page closed]
Associat0r has quit [Ping timeout: 260 seconds]
marcux has quit [Quit: Lost terminal]
mengu has joined #ocaml
mengu has quit [Ping timeout: 248 seconds]
malina has quit [Ping timeout: 240 seconds]
peddie[m] has joined #ocaml
Soni has quit [Read error: Connection reset by peer]
Soni has joined #ocaml
enterprisey has quit [Ping timeout: 255 seconds]
enterprisey has joined #ocaml
enterprisey_ has joined #ocaml
enterprisey has quit [Read error: Connection reset by peer]
spew has quit [Quit: foobar]
iitalics has quit [Quit: /thread]
kerrhau has quit [Ping timeout: 240 seconds]
_whitelogger has joined #ocaml
lopex has quit [Quit: Connection closed for inactivity]
samrat has joined #ocaml
jonasen has joined #ocaml
jonasen has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cbot_ has quit [Ping timeout: 255 seconds]
cbot has joined #ocaml
cbot has quit [Quit: Leaving]
jonasen has joined #ocaml
mnemem has quit [Read error: Connection reset by peer]
MercurialAlchemi has joined #ocaml
mnemem has joined #ocaml
shinnya has quit [Ping timeout: 255 seconds]
infinity0 has quit [Ping timeout: 255 seconds]
infinity0_ has joined #ocaml
infinity0_ has quit [Changing host]
infinity0_ has joined #ocaml
jonasen has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dakk has joined #ocaml
mnemem has quit [Ping timeout: 248 seconds]
jonasen has joined #ocaml
dakk has quit [Ping timeout: 240 seconds]
Simn has joined #ocaml
dakk has joined #ocaml
mnemem has joined #ocaml
troydm has quit [Ping timeout: 240 seconds]
enterprisey_ has quit [Read error: Connection reset by peer]
Associat0r has joined #ocaml
Associat0r has quit [Changing host]
Associat0r has joined #ocaml
AltGr has joined #ocaml
jonasen has quit [Ping timeout: 248 seconds]
mengu has joined #ocaml
Lightsephi has quit [Remote host closed the connection]
johnelse has joined #ocaml
Lightsephi has joined #ocaml
jonasen has joined #ocaml
lopex has joined #ocaml
shinnya has joined #ocaml
letoh has quit [Ping timeout: 252 seconds]
mengu has quit [Remote host closed the connection]
samrat has quit [Ping timeout: 260 seconds]
argent_smith has joined #ocaml
samrat has joined #ocaml
TheLemonMan has joined #ocaml
jonasen has quit [Read error: No route to host]
jonasen has joined #ocaml
mfp__ has joined #ocaml
letoh has joined #ocaml
ziyourenxiang has joined #ocaml
dhil has joined #ocaml
dhil_ has joined #ocaml
dhil_ has quit [Client Quit]
jonasen has quit [Read error: Connection reset by peer]
mengu has joined #ocaml
ShalokShalom has quit [Ping timeout: 258 seconds]
samrat has quit [Ping timeout: 260 seconds]
snhmib has joined #ocaml
copy_ has joined #ocaml
johnelse is now known as johnel_away
johnel_away is now known as johnelse
jonasen has joined #ocaml
mengu has quit [Remote host closed the connection]
infinity0 has quit [Remote host closed the connection]
AltGr has left #ocaml [#ocaml]
infinity0 has joined #ocaml
_andre has joined #ocaml
freusque has quit [Quit: WeeChat 1.7.1]
ansiwen[q] has joined #ocaml
AltGr has joined #ocaml
freusque has joined #ocaml
mengu has joined #ocaml
mayhew has joined #ocaml
lucas__ has joined #ocaml
lucas__ is now known as luukAntwerp
mengu has quit [Remote host closed the connection]
mengu has joined #ocaml
mrgrieves has quit [Ping timeout: 240 seconds]
superherointj has joined #ocaml
samrat has joined #ocaml
jonasen has quit [Read error: Connection reset by peer]
mengu has quit [Ping timeout: 246 seconds]
mengu has joined #ocaml
jbrown has joined #ocaml
superherointj has quit [Remote host closed the connection]
jonasen has joined #ocaml
shinnya has quit [Ping timeout: 248 seconds]
aciniglio has joined #ocaml
jbrown has quit [Ping timeout: 248 seconds]
marcux has joined #ocaml
ygrek has joined #ocaml
jbrown has joined #ocaml
samrat has quit [Ping timeout: 264 seconds]
mengu has quit [Remote host closed the connection]
benq has joined #ocaml
<benq> hi
malina has joined #ocaml
jbrown has quit [Read error: Connection reset by peer]
mengu has joined #ocaml
jbrown has joined #ocaml
mengu has quit [Quit: Leaving...]
cthuluh has joined #ocaml
hio has joined #ocaml
<hio> hi im new to ocaml, just tried to build a project but I get: "ocamlbuild -pkg cohttp-lwt-unix server_example.native
<hio> ocamlfind: Package `cohttp-lwt-unix' not found"
<hio> Cannot run Ocamlfind.
<companion_cube> you need to install the package with opam, probably
dtornabene has joined #ocaml
<hio> you mean ocamlfind? i literally just installed it right before i ran that command
<companion_cube> opam install cohttp-lwt, I mean
<companion_cube> or something like that
mnemem has quit [Ping timeout: 258 seconds]
samrat has joined #ocaml
freusque has quit [Quit: WeeChat 1.7.1]
<hio> is this normal, i installed it from source: Fatal error: the file '/usr/bin/camlp5' is not a bytecode executable file
<companion_cube> camlp5 ‽
<companion_cube> what switch (`opam switch`) and version of the compiler are you using?
<hio> 4.05.0
<hio> i just installed through opam and same problem
jonasen has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dtornabene has quit [Remote host closed the connection]
<companion_cube> have you eval `opam config env`? :/
mnemem has joined #ocaml
<hio> i restarted now and suddenly it works...
<companion_cube> it's probably a matter of environment indeed
mnemem has quit [Ping timeout: 258 seconds]
FreeBirdLjj has joined #ocaml
yawaramin has joined #ocaml
Denommus has joined #ocaml
Denommus has quit [Client Quit]
Denommus has joined #ocaml
<Denommus> hey
<hio> can someone explain why im getting this error? http://pastebin.centos.org/352381/
<hio> its a valid comment no?
<hio> nvm
<reynir> Denommus: react² :)
jonasen has joined #ocaml
<Denommus> reynir: I avoided numbers because people might think it's a version number
<def`> react-react is a nice name :P
<Drup> Reactive react ? :p
<Drup> (I like the name too, though :)
johnelse is now known as johnel_away
johnel_away is now known as johnelse
<companion_cube> hio: just in case: {w|… is the beginning of a string
<companion_cube> and strings are parsed in comments
AltGr has left #ocaml [#ocaml]
yawaramin has quit [Ping timeout: 255 seconds]
yawaramin_ has joined #ocaml
dakk has quit [Ping timeout: 255 seconds]
aciniglio has quit [Ping timeout: 240 seconds]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
yawaramin_ has quit [Ping timeout: 258 seconds]
yawaramin_ has joined #ocaml
ziyourenxiang has quit [Ping timeout: 248 seconds]
yawaramin_ is now known as yawaramin
<Denommus> def`: Drup: thanks
slash^ has joined #ocaml
mnemem has joined #ocaml
hio has quit [Quit: Leaving]
yawaramin has quit [Ping timeout: 255 seconds]
yawaramin has joined #ocaml
pmetzger has joined #ocaml
freefunc has joined #ocaml
malina has quit [Ping timeout: 255 seconds]
<pmetzger> What's the purpose of Uchar? It doesn't seem to be used anywhere (or supported anywhere) in the standard library...
<octachron> pmetzger, mostly intercompatibility between external libraries (like the result type)
<pmetzger> explain?
<pmetzger> btw, playing with unicode + ocaml, it looks like support is pretty weak. camomile seems to be semi-abandoned (and has its own UChar!), sedlex seems to be unmaintained (and uses ints), I can't find a regex library that seems unicode aware...
<pmetzger> None of this is actually going to hurt my current work too much but it is surprising.
<thizanne> pmetzger: having a single type that external libraries can agree on is nice for intercompatibility
<pmetzger> But I haven't seen it in use in external libraries so far. :)
<thizanne> even if you don't provide any function in the standard library
<thizanne> there are libraries from daniel bunzli, although i'm not quite sure what they eactly do (I never personnally needed unicode)
<octachron> pmetzer, the idea is that external library can use it to agree on what is the type of an unicoude scalar value, for instance: http://erratique.ch/software/uuseg/doc/Uuseg.html
<thizanne> (uucp, uuseg, uuidontremember)
<pmetzger> octachron: that one does indeed use it. hadn't stumbled on it yet.
yawaramin_ has joined #ocaml
<octachron> pmetzger, like thizanne said most of Daniel Bünzli's unicode libraries use it .
<pmetzger> thizanne: if you want to write a modern app that is easily internationalized it is hard to avoid unicode these days.
yawaramin has quit [Ping timeout: 258 seconds]
<Drup> Yeah, for unicode, the uu* libraries by bunzli are probably the best ones around
<Drup> sedlex was written before Uchar was added, it should really be ported
<pmetzger> sedlex needs love. I'm using it for a project. It's adequate but it needs improvements. I get the impression it hasn't been touched in a while.
<Drup> the impression is correct
Soni has quit [Ping timeout: 248 seconds]
<pmetzger> I like sedlex's use of ppx over other methods for handling the syntax btw. It's quite clean.
<Drup> I'm personally not very satisfied with some internal aspects of it, and I don't really took time to work on it further
<pmetzger> (I'm building a compiler front end; sedlex and menhir are my lexing/parsing tools.)
wwhite has joined #ocaml
<wwhite> Hi
<wwhite> anybody there?
<pmetzger> That depends on who anybody is.
malina has joined #ocaml
<yawaramin_> wwhite: what's up?
<wwhite> nothing of special, I'm a newbie and was wondering if it's possible to run a .ml file rather than use the "interactive" shell
<wwhite> just like with java or c. (after compiling or directly like with LUA).
<pmetzger> you can compile .ml files into either bytecode (ocamlc) or native code (ocamlopt)
<pmetzger> most ocaml code is compiled. the top level is just for experimenting.
<pmetzger> (debugging, etc.)
<wwhite> yeah I saw that, tried with ocamlc but was not able to run it then :\
<Armael> (note that you can also run them using the interpreter, by calling `ocaml yourfile.ml`)
<Armael> (but as pmetzger pointed out, most ocaml code is compiled)
<wwhite> Armael that's similar to LUA, and not possible with c or java, right?
<pmetzger> there are C interpreters.
<pmetzger> I don't know if there are Java interpreters, though there's nothing that prevents writing one.
<wwhite> oki, thanks, I'll try "ocaml filename.ml" :)
<pmetzger> why not try compiling and running?
<wwhite> because it compiled but I was not able to run it later (<--idiot)
mnemem has quit [Read error: Connection reset by peer]
<pmetzger> hard to help you fix that if you don't explain what you did.
<pmetzger> (or what you want to do and failed at.)
<wwhite> ocamlc filename.ml
Soni has joined #ocaml
Soni has quit [Changing host]
Soni has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
mnemem has joined #ocaml
<pmetzger> that's not likely to be what you wanted to run, but okay, what happened next?
<pmetzger> what platform are you on? what were you expecting to happen? what happened?
<wwhite> linux
<wwhite> print something
<wwhite> nothing basically xD
<pmetzger> compiling a program produces an executable. you have to run the executable afterwards. have you done much programming before now?
<Drup> If you don't give any other argument, the binary produced is called "a.out"
<yawaramin_> wwhite: if you compile with `ocamlc`, the output is bytecode. you need to run it using `ocamlrun`
<pmetzger> (If you haven't, mention that, and we will no what level to help you on.)
<Drup> yawaramin_: no you don't
<pmetzger> yawaramin_: on unix/linux, it puts a #! into the front of the bytecode so you can run it directly.
<pmetzger> no need to invoke the bytecode interpreter by hand.
<yawaramin_> and on Windows?
<pmetzger> he's on linux.
<pmetzger> I meant to say "know what level to help you on". gah.
<Drup> yawaramin_: pretty sure it's the same on cygwin&co
<yawaramin_> fair enough. then i'm out of ideas :-)
<pmetzger> yawaramin_: ideas for what? he didn't try running the output. :)
Anarchos has joined #ocaml
<yawaramin_> it's not clear what exactly he tried. in fact, it's not clear that it's a 'he' ;-)
<pmetzger> if he's a she, or a xe, or something else, I'm happy to be corrected. :)
<yawaramin_> 👍
ygrek has quit [Ping timeout: 255 seconds]
<Denommus> damn, I just remembered I completely forgot to have props in my ReactReact library
dakk has joined #ocaml
dhil has quit [Ping timeout: 240 seconds]
ShalokShalom has joined #ocaml
<pmetzger> Drup: If one wanted to help with sedlex, what would one need to do?
samrat has quit [Ping timeout: 240 seconds]
<Drup> that's actually not an easy question
Algebr has joined #ocaml
<Drup> there are two possible ways: improve re until it can do lexing, or improve sedlex until it has a decent regex engine
<pmetzger> my biggest pain point at the moment with sedlex is the lack of regex context. I need to be able to fail to match in certain circumstances depending on trailing context.
<Drup> yeah, the regex engine is extremely basic
<pmetzger> I would say improving sedlex seems like the lowest barrier to entry. But I don't want to make changes without talking to the project owners.
<thizanne> pmetzger | thizanne: if you want to write a modern app that is easily internationalized it is hard to avoid unicode these days.
<thizanne> then i'm lucky not wanting that !
<Drup> I have commit rights on sedlex :p
<pmetzger> Should I just fork it and play? Some things (like switching it to use Uchar.t instead of int) would seem like very quick work, but would be breaking changes.
<Drup> Yeah, feel free to fork it and play
<freefunc> Hi everyone
<pmetzger> Drup: I might do that in a couple of weeks. I need to get my basic code generation going but then I'll want to clean things up and fixing some sedlex issues would be high on my list.
<freefunc> So I am making a small lib, I have a set of functions that are implemented differently and another one that is similar to both
FreeBirdLjj has joined #ocaml
<Drup> There are three big issues, I would say
<Drup> 1) lack of name bindings
<freefunc> to avoid code duplication, I'd like to use a functor (say "Make") that takes one of the implementation as input
<freefunc> the common functions would live inside Make
<Drup> 2) lack of basic regex constructs, such as posix
<pmetzger> Drup: name bindings = capturing submatches?
<freefunc> My problem is: I have helper functions that the two submodules (say S1 and S2) share
<Drup> 3) non-modularity of regex definitions
<freefunc> I would like to not duplicate the code for them
<Drup> 1 and 2 basically need a reimplementation of the engine
<pmetzger> Drup: (2) is an obvious problem. I don't quite get what you mean by (3).
<Drup> 3 has to do with how the ppx is defined
<freefunc> but among those helpers, there are some functions that would live inside the Make functor
<freefunc> how do I go about this?
<pmetzger> (2) will certainly require significantly improving the regex engine. Luckily that's a well understood set of algorithms.
<Drup> pmetzger: ahah, famous last words
<pmetzger> Drup: :)
<Drup> freefunc: divide your helper functions in the part that lives outside the functor and the ones that are inside ?
<Drup> (or just put everything inside, that works too)
<Drup> pmetzger: how well-versed are you in things like borowzski derivatives and thomson automatons ?
<freefunc> Drup but then I'd have to add the helper functions that rely on functions from the functor to the functor signature?
<pmetzger> Drup: Thompson automatons I know well. Borowzski derivatives not at all.
<freefunc> I'd rather expose not those function
<freefunc> s
<pmetzger> Drup: for performance in lexical analyzers I'd want to use the Thompson construction or something similar, definitely.
<wwhite> may someone link a good basic tutorial about those commands ?
<freefunc> not expose*
<Drup> pmetzger: not necessarely
<Drup> you don't have to expose the complete output of the functor, you can hide part of it as you wish
<pmetzger> I am reminded of https://swtch.com/~rsc/regexp/regexp1.html of course.
<Drup> huh, freefunc^
<freefunc> Drup: ok, but then, let's say S1 and S2 rely on helper (remove_head x) which itself relies on (get_size x) which is implemented in Make
<wwhite> none?
<pmetzger> wwhite: sorry, context?
<freefunc> how can I use remove_head from S1?
<Drup> pmetzger: right, yes, so you have to read that series, and I would advise also to read this paper: https://www.mpi-sws.org/~turon/re-deriv.pdf
<pmetzger> wwhite: If you want to understand the basics of using OCaml, I suggest trying a book like Real World OCaml. (That one is online for free.)
<Drup> freefunc: I would need a complete example
<pmetzger> wwhite: but the man pages for commands like "ocamlopt" and the like will be in your distribution. you know how to use "man" I presume.
<pmetzger> Drup: I've read that series (and knew the content before I read it in fact) but I'll read that paper.
<Drup> pmetzger: that series actually re-do what derivatives do, in a more pragmatic fashion
<pmetzger> You mean the Thompson DFA construction re-derives the idea of RE derivatives? :)
hio has joined #ocaml
peterbb has quit [Quit: Lost terminal]
<Drup> :p
<hio> I'm not sure that I like ocaml so far, very confusing to set up. Constantly some weird errors
<pmetzger> Drup: I'm sorry, it was impossible to resist.
<Drup> Thompson doesn't, but the extension proposed in this series do
<pmetzger> hio: What issues are you having?
<pmetzger> hio: Generally I've found it quite pleasant to use but the initial setup was kind of irritating. The language is very nice, almost soothingly pleasant.
<Drup> pmetzger: the problem is that doing submatching in this context is not that easy ...
<pmetzger> Drup: you mean capturing submatches.
<pmetzger> Drup: I thought Pike had an algorithm for that based on Thompson's algorithm.
<Drup> It all depends on how many features you want in your regex engine :D
<pmetzger> Drup: There was also some work done by Ville Laurikari as part of his regular expression package IIRC.
<wwhite> pmetzger yes ofc, thank you
<Drup> (like, unions, intersection, lazy determinisation or not, and so on)
<pmetzger> Drup: Generally I prefer to avoid backtracking. NP complete things are icky.
<wwhite> there are also some things about "functions inside functions" that I would like to ask if possible
<wwhite> not now though
<wwhite> (sorry but my english is pretty bad i know =( )
<Drup> pmetzger: oh sure, that's out of the question
<pmetzger> Drup: I think the Perl REs minus backtracking and other nastiness that makes things very non-regular are a good target for a normal re library. for lexing, what is in sedlex plus a few things like context and capture are probably enough.
<pmetzger> anchoring, positive and negative context probably?
<pmetzger> and capture
wwhite has quit [Quit: leaving]
<pmetzger> A syntax for capture that works well in a PPX context is an interesting problem.
<Drup> Actually, that's easy
<Drup> (... as x)
<pmetzger> Yup, that would clearly be the way to do it.
<pmetzger> Hadn't thought of it but it's of course the right thing.
<pmetzger> (I'm an OCaml newbie, been using it for under a month for serious work, so things like "as" aren't nailed enough in my head yet.)
<pmetzger> (I'm enjoying it a lot, though the documentation keeps driving me crazy. Luckily ocaml source is easy to read, unlike say C++)
<pmetzger> Named capture would make a lot of what I'm doing much much easier.
<pmetzger> Right now I'm faking things by resetting and passing the lexbuf to a distinct lexing function to walk over the string again. Very very disgusting IMHO.
<pmetzger> no, let me walk that back. modestly disgusting. It's not too bad, but it's doing the same work twice.
<hio> I am just trying to run the sample code here but it doesnt work: https://github.com/mirage/ocaml-cohttp
<yawaramin_> hio: what happens?
<Drup> pmetzger: yeah, it's annoying, I agree
<hio> ocamlbuild -pkg cohttp-lwt-unix client_example.native
<hio> ocamlfind: Package `cohttp-lwt-unix' not found
<hio> Cannot run Ocamlfind.
<pmetzger> have you installed cohttp-lwt-unix?
<pmetzger> perhaps it isn't there in which case use opam to pull it in
<pmetzger> (I believe that's part of the cohttp library, aka opam install cohttp)
<pmetzger> btw, I thought it used underscores (_) not dashes (-)
<hio> weird, i swear i tried that 50 times but now i did it and it worked...
<pmetzger> tried what?
<hio> opam installing that library
<pmetzger> one trick I've found useful is learning how the ~/.opam directory is laid out. If you can read things like the META files you can figure out quite a bit about what is failing.
jnavila has joined #ocaml
<pmetzger> I may be a weird person in this regard, but a lot of the docs for beginner say "just do X to build this thing" and I've found understanding what the tools do has made it _vastly_ easier to get my work done. treating them like black boxes was failing for me too much.
<hio> I feel like ocaml is a hard language to learn, I only know c-like languages so far
<companion_cube> don't worry, it's also hard to learn C if you only know OCaml ;)
<pmetzger> hio: it is a very normal functional language, but you probably don't know anything about what those are like, so it will be alien for quite a while. it is worth it though.
<pmetzger> One trick is to understand how some of the features map. At first algebraic datatypes seem a bit too magical if you're a C programmer. After a bit you get used to them.
<pmetzger> but the pieces map pretty easily if you think about it. records are like structs. variants are like discriminated unions + enums. arrays are easy of course. Lists are like singly linked lists where you hold a handle to the front.
<pmetzger> the more important difference is the functional style. getting used to not mutating things and using function composition as a basic tool.
jmiven has quit [Quit: co'o]
jmiven has joined #ocaml
<pmetzger> sadly I don't really remember what it is like not to "get" that part of the idea. I learned Lisp 35 years ago and my beginner mind neurons are long gone.
Simn has quit [Ping timeout: 255 seconds]
<hio> ocaml is fast, it compiles fast.. what is the drawback here? any gotchas?
aciniglio has joined #ocaml
<hio> i guess java is still faster
<pmetzger> hio: So far my only complaints are (1) the documentation isn't as good as I would like (2) the build system(s) are baroque and you need to learn to understand them quickly.
<yawaramin_> it doesn't really do much optimisation. if you optimise more (e.g. with flambda) the compile slows down
<pmetzger> hio: I don't know that Java is faster really.
<yawaramin_> but even relatively unoptimised binaries are still pretty fast.
Simn has joined #ocaml
<pmetzger> Actually one other complaint: since the community is small, sometimes the thing you want isn't there or isn't maintained. But so far I've been _insanely_ productive given that I've been using the language for real work for so short a period of time.
<yawaramin_> cool, always good to hear.
<pmetzger> By contrast, I supposedly know C++ but every time I start a new project I feel like I'm starting from scratch and swimming in molasses.
<yawaramin_> OOC, ever tried D?
<pmetzger> I'm using OCaml at the moment specifically for the LLVM bindings because I was finding C++ so insanely unpleasant for the same work.
<pmetzger> I've never tried D.
<hio> how big is the language feature surface area
<hio> can I learn it in a day?
<yawaramin_> you can learn the basics in a day.
<pmetzger> hio: I don't know how good you are at learning, so I can't say. It's a small language compared to Java and especially compared to C++.
<hannes> hio: I think the basics are pretty straightforward.
<companion_cube> it's small if you don't touch the OO pat
<companion_cube> part
<hannes> things like lwt (an asynchronous task framework), the module system, the object system, are better kept for another day ;)
<pmetzger> the basics are quite straightforward if one is used to a functional language. If one isn't used to functional languages it might not seem so straightforward.
mnemem has quit [Quit: WeeChat 1.9.1]
<pmetzger> to me the most frustrating thing was that almost from the start, if one has a project in multiple .ml files one must learn how to use some build system, and that slows you down. I gave up and just write grotesquely elaborate Make rules at the moment.
<pmetzger> I'll have to learn jbuilder or what have you at some point but I'm putting it off.
<pmetzger> (I tried looking at jbuilder and it wasn't obvious what it was doing which I found frustrating.)
<companion_cube> yeah the docs are not so simple -_-
<hannes> pmetzger: I initially started with oasis since it was pretty easy to copy templates from elsewhere, but these days I use topkg (which invokes ocamlbuild)
<pmetzger> I have a couple of bugs in my Make logic so it tends to rebuild too much. Luckily the compiler is very very fast on a modern machine so I barely notice.
<companion_cube> try ocamlbuild perhaps?
<yawaramin_> yeah the jbuilder docs are a bit opaque ... they seem to assume you already know their worldview and just want to do specific things
<pmetzger> I tried ocamlbuild but hit some wall and then just started throwing ocamlfind+ocamlopts into a Makefile and I've been happy.
<pmetzger> if not entirely efficient.
<Drup> You might like OCamlMakefile
<hannes> pmetzger: fair enough if it works for you
<pmetzger> I may try ocamlbuild again at some point in the next few weeks. right now I'm very happily churning out code at a preposterous rate.
<Drup> I cant say I advise it but, oh well
<pmetzger> BTW, I definitely don't think using a Makefile is the right thing. It's insane how complicated my Makefile is. But I understand what it is doing, and it's working for the moment. I would never tell a beginner who wasn't really used to Make to do this.
<Drup> (it's probably broken too)
<pmetzger> And Make really isn't "used to" the idea of one command producing multiple needed target files (say .cmx and .cmi)
<pmetzger> It is broken in that I'm recompiling too much every time I type make, but not broken in that I'm not failing to recompile things I need to. :)
<companion_cube> ocamlbuild for basic projects is super simple, though
<hio> uh is the ocaml repl broken for you too? i cant get to the last line with the arrow up key
FreeBirdLjj has quit [Remote host closed the connection]
<pmetzger> hio: are you using utop? if not, switch to utop.
<yawaramin_> or just `rlwrap ocaml`
<companion_cube> hio: it doesn't have readline baksed in
<companion_cube> everyone uses utop
<pmetzger> BTW, I have to say that emacs+tuareg+merlin is kick ass.
FreeBirdLjj has joined #ocaml
<pmetzger> I save my file and it shows me my type errors before I even try to compile! so sweet.
<pmetzger> But I'm not telling anyone anything they don't know already. :)
<pmetzger> I do wish the docs were better. I constantly read something and I'm like "okay, but what is StringLabel *for*" etc. But OTOH, my overall experience has been excellent.
dakk has quit [Ping timeout: 248 seconds]
<yawaramin_> yeah docs are very minimalistic
<hio> how come so many compilers are written in ocaml first
FreeBirdLjj has quit [Ping timeout: 258 seconds]
<yawaramin_> pattern matching and other stuff. easy to do case analysis because the compiler helps you out
<Denommus> hio: OCaml has a good lexer and a good parser generator, and the type system helps modeling the AST
<companion_cube> you can ask merlin for docs, pmetzger ;)
<pmetzger> ocaml is practically designed for writing a compiler. :)
<Denommus> pmetzger: I was recently amazed that merlin also supports ReasonML
<pmetzger> companion_cube: yes, but the docs it gives me only tell me the same incomplete thing the web pages say. :)
<yawaramin_> e.g. Graydon Hoare on why he started writing Rust in OCaml https://twitter.com/graydon_pub/status/917116222776295424
<hannes> pmetzger: there are some libraries which are excellently documented... I stick to them and try to avoid others ;)
<pmetzger> Oh, one question. I fear asking it because I suspect there is going to be a brick thrown at me. Why doesn't OCaml have typeclasses?
<hio> ironic that he appreciates the instant compilation
<hio> then he makes a language that doesnt do that
<Denommus> pmetzger: modules subsume typeclasses
<Drup> Denommus: that is not completely correct
<pmetzger> Not really from what I can tell.
<yawaramin_> hio: lol. that wasn't his goal
<Denommus> in fact, look for "modular implicits", which AFAIK are in the works
<Denommus> Drup: but for most pragmatic purposes it is
<hannes> pmetzger: you may enjoy reading http://tycon.github.io/modular-implicits.html -- they're not there (yet)
<companion_cube> don't promise stuff before it's delivered :/
<companion_cube> it could be 5 years from now
<Drup> pmetzger: please do complain/report bug when you find crappy documentation
<Drup> some is know, of course, but some less so
<pmetzger> hannes: I wonder what a person who didn't know what an existential type is would make of that web page. Luckily I know. :)
<hannes> pmetzger: or to rephrase: there's a prototype, it's hard, and not there yet. it may appear some day.
<Denommus> pmetzger: for instance, the "monad" typeclass can be understood as the following module sigs: https://gist.github.com/Denommus/dc6a027ec1760abfc8e6
<companion_cube> it's like multicore.
<companion_cube> I'll believe it when it's merged.
<pmetzger> So given modular implicits, I could conveniently do most of the things typeclasses do.
<companion_cube> … in $n years
<Denommus> pmetzger: even without modular implicits you can, it's just more verbose
<pmetzger> That might let me get rid of some of the ppx deriving show magic I suppose. Though so far that's been doing well for me.
<pmetzger> Denommus: more verbose is a problem. that which is cumbersome one avoids doing. :(
<Denommus> pmetzger: it might be a problem, but it's still beter than writing the same functions multiple times
yawaramin has joined #ocaml
<Denommus> pmetzger: also, modules don't have some problems that typeclasses have, like orphan instances
kerrhau has joined #ocaml
kerrhau has quit [Changing host]
kerrhau has joined #ocaml
yawaramin_ has quit [Ping timeout: 258 seconds]
<pmetzger> BTW, I have to say I'm also very happy about the fact that OCaml isn't pure functional. I like being able to just throw some side effects in for debugging without having to alter my type structure.
<Drup> pmetzger: you would still have deriving with typeclasses/modular implicits
<Drup> (as you do in haskell)
<Denommus> I wouldn't say one approach is superior to the other, they both have their own set of advantages and disadvantages. But, in general, I prefer modules
<pmetzger> BTW, I haven't yet looked for a quickcheck like library for ocaml. I imagine if I google I'll find at least one.
<Drup> It's even called quickcheck
<pmetzger> :)
<companion_cube> Drup: meh
<hannes> pmetzger: you may also be interested in crowbar - which uses property-based testing together with afl
<pmetzger> I'd say the only thing that really was giving me headaches was trying to figure out camlp4, but then I learned the world is moving to ppx and I happily stopped trying to figure out how it works. :)
kakadu has joined #ocaml
<pmetzger> 95% of my problems on my project have been trying to puzzle out LLVM stuff from their truly atrocious documentation and their C++ code. Even though I'm a total OCaml newcomer. It's just really so _pleasant_.
<pmetzger> (OCaml that is.)
<hannes> pmetzger: what are you doing with LLVM?
<Drup> the LLVM API is not the most pleasant
<pmetzger> I'm building a programming language front end that uses LLVM as the back end.
<Drup> (especially since the bindings are far from perfect)
<pmetzger> you mean the OCaml bindings. Yah, they're mediocre. I wish they were more OCaml-like and much more strongly typed.
leah2 has quit [Ping timeout: 240 seconds]
<pmetzger> I've had my program core dump because of what amounted to type errors that couldn't be caught because everything in sight is just an llvalue
Anarchos has quit [Quit: sleep]
<Drup> I had a plan to rewrite them, but I would need a few month, and I didn't had them :p
<pmetzger> If you ever get to it I won't complain. :)
slash^ has quit [Read error: Connection reset by peer]
<pmetzger> I presume by now someone has played with retargeting the ocaml compiler at LLVM? I wonder how it performed.
cbot has joined #ocaml
<Drup> It performed "howdoIevenimplementGCroots"
<Drup> :]
<pmetzger> There must be a way to do that, GHC does it right?
kakadu has quit [Ping timeout: 240 seconds]
kakadu_ has joined #ocaml
<Drup> A few years ago, it was waiting a bunch of things that were in the pipeline
<Drup> not sure what's today's situation
<pmetzger> I suspect that it has to be better given GHC and other functional languages using it as a back end. But I have no time to check. :)
jonasen has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leah2 has joined #ocaml
<freefunc> Re -
<freefunc> so I have this code: https://pastebin.com/Avx7NwJQ that doesn't compile
<freefunc> it would if I changed the type signature of my functor's functions from "t" to "F.t"
<freefunc> but I don't understand why...? and in addition to that, if I'm forced to replace it then what's the purpose of the functor's "type t"
<freefunc> and also, how to make my conversion functions (of_string and of_format) work? they used to be quite simple because type t = string and so the compile infered what needed to be
<Drup> you meant "from string to F.t", I suppose ?
<Drup> freefunc: In any case, the first issue is that maker is the signature of a functor, not the signature of the output module, you are not using it right
<Drup> the second issue is that you seem to assume that F.t = string inside the body of the functor, but since t is abstract in the Format signature, that is not the case
<pmetzger> BTW, when does 4.06 come out? It apparently has a number of little steps towards unicode friendliness...
<companion_cube> it's on beta right now I think
<pmetzger> so soonish?
<companion_cube> probably :)
hio has quit [Quit: Leaving]
benq has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
yawaramin has quit [Ping timeout: 246 seconds]
copy_ has quit [Quit: Connection closed for inactivity]
fraya has joined #ocaml
fraya has quit [Quit: Leaving]
_andre has quit [Quit: leaving]
snhmib has quit [Ping timeout: 260 seconds]
mayhew has quit [Quit: WeeChat 1.6]
jlouis has joined #ocaml
argent_smith has quit [Quit: Leaving.]
jnavila has quit [Quit: Konversation terminated!]
<freefunc> Drup: but the functor outputs the output module, no?
<Drup> freefunc: let's make a comparison
<freefunc> I'm using https://realworldocaml.org/v1/en/html/functors.html - very new to functor, a bit confused... I understand they are parametrized module though
<Drup> This is wrong: `let f (i : int) : int -> int = i + 1`
<Drup> This is right: `let f (i : int) : int = i + 1`
<freefunc> oh I see ok
dakk has joined #ocaml
<freefunc> In ` module Make (F : Format) : Maker` I need to drop either the `(F : Format)` or the `: Maker`, right?
<freefunc> otherwise my definition is redundant, it's a functor that outputs a functor
<Drup> you can't drop the (F: Format)
<Drup> just like you can't write `let f : int -> int = i + 1`
<freefunc> oh right
<freefunc> I thought Maker would be replaced by its definition
<freefunc> i.e `functor (F : Format) ...`
<freefunc> for the second issue, basically I'd like to make a bunch of functions that are common to every functorized module without duplicating code
<freefunc> *I* know that the Format modules are all based on the same type and so I make that assumption, but I know it's ugly. is there a better way to do it?
<Drup> If something is present in all the arguments, you can also just leave it outside
<freefunc> can I create a type that's either Format1 or Format2 exactly?
<freefunc> something like type `type a_format = Format1 | Format2`
kerrhau has quit [Quit: bye!]
Algebr has quit [Remote host closed the connection]
<Drup> freefunc: can you show your actual example ?
gacepa has joined #ocaml
<freefunc> also, why is it that my of_string function don't return a "type t" but a "string" (despite my signature saying it is "val of_string : string -> t") but the compiler doesn't mind (tells me the signature is "val of_string : 'a -> 'a")?
<freefunc> Drup: so far, I don't have a working example. I'm trying to do that for a binary string lib (was here a couple days ago, you helped me a lot!) defining two types (LittleEndian and BigEndian)
<Drup> well, it's not because you say it that it's right, the compiler has to check :p
<Drup> in this case, the function you write is the identity, so 'a -> 'a, but t ≠ string, so it can't be string -> t
kerrhau has joined #ocaml
kerrhau has joined #ocaml
kerrhau has quit [Changing host]
aciniglio has quit [Ping timeout: 258 seconds]
<freefunc> in my previous version, I had an abstract `type t = string` and unsafe functions that could convert back and forth (`unsafe_b : t -> string` and `unsafe_s : string -> t`)
<freefunc> how come the compiler was able to infer all that was needed but not now?
yawaramin has joined #ocaml
<freefunc> My implementation of those function was the identity function
Simn has quit [Ping timeout: 258 seconds]
dakk has quit [Ping timeout: 240 seconds]
Soni has quit [Ping timeout: 240 seconds]
Soni has joined #ocaml
cbot has quit [Ping timeout: 248 seconds]
<orbifx[m]> Can a function take a module as a parameter?
<companion_cube> a first class module, yes
<orbifx[m]> I don't need to determine the module at run time, it's known during compile time.
<companion_cube> then why do you need it passed as an argument? :D
<orbifx[m]> Is that the only way companion_cube ?
<orbifx[m]> It's a functor actually
<companion_cube> you could wrap this into a functor
<orbifx[m]> So I create an instance elsewhere in the code and wish to use that instance in function
<orbifx[m]> Wrap this into a functor?
<yawaramin> wrap the function inside a functor, the functor takes a module as a param
<companion_cube> ^
<companion_cube> if everything is static you don't need the function to take a functor
<orbifx[m]> not what I'm after. There can be many different implementation of this function
<companion_cube> well it's either functor or passing a first-class module (which can be a first-class functor)
<companion_cube> good luck
<orbifx[m]> Or this class of functions, independent of the module that implements the module.
<orbifx[m]> Ok, looks like first-class functor.
<orbifx[m]> But one last one question: can I pass a type as parameter and therefor instantiate the module inside the function?
<orbifx[m]> Wait.. I guess that would be a module again, not a type.. and we are back to what I asked before
<orbifx[m]> thanks, will look more into this and first class mods.
<companion_cube> let f (type a) … =
cbot has joined #ocaml
xa0 has quit [Quit: Divided by zero]
<yawaramin> or `module Make(Input : sig type t end) = struct ... end`
malina has quit [Quit: Throwing apples of Montserrat]
yawaramin has quit [Ping timeout: 255 seconds]
yawaramin has joined #ocaml
cbot has quit [Ping timeout: 258 seconds]
cbot has joined #ocaml
john51 has quit [Ping timeout: 252 seconds]
john51 has joined #ocaml
john51 has quit [Read error: Connection reset by peer]
john51 has joined #ocaml
yawaramin has quit [Remote host closed the connection]
<orbifx[m]> thanks companion_cube yawaramin
<freefunc> Can someone explain me what I'm missing here? https://pastebin.com/Rbxyp0wt
<freefunc> I'd like unsafe_b to be of type (F.fmt -> string) and unsafe_s of type (string -> F.fmt) instead I get (F.fmt -> F.fmt) and (string -> string)
<freefunc> also what do I need to do to make the compiler yell if Make doesn't implement Maker faithfully (like now)
<lyxia> module Make : Maker = functor (F : Format) -> struct ... end
shinnya has joined #ocaml
marcux has quit [Quit: Lost terminal]
marcux has joined #ocaml
benq has joined #ocaml
andreas__ has quit [Quit: Connection closed for inactivity]
kakadu_ has quit [Remote host closed the connection]
<freefunc> lyxia: thanks friend
Denommus has quit [Quit: going home]
kerrhau has quit [Ping timeout: 240 seconds]
<lyxia> You're welcome, buddy
kerrhau has joined #ocaml
kerrhau has joined #ocaml
kerrhau has quit [Changing host]
webshinra has quit [Ping timeout: 255 seconds]
freefunc has quit [Ping timeout: 260 seconds]
marcux_ has joined #ocaml
webshinra has joined #ocaml
gacepa has quit [Quit: Connection closed for inactivity]
pmetzger has quit []
marcux_ has quit [Ping timeout: 258 seconds]
freefunc2 has joined #ocaml
freefunc2 has quit [Ping timeout: 260 seconds]
igstan has joined #ocaml
igstan has quit [Client Quit]