companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.11 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.11/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
mxns has joined #ocaml
mfp has quit [Ping timeout: 240 seconds]
Tuplanolla has quit [Quit: Leaving.]
mxns has quit [Ping timeout: 252 seconds]
Haudegen has quit [Ping timeout: 240 seconds]
curtosis[away] has joined #ocaml
sagax has joined #ocaml
osa1_ has joined #ocaml
osa1 has quit [Ping timeout: 265 seconds]
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
osa1_ has quit [Ping timeout: 268 seconds]
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
waleee-cl has quit [Quit: Connection closed for inactivity]
c4rc4s has joined #ocaml
mxns has joined #ocaml
gopiandcode has joined #ocaml
vicfred has quit [Quit: Leaving]
curtosis[away] has joined #ocaml
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
mxns has quit [Ping timeout: 250 seconds]
vicfred has joined #ocaml
hackinghorn has quit [Quit: Leaving]
mbuf has joined #ocaml
curtosis has joined #ocaml
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
MavneetK has joined #ocaml
MavneetK has quit [Quit: Connection closed]
osa1 has joined #ocaml
shawnw has joined #ocaml
shawnw has quit [Remote host closed the connection]
gopiandcode has quit [Remote host closed the connection]
shawnw has joined #ocaml
Serpent7776 has joined #ocaml
Tuplanolla has joined #ocaml
vicfred has quit [Quit: Leaving]
narimiran has joined #ocaml
White_Flame has quit [Ping timeout: 265 seconds]
White_Flame has joined #ocaml
OPeritel_ has quit [Ping timeout: 240 seconds]
narimiran has quit [Quit: leaving]
arecaceae has quit [Remote host closed the connection]
arecaceae has joined #ocaml
mfp has joined #ocaml
Haudegen has joined #ocaml
zebrag has joined #ocaml
olle has joined #ocaml
olle has quit [Ping timeout: 252 seconds]
Sonakshi has joined #ocaml
bartholin has joined #ocaml
tane has joined #ocaml
bartholin has quit [Ping timeout: 252 seconds]
waleee-cl has joined #ocaml
bartholin has joined #ocaml
bartholin has quit [Ping timeout: 265 seconds]
Sonakshi has quit [Quit: Connection closed]
shawnw has quit [Ping timeout: 252 seconds]
bartholin has joined #ocaml
ec is now known as ELLIOTTCABLE
olle has joined #ocaml
<olle> Halp
<olle> Wait, I shouldn't double post
<companion_cube> why not produce an AST
<companion_cube> instead of a string, I guess
<olle> companion_cube: for C?
<companion_cube> sure
yashi_vijay has joined #ocaml
<companion_cube> doesn't have to be a full AST, just a printable thing
<olle> Would it gain anything?
<olle> Compared to having a queue of lines I can push to
yashi_vijay has quit [Client Quit]
<dh`> olle: don't understand your question
<companion_cube> well you gain the ability to manipulate it however you want
<companion_cube> instead of having, well… lines of text? :/
<olle> hm hm
<dh`> oh
<dh`> you're writing a compiler to C and you're trying to output C text directly? don't do that (tm)
<olle> dh`: I need a reason too :D
<olle> I guess the C AST could have a tag called "Need struct alloc before"
<companion_cube> or you could look inside to see if it's a struct
<olle> Possibly... It gets more complex when doing stuff like: `local points = [new Point {1, 2}, new Point {2, 3}];` and they're all supposed to be stack allocated.
<olle> The "local" keyword should propagate the locality
<dh`> one of these days I should post my general recommendations for compiler writers somewhere
<dh`> anyway olle... what you're doing is a transformation on your code
<olle> dh`: There should be like a book...
<dh`> do the transformation in a representation that can represent it
<companion_cube> :D
<companion_cube> makes sense!
<dh`> that is, if you have local points = [new Point {1, 2}]
<dh`> what you want is to transform that into something like local _p = new Point {1, 2}; local points = [p]
<olle> Sure
<dh`> depending on what your syntax actually means
<olle> Oh
<dh`> do that first, transform it to C in a later pass
<olle> Yes, that was my first idea, I wrote it one thread.
<olle> A first pass to extend syntactic sugar
<olle> A second pass to spit out C
<dh`> yes
<dh`> real compilers usually have considerably more than two passes
<dh`> there's a reason for this
<olle> :d
<olle> dh`: Maybe you can add your idea to the forum?
<dh`> I assume I have to sign up to post
<olle> Oh
<olle> Yeah
<olle> Or just link with github
<dh`> so I need to sign up to post
<dh`> :-)
<olle> Or you have a link about multiple passes in compilers? Then I can post it.
<dh`> not a useful one
<dh`> (I'm sure there is one somewhere, but often it's hard to find decent canonical references for standard practices)
bartholin has quit [Read error: Connection reset by peer]
<dh`> anyway the first thing to choose is not how many passes you want but how many representations you want
<olle> 1
<dh`> more representations -> less goop in each pass but more fixed overhead
<dh`> it's a mistake to not have at least two (one for source language, one for target language)
<dh`> and in general you'll want a third for the concrete syntax of your source language, and depending on what you're doing an additional intermediate representation may be helpful
<olle> Meh
<dh`> I wrote a compiler with 10 once but that was overkill
<dh`> anyway if the target language is higher-level than assembly you'll probably want the final representation to be a tree of strings that you can generate semi-legible formatted output from
<companion_cube> there's "nanopass" if you go further
<dh`> because you'll need to read the output when debugging
<olle> hm
<olle> what's nanopass?
<companion_cube> a framwork for compilers with many passes
<olle> ok
<companion_cube> I think chez scheme uses that
bartholin has joined #ocaml
<dh`> seems to be racket stuff
<companion_cube> seems to be a scheme thing
<companion_cube> among other reasons, because they use macros to generate each intermediate AST
<dh`> that seems ... error-prone
<dh`> I feel like someone should figure out a useful system for parameterized variant ADTs
<companion_cube> erf, yes
<companion_cube> sounds tough
<dh`> not sure it really is, in a sense it ends up just being two layers of ADT
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
Haudegen has joined #ocaml
<olle> I'm really looking for the minimal effort for a proof-of-concept
<olle> Maybe I should just hire someone...
<olle> dh`: what's your hourly rate? xD
bartholin has quit [Ping timeout: 260 seconds]
bartholin has joined #ocaml
olle has quit [Ping timeout: 260 seconds]
vicfred has joined #ocaml
<d_bot> <darrenldl> reads like you can propagate the information in passes if you in some way allow for an intermediate representation or if the original ast can be further annotated
<dh`> olle: probably too high :-)
<dh`> (though if you're serious I might actually do it, in the middle of looking for jobs)
<dh`> oh well, they left
mbuf has quit [Quit: Leaving]
<d_bot> <EduardoRFS> Does merlin read CMT files?
<companion_cube> I think it does, yes
<d_bot> <EduardoRFS> do you know if it is only for the file that it is inspecting or it is also for external files?
<companion_cube> it's used for the other files
<companion_cube> merlin reads and types the current file/buffer directly
<d_bot> <EduardoRFS> grr
bartholin has quit [Ping timeout: 240 seconds]
oriba has joined #ocaml
bartholin has joined #ocaml
<oriba> This weekend I read a lot of the language extension chapters in the refman. My gial was understanding GADTs, but some other topics were also interesting. But my understanding of localy abstract types and GADTs is incomplete.
<oriba> somehow I unbderstand what the "localy abstract types" part plays in GADTs
<oriba> But I don't undrstand what the locally abstract types are useful for without GADTs.
<oriba> the '(type t)' is the part that says, what is locally abstract
<oriba> but where is that type abstract? In the expression that follows?
<oriba> and why to do that?
<oriba> or is '(type t) not the abstract type but the concrete one?
<oriba> looking for examples that make sense to me.
<d_bot> <mnxn> I'm not the most knowledgeable about this topic, but I know it's useful in situations like these:
<d_bot> <mnxn> ```ocaml
<d_bot> <mnxn> # let one : 'a list = [1];;
<d_bot> <mnxn> val one : int list = [1]
<d_bot> <mnxn>
<d_bot> <mnxn> # let two (type a) : a list = [2];;
<d_bot> <mnxn> Error: This expression has type int but an expression was expected of type a
<d_bot> <mnxn>
<d_bot> <mnxn> # let three (type a) : a list = [];;
<d_bot> <mnxn> val three : 'a list = []
<d_bot> <mnxn> ```
<dh`> ocaml gadts are kinda shoehorned in; my recommendation would be to go learn them in e.g. coq where they're natural and then you can figure out how to read the ocaml syntax
worc3131 has joined #ocaml
worc3131 has quit [Ping timeout: 252 seconds]
<oriba> d_bot: let four = [];; (* also gives 'a list = [] *)
<oriba> so I don't see an advantage of the locally abstract type notation added.
<dh`> the point of gadts is you can do things like index your expression types with the type they return so you can't construct ill-typed expressions
<dh`> (note: I don't actually recommend doing this in a compiler or interpreter)
<dh`> e.g. type _ expr = IntConst: int -> int expr | BoolConst: bool -> bool expr | Add: 'a expr * 'a expr -> 'a expr
bartholin has quit [Quit: Leaving]
curtosis[away] has joined #ocaml
tane has quit [Quit: Leaving]
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
Tardigreat[m] has joined #ocaml
astronavt has joined #ocaml
curtosis has joined #ocaml
<d_bot> <mnxn> oriba: I was trying to show that with locally abstract types the compiler won't let you use a less general type by accident
<d_bot> <mnxn> in one, the type variable 'a gets replaced with int, but for two/three, it must be a polymorphic type or you get an error
<d_bot> <mnxn> probably more useful for annotating a function's type
<d_bot> <mnxn> especially if you're working with phantom types
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
lindah has joined #ocaml
lindah has quit [Quit: Connection closed]
curtosis has joined #ocaml
Haudegen has quit [Ping timeout: 240 seconds]
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
bjorkintosh has quit [Ping timeout: 258 seconds]