adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.09 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.09/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
kleisli has quit [Remote host closed the connection]
kleisli has joined #ocaml
rig0rmortis has joined #ocaml
ollehar has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
rig0rmortis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jbrown has quit [Ping timeout: 260 seconds]
rig0rmortis has joined #ocaml
mfp has quit [Ping timeout: 240 seconds]
borne_ has quit [Ping timeout: 260 seconds]
_whitelogger has joined #ocaml
osa1 has joined #ocaml
bitwinery has joined #ocaml
vicfred has joined #ocaml
bitwinery has quit [Remote host closed the connection]
_whitelogger has joined #ocaml
leah2 has joined #ocaml
reynir has quit [Ping timeout: 256 seconds]
reynir has joined #ocaml
rig0rmortis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rig0rmortis has joined #ocaml
osa1 has quit [Quit: osa1]
rig0rmortis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_whitelogger has joined #ocaml
bartholin has quit [Quit: Leaving]
waleee-cl has quit [Quit: Connection closed for inactivity]
osa1 has joined #ocaml
narimiran has joined #ocaml
osa1 has quit [Ping timeout: 264 seconds]
osa1 has joined #ocaml
mbuf has joined #ocaml
kleisli has quit [Ping timeout: 260 seconds]
osa1 has quit [Ping timeout: 240 seconds]
narimiran has quit [Ping timeout: 258 seconds]
Tuplanolla has joined #ocaml
jbrown has joined #ocaml
g0d_shatter has joined #ocaml
dckc has quit [Ping timeout: 256 seconds]
dckc has joined #ocaml
osa1 has joined #ocaml
borne_ has joined #ocaml
mbuf has quit [Ping timeout: 256 seconds]
borne_ has quit [Ping timeout: 272 seconds]
antaoiseach has joined #ocaml
_whitelogger has joined #ocaml
<antaoiseach> Hello folks ... newbie to OCaml, with a particular interest in using it to eventually write compilers in. Do you folks know of any good resources that uses OCaml to write a simple compiler from scratch - no parser generators et al. I'm also planning to work through the LLVM Kaleidoscope OCaml tutorial once I get the hang of basic OCaml. Any suggestions would be warmly welcomed! :-)
mfp has joined #ocaml
<flux> antaoiseach: perhaps this is useful to you: https://github.com/andrejbauer/plzoo . buut, all of them use parser generators, you can probably find general level non-ocaml-specific material about writing those manually.
madroach_ has quit [Quit: leaving]
<flux> I would highly suggest making use of lexer and parser generators, however, unless your interest particularly in writing those parts yourself
<antaoiseach> flux: Thanks for sharing the resource! Yeah, I did a lot of search, but didn't find the sweet spot betwen a basic maths expr evaluator and a fullblown compiler
<flux> you can look at OCaml parser combinator libraries as well
<antaoiseach> That should be useful for me in any case though! :-)
<antaoiseach> flux: Yeah, I'm interested in mastering the innards of lexers and parsers first and then working on the code gen and optimisation parts - mostly for edificational purposes! :D
<flux> antaoiseach: I suppose it will give you valuable insight why people like to use generators.. ;-)
<antaoiseach> Interestingly, I did a small parser combinator like library (very basic) in Haskell .... I'm assuming it should be trivially translatable into OCaml? I don't think monad notatione exists in OCaml (?) but pattern matching should be very useful along with ADTs... I'm hoping!
<flux> antaoiseach: actually perhaps you should look into actual scientific literature on the topic
<antaoiseach> flux: Hahaha .. well, maybe I can write a parser generator as a bigger project after that! :D
<antaoiseach> flux: I do have a a few books lined up for reading alongside the practicals ... so it should be fun!
<flux> antaoiseach: btw, perhaps start with interpreters
<antaoiseach> flux: good idea ... I will most likely do that. I'm planning to work through Bob Nystrom's Crafting Interpreters course as a sort of prelude.
<flux> on the surface this seems like a decent C-based material: https://www3.nd.edu/~dthain/compilerbook/
<flux> parsing in practice chapter.. starts with parser generator :)
<flux> but the previous chapter uses hand-written one
<flux> I guess those are pretty sophisticated parser compared to what one would typically hand-write, though..
<antaoiseach> flux: Agreed ... those would be way beyond my reach for now, but with the experience gained from doing everything from scratch, I hope to be able to focus on the optimisation parts with more confience. Otherwise I'll feel like I haven't done it properly.. just a quirk I guess!
<antaoiseach> Btw, I had a question about OCaml in general
<antaoiseach> So from what I heard, OCaml comes with a pretty lean stdlib, right? And RWO (the book) et al recommend using Core ...
<flux> yes
<antaoiseach> For compilers I suppose that wouldn't be needed? Or would you still recommend learning Core from the get go (or not at all!)
<flux> actually I haven't used Core much at all but instead prefer smaller additional libraries, such as containers. bonus: companion_cube is here for your immediate complaints :P
<flux> my understanding is though that Core is fine.
<antaoiseach> :D
<antaoiseach> flux: Hmmm ... interesting! Yeah, I would rather learn only as much as needed to get going with the domain .... so I suppose I will start with vanilla OCaml and see if I can use some data strucrtures etc (if needed) like you mentioned
<antaoiseach> (from Core that is)
<flux> I must admit I use containers even for simple tasks, such as "write this string to a file" which I find too annoying in the standard library. I mean, the primitives are fine, but containers comes with a nice with_out function that handles closing and exceptions etc
<flux> so I'm assuming Core has all that stuff as well
<antaoiseach> flux: Aha
<antaoiseach> Okay, just to make sure, the containers you refer to - they're part of the OCaml stdlib, or from some central registry?
<flux> I guess the name isn't super-descriptive due to scope creep..
<flux> though perhaps most of the stuff there is about data structures
<flux> ..except CCIO and the containers-thread module
<antaoiseach> flux: Oh wow, that looks quite nice and small ... I'll definitely have a look at it, could prove quite useful for me.
<flux> ..and CCUnix, hadn't noticed that earlier
<antaoiseach> Btw, I'm planning to learn OCaml from three resources (for now) - OCaml from the very beginning, More Ocaml, and the official docs ... good enough?
<antaoiseach> I feel like I should be able to pick up the basics quick enough, but the higher-level concepts might be trickier ... for instance, I seem to have read somewhere that a functor in OCaml is not quite the same as a functor in Haskell?
<antaoiseach> Btw that pl zoo resource seems quite nice. I could use the sample grammars for practice. Thanks again for sharing it! :-)
<mipri> https://dev.realworldocaml.org/functors.html - AIUI you'd use them where might want a typeclass.
<octachron> functors in haskell/OCaml/C++ only share a name and nothing more.
<flux> antaoiseach: btw, how familiar are you with writing ocaml?
<hannes> since 4.11 ships with a statistical memory profiler, is there published tooling for analysing the output thereof (I remember there was an emacs UI for an earlier version, but that has not received any updates for the new version (yet?))?
<hannes> and does the new statmemprof take bigarray allocations into account as well?
<d_bot> <mseri> @antaoiseach those are three good resources. I agree with @Flux that containers is a good choice: it is small and designed as an extension of Stdlib instead of a replacement (like Base is)
mbuf has joined #ocaml
<antaoiseach> mipri: flux: sorry, was away! :-) ... thanks for the link, will have a look at it... and hmmm, okay, that makes some sort of sense to me about considering functors as kind of like typeclasses
<antaoiseach> flux: Not too familiar - just had a look at some sample code, but it looks very readable - the familiar ADTs, and pattern matching
OptimusMKD has joined #ocaml
<antaoiseach> the `rec` part seems a bit weird, but maybe I don't know enough about OCaml ... maybe it is nice to have an explicit note about recursion
<flux> antaoiseach: oh by the way when you end up in the code generation phase, I propose you would consider using LLVM syntax, this way you get a wide array of tools available for you (also webasm)
<antaoiseach> flux: yes, exactly!
<flux> I recall there was an alternative to LLVM around as well, but I can't remember its name
<antaoiseach> I'm keen on that, especially since most compiler resources seem to focus on generating three-address code which is nice, but impractical for a real compiler. LLVM is definitely my target
<flux> there were some quality-of-life improvements there, but probably not quite as featureful
<antaoiseach> I'm hoping there are some nice libraries for llvm integ (the kaleidoscope tutorial on llvm.org seems to suggest that it's easy, will have to work through that!)
<antaoiseach> https://llvm.org/docs/tutorial/OCamlLangImpl1.html is what I'm referring to, just for reference
Haudegen has joined #ocaml
<antaoiseach> flux: Thanks for all the help, mate! Really appreciate it ... also thanks for mipri ... got to go now, but will be back. Cheers! :-)
antaoiseach has quit [Quit: leaving]
<flux> good luck with your endeavours :)
jnavila has joined #ocaml
g0d_shatter has quit [Quit: Leaving]
ldbeth has joined #ocaml
<ldbeth> I have a function that does some side effect then return a function
<ldbeth> now i only want the side effect and ignore the returned function using let _ =
<ldbeth> and ocaml complains "Error (warning 5): this function application is partial,
<ldbeth> maybe some arguments are missing."
<ldbeth> how can I get rid of this without turning off partial application check globally
<ldbeth> ok seems I can use `let tmp = f a b in ingore tmp` to do that
<d_bot> <glennsl> @ldbeth: You should annotate the type instead: `let _: unit -> unit = f a b`
<Fardale> You can disable warning locally but I don't remember the syntax for this
<d_bot> <glennsl> There's a good reason this warning exists, and using `ignore` to silecne it stills sets you up for failure if for example you add another argument to the end of `f`
<d_bot> <glennsl> Then the side effect just won't happen, without any warning
<d_bot> <glennsl> If you annotate the type you'll get an error because the type has changed.
<d_bot> <glennsl> Although this does also seem like a bad API and that this problem ought to be fixed at a higher level.
webshinra has quit [Remote host closed the connection]
<ldbeth> glennsl: ah, thank you
webshinra has joined #ocaml
waleee-cl has joined #ocaml
<ldbeth> is it good to disable "(warning 34): unused type "?
<d_bot> <Et7f3> dead code should be removed or will your code a feature can be ignored
<ldbeth> it is a module to be opened inside other modules
<ldbeth> maybe I should use include instead?
reynir has quit [Ping timeout: 240 seconds]
reynir has joined #ocaml
<octachron> unused type means that the type is not exposed in the public interface.
ldbeth` has joined #ocaml
<ldbeth`> but the type it complains are inside a module signature
<ldbeth`> which is supposed to be used in other signature files
ldbeth has quit [Ping timeout: 260 seconds]
mbuf has quit [Quit: Leaving]
ldbeth`` has joined #ocaml
ldbeth` has quit [Ping timeout: 240 seconds]
inkbottle has quit [Quit: Konversation terminated!]
inkbottle has joined #ocaml
osa1 has quit [Ping timeout: 264 seconds]
malc_ has joined #ocaml
Haudegen has quit [Ping timeout: 258 seconds]
<d_bot> <mseri> Then maybe it is redefined twice
Haudegen has joined #ocaml
ldbeth`` has quit [Quit: ERC (IRC client for Emacs 26.3)]
rig0rmortis has joined #ocaml
Haudegen has quit [Ping timeout: 264 seconds]
_whitelogger has joined #ocaml
borne_ has joined #ocaml
Haudegen has joined #ocaml
rig0rmortis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ggole has joined #ocaml
ransom has joined #ocaml
Niamkik has quit [Ping timeout: 264 seconds]
Niamkik has joined #ocaml
rig0rmortis has joined #ocaml
rig0rmortis has quit [Client Quit]
Haudegen has quit [Ping timeout: 256 seconds]
ransom has quit [Ping timeout: 240 seconds]
sonologico has quit [Remote host closed the connection]
borne_ has quit [Ping timeout: 260 seconds]
mbuf has joined #ocaml
ransom has joined #ocaml
tane has joined #ocaml
sonologico has joined #ocaml
kleisli has joined #ocaml
ransom has quit [Ping timeout: 240 seconds]
osa1 has joined #ocaml
zeeno has joined #ocaml
brown121407 has joined #ocaml
worc3131 has joined #ocaml
ransom has joined #ocaml
ransom has quit [Client Quit]
Niamkik has quit [Ping timeout: 260 seconds]
<zeeno> Hi, I've a question about mutual recursion. If OCaml did not read definitions sequentially, would it need the `and` keyword to type check mutually recursive functions? Am I right in assuming that it exists because the type checker doesn't do any sort of dependency analysis?
<mipri> there are other ways to do mutual recursion, but taking definitions in order doesn't just mean you don't have to do some more work, it affects the language. for a trivial example consider: let x = 1; let x = 2;
<zeeno> mipri: Makes sense. But there's nothing inherent in the type system that requires the user to tell the compiler "hey, these definitions all are mutually recursive." Right?
worc3131 has quit [Ping timeout: 272 seconds]
<mipri> AFAIK no. It's just a consequence of choosing linear rather than orderless bindings
<zeeno> mipri: Thank you!
zeeno has quit [Remote host closed the connection]
mbuf has quit [Quit: Leaving]
ransom has joined #ocaml
amiloradovsky has joined #ocaml
Niamkik has joined #ocaml
worc3131 has joined #ocaml
brown121407 has quit [Remote host closed the connection]
brown121407 has joined #ocaml
narimiran has joined #ocaml
brown121407 has quit [Remote host closed the connection]
brown121407 has joined #ocaml
<d_bot> <Et7f3> Hy z no I see you on reason discord 🤓 maybe you want to say hi to yourself from ocaml discord
osa1 has quit [Ping timeout: 264 seconds]
rig0rmortis has joined #ocaml
kleisli has quit [Ping timeout: 244 seconds]
jbrown has quit [Remote host closed the connection]
narimiran has quit [Ping timeout: 258 seconds]
jnavila has quit [Quit: Konversation terminated!]
Haudegen has joined #ocaml
kleisli has joined #ocaml
Haudegen has quit [Read error: Connection reset by peer]
Jesin has quit [Quit: Leaving]
Haudegen has joined #ocaml
Jesin has joined #ocaml
ggole has quit [Quit: Leaving]
rig0rmortis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
amiloradovsky has quit [Ping timeout: 260 seconds]
reynir has quit [Ping timeout: 264 seconds]
reynir has joined #ocaml
Tuplanolla has quit [Ping timeout: 240 seconds]
oriba has joined #ocaml
tane has quit [Quit: Leaving]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
rig0rmortis has joined #ocaml
amiloradovsky has joined #ocaml