companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.14.0 released: https://ocaml.org/releases/4.14.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 245 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 268 seconds]
<John_Ivan> So I'm gonna try to ask my questions as simple as possible; I don't aim to get a perfect answer, instead, I aim to get a general one.
<John_Ivan> Between Monads, Functors, Zippers and Variants, which is for generic programming?
<John_Ivan> inb4 "Yes." as the answer.
<John_Ivan> :)
<d_bot> <NULL> At the most simple level, "generic programming" (what I presume is ~polymorphism) is the `'a` in a function type, which the compiler does on its own.
<d_bot> <NULL> Functors allow for more (higher) polymorphism. Monads are a particular structure which has some operations, but is still quite generic in nature
<d_bot> <NULL> Variants are a building block of data structures and Zippers a transformation of ADTs to traverse them.
<d_bot> <NULL> That's how I understand it at least, I don't know everything there is to know about those big words you brought
rgrinberg has joined #ocaml
<John_Ivan> I'm trying really hard to separate out what is what so I appreciate the opinion.
<d_bot> <NULL> It isn't really an opinion, more of a partially informed summary
sonologico has joined #ocaml
<John_Ivan> NULL: I'm trying to figure out what is a new concept altogether and what is a mimic of an existing concept.
<John_Ivan> NULL: as well as what is a design pattern and what is actual code.
<d_bot> <NULL> Functors are OCaml structures, monads are a theoretical structure with some syntactic-sugar, variants are OCaml structures and zippers (the ones I know least) are a theoretical derivation you do on types (so the result can be programmed)
<d_bot> <NULL> some syntactic sugar for the usage*
<John_Ivan> NULL: no wonder I'm confused. everything is the same thing.
<John_Ivan> :D
sonologico has quit [Ping timeout: 252 seconds]
<d_bot> <NULL> ? No they're not
<John_Ivan> well, ok. maybe they aren't but I have a very different way of how I think of programming.
<d_bot> <NULL> When I say "OCaml structire", I only mean "something you can define in OCaml", this is still very vague
<d_bot> <NULL> structure*
<John_Ivan> it still falls under what I personally call "a declaration"
<John_Ivan> at least, that's how I see things.
<John_Ivan> so type or structure - a declaration.
<John_Ivan> NULL: in short, in my eyes, OCaml classes, objects, monads, functors, and variants are all "declaration oriented" entities.
<John_Ivan> if what you said so far matches correctly.
<d_bot> <NULL> That is true, but a bit too simplified from my point of view
<John_Ivan> agreed. but I'm a slow learner so baby steps are fine with me.
<John_Ivan> so simplified as it may be, it's something to give me an indication of where to go next. thank you.
<d_bot> <NULL> On that note, are you learning all those concepts at the same time ? They are definitely not the same level of complexity, so if you do I don't think it's a good idea to put them on the same plane
<John_Ivan> NULL: Not a the same time no. I'm segmenting the whole language in parts which are "code, design pattern, syntax, declarations and executable code"
<John_Ivan> vague terms I know, but right now, I'm looking at everything from a high level point of view
<John_Ivan> I'll drill down in each element slowly in time
<d_bot> <NULL> I get it, seems quite fair to me
<d_bot> <NULL> What difference do you make between code, syntax and declarations (I fail to see more than 2 distinct categories)
<John_Ivan> syntax counts as symbols, keywords, naming convention and whitespace
<John_Ivan> declarations are, well, "static" entities that only structure out a system from a **data** point of view.
<John_Ivan> executable code are expressions and functions
<John_Ivan> as well as methods
<John_Ivan> and design pattern is, well, an approach to how to lay the above out.
<d_bot> <NULL> Okay, syntax is way smaller a topic than the other two then
<John_Ivan> maybe. I have a whole page of symbols though
<John_Ivan> and keywords
<d_bot> <NULL> Also, functions and expressions are basically the same in OCaml, and methods are often ignored (as well as the whole OO part)
<John_Ivan> hmm. I see
<d_bot> <NULL> (Are there than many symbols and keywords ?)
<d_bot> <NULL> (I guess that since I don't count `class`, `object`, `method` and all the OO symbols, that's a good chink less than you)
<d_bot> <NULL> chunk*
motherfsck has joined #ocaml
<John_Ivan> let, in, and, begin...end, method, val, with, where?, rec, fun, function, true, false, None, Nothing, for..to...done, while...end, ( ), sig, type, class, object
<John_Ivan> open. module
<John_Ivan> I think "struct" is also another.
<John_Ivan> as for symbols
<John_Ivan> -> <- :: ; ;; ~ ' : @@ $ (:) [||] .() # + / * - <> and the floating point variants.
<John_Ivan> I'm pretty sure there are others. I always keep finding new ones...
<d_bot> <hockletock> != isn't in that list
<John_Ivan> I assume <> is what the negation is?
<John_Ivan> not equal to*
<d_bot> <NULL> Of those, I'd only remember `let (and) in ;` `begin end ( )` `rec fun function` `{ } with` `match with |` `type module struct end sig end`
<d_bot> <hockletock> <> is uhh structural inequality
<John_Ivan> oh yeah. I forgot "|" and "match"
<d_bot> <hockletock> != is identity inequality
<d_bot> <hockletock> there's some other name for it
<John_Ivan> and I forgot the number separator "_"
<John_Ivan> 10_000_000
<d_bot> <hockletock> well _ has actual syntactical meaning when matching
<d_bot> <hockletock> it matches any value
<John_Ivan> ah yeah. that too.
motherfsck has quit [Ping timeout: 252 seconds]
<John_Ivan> I recall that from Haskell
<d_bot> <NULL> And for values and standard functions in symbols, `true false` `Some None` `= <>` [arithmetic, ints] `[] (::) [ ; ; ]` `[| ; ; |] .() .()<-` `"" .[]`
<d_bot> <NULL> (+ `val` for mlis)
* John_Ivan commits suicide
<John_Ivan> ok. baby steps John. baby steps.
<d_bot> <NULL> That's like 2/3 of your list, the rest is not useful for quite a while when you start
<d_bot> <hockletock> what is `.()<-` distinct from its parts?
<John_Ivan> wondeful
<d_bot> <NULL> `<-` never exists on its own; it's either a field being overwritten or a cell, the function to write in a cell would be named `( .()<- )` if it were possible to overwrite it someday
<d_bot> <NULL> (cf. `(.%()<- )` https://v2.ocaml.org/manual/indexops.html)
<d_bot> <hockletock> oh and ~- and ~-. because a language that can tell you you forgot a single case in a complicated match can decide if you meant foo (-10) or to subtract 10 from a function without extra help, for some reason
<d_bot> <hockletock> can't*
<d_bot> <NULL> I mean, you can use `-` for unary substraction
<d_bot> <NULL> It's just that the underlying functions can't have the same name, so unary substraction is internally (and externamly f you want to override it) named `(~-)`
<d_bot> <NULL> externally*
<John_Ivan> so my whole goal in ocaml is to write everything to be as stateless as possible
<d_bot> <hockletock> let foo x = print_int x;; foo -10 gives an error because it is looking for an int on its left hand side
<John_Ivan> and put away the state driven stuff tucked away in a nice fashion and as separate as possible from the rest.
<d_bot> <NULL> `foo (-10)`
sonologico has joined #ocaml
<d_bot> <NULL> Sure, `foo ~-10` doesn't need parentheses because ~- has a higher priority, but I'll use the former everyday for its clarity
<d_bot> <hockletock> John_Ivan: Ocaml is extremely pragmatic and lets you put state where you need it and avoid it where you don't
<John_Ivan> I see.
<d_bot> <hockletock> for instance the Graph library (not part of stdlib) has both persistent and imperative graphs, imperative graphs have state where that can help performance greatly
sonologico has quit [Ping timeout: 245 seconds]
motherfsck has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
chrisz has quit [Ping timeout: 240 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chrisz has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 245 seconds]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
rgrinberg has joined #ocaml
azimut has joined #ocaml
John_Ivan has quit [Ping timeout: 252 seconds]
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 268 seconds]
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 268 seconds]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
Sankalp- has joined #ocaml
Sankalp has quit [Ping timeout: 245 seconds]
Sankalp- is now known as Sankalp
zebrag has quit [Quit: Konversation terminated!]
azimut_ has joined #ocaml
azimut has quit [Ping timeout: 268 seconds]
sonologico has joined #ocaml
williewillus_ has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sonologico has quit [Ping timeout: 268 seconds]
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 252 seconds]
motherfsck has quit [Quit: quit]
Techcable has quit [Remote host closed the connection]
Techcable has joined #ocaml
sonologico has joined #ocaml
Techcable has quit [Remote host closed the connection]
Techcable has joined #ocaml
sonologico has quit [Ping timeout: 245 seconds]
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 252 seconds]
williewillus_ is now known as williewillus
John_Ivan has joined #ocaml
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 252 seconds]
trev has joined #ocaml
sonologico has joined #ocaml
Haudegen has joined #ocaml
sonologico has quit [Ping timeout: 245 seconds]
Serpent7776 has joined #ocaml
octachron has quit [Quit: ZNC 1.8.2 - https://znc.in]
reynir has joined #ocaml
octachron has joined #ocaml
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 252 seconds]
Tuplanolla has joined #ocaml
chrisz has quit [Ping timeout: 268 seconds]
olle has joined #ocaml
chrisz has joined #ocaml
olle has quit [Ping timeout: 245 seconds]
Serpent7776 has quit [Ping timeout: 244 seconds]
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 245 seconds]
williewillus has quit [Quit: Leaving]
neiluj has joined #ocaml
<neiluj> Hi! Is it possible to open a module for a type definition? like so type t = Module.{ a: SubModule1.t; b: SubModule2.t }
sonologico has joined #ocaml
dextaa has quit [Ping timeout: 252 seconds]
sonologico has quit [Ping timeout: 252 seconds]
<octachron> No, this is not supported.
Tuplanolla has quit [Ping timeout: 245 seconds]
<d_bot> <denis631> Hey everybody,
<d_bot> <denis631> I am trying to do parsing and bindings (string → ValuableType conversion) in `parser.mly` file which I declare with mehnir.
<d_bot> <denis631> The problem is that in order to do the binding in `parser.mly` file I would need to pass some extra data/context, so it can perform the mapping.
<d_bot> <denis631> Does anybody know how to do it?
<d_bot> <denis631>
<d_bot> <denis631> I tried to declare some `ref`s in the `%{ … }` block in `parser.mly` file, however, it is not visible outside of the module and hence can not be passed.
<d_bot> <denis631> Is there a way to bypass this issue or what I am doing is hacky and shouldn’t be done in the first place.
<d_bot> <denis631>
<d_bot> <denis631> I just feel lazy declaring similar ADT, just with some other types for the leaf nodes, which will change due to binding
<neiluj> thanks octachron
Tuplanolla has joined #ocaml
sonologico has joined #ocaml
sonologico has quit [Ping timeout: 252 seconds]
<d_bot> <darrenldl> @denis631 what is ValuableType?
<d_bot> <darrenldl> but handling binding in a separate pass might be easiest
olle has joined #ocaml
azimut_ has quit [Remote host closed the connection]
azimut has joined #ocaml
mbuf has joined #ocaml
<neiluj> hey! is this a cast (x :> int)?
<neiluj> the :> operator
<mclovin> it's a coercion
<neiluj> so that allow to "cast" private types to an other one?
<mclovin> yes but it can be used in other cases
<mclovin> it's used to coerce a value v from t to t' with t being a subtype of t'
<mclovin> the main use case is polymorphic variant I would say
<neiluj> oh nice!
<neiluj> in case the type is a record, this fills the other fields with default values?
<mclovin> I don't think it works with records
<neiluj> this also converts in the other direction: from a type to a subtype?
<d_bot> <darrenldl> that would not be well defined(?)
<neiluj> indeed
wingsorc__ has quit [Ping timeout: 240 seconds]
omegatron has joined #ocaml
<olle> How would you do lazi init of record fields in OCaml?
<olle> Possible while still immutable? Or must be mut?
gopiandcode has quit [Quit: WeeChat 3.0]
Serpent7776 has joined #ocaml
bartholin has joined #ocaml
Anarchos has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
<Anarchos> hello
adanwan has quit [Remote host closed the connection]
azimut has quit [Remote host closed the connection]
adanwan has joined #ocaml
azimut has joined #ocaml
waleee has joined #ocaml
kakadu_ has joined #ocaml
kakadu has quit [Ping timeout: 252 seconds]
hasbae has joined #ocaml
Haudegen has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
John_Ivan has quit [Read error: Connection reset by peer]
John_Ivan has joined #ocaml
trev has quit [Remote host closed the connection]
jtm has quit [Ping timeout: 272 seconds]
motherfsck has joined #ocaml
xgqt has quit [Read error: Connection reset by peer]
xgqt has joined #ocaml
zebrag has joined #ocaml
<olle> There's a `lazy` keyword? o0
sonologico has joined #ocaml
<companion_cube> Err, yes? :D
<olle> companion_cube: When did that happen??
<companion_cube> 1990, roughly, i think ?
<olle> Wat the
<olle> So 10 years ago...
<companion_cube> Now to blow your mind: it also exists in pattern position
<companion_cube> Not to sadden you but 1990 was 30 years ago
<olle> :(
<olle> Sad
<olle> companion_cube: So you can Lazy.force in pattern match?
<companion_cube> Yep
<companion_cube> And match inside the forced value in the same stroke
<companion_cube> Pattern matching in ocaml is pretty amazing
<olle> That's cool
<olle> Also here
sonologico has quit [Ping timeout: 252 seconds]
Serpent7776 has quit [Quit: WeeChat 1.9.1]
williewillus_ has joined #ocaml
rgrinberg has joined #ocaml
williewillus_ is now known as williewillus
Haudegen has quit [Quit: Bin weg.]
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
williewillus has quit [Quit: Leaving]
Serpent7776 has joined #ocaml
mbuf has quit [Quit: Leaving]
<olle> Maybe I should write a php_of_ocaml pipeline.......
jtm has joined #ocaml
<Anarchos> what is the best protocol to communicate between a gui and a server ? I see that coq/coqide use a XML protocol.
<olle> JSON, in my opinion
<olle> XML is bloated piece of crap
<olle> Armael: Oooooh :O
<companion_cube> Cbor or protobuf!
<olle> ?
<olle> hm
<companion_cube> If you want to avoid bloat :p
olle has quit [Remote host closed the connection]
<Anarchos> companion_cube is there an opam package for protobuf ?
<d_bot> <Anurag> Anarchos: There are multiple. https://github.com/mransan/ocaml-protoc if you want a pure OCaml library that doesn't depend on the protobuf compiler. https://github.com/issuu/ocaml-protoc-plugin if you want a plugin for the official protobuf compiler.
<companion_cube> sure, there's protoc, ppx_deriving_protobuf, and others
<companion_cube> `opam search protobuf` and off you go
Haudegen has joined #ocaml
<Anarchos> there is a protobuf package but with no documentation
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bartholin has quit [Quit: Leaving]
rgrinberg has joined #ocaml
Haudegen has quit [Read error: Connection reset by peer]
olle has joined #ocaml
Haudegen has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
<d_bot> <Bluddy> what is the current state of the art in persistent data structures?
<companion_cube> I know that the Deque world is crazy (cc Armael btw ;)), and for vector/map I think HAMT/RRB trees are more or less the current best
dh` has quit [Quit: bbiab]
<companion_cube> i.e. they're reasonably close to a functional hashmap
Haudegen has quit [Ping timeout: 252 seconds]
<Anarchos> i hesitate to transform my list into a zipper list or in a graph....
Haudegen has joined #ocaml
dh` has joined #ocaml
neiluj has quit [Quit: Leaving]
sonologico has joined #ocaml
azimut has quit [Ping timeout: 268 seconds]
dh` has quit [Quit: brb again]
sonologico has quit [Ping timeout: 252 seconds]
dextaa has joined #ocaml
dh` has joined #ocaml
dh` has quit [Ping timeout: 252 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sonologico has joined #ocaml
<Anarchos> how can i build the ocaml runtime/unix lib with debug flags, to be able to debug them with gdb ?
gwizon has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Tuplanolla has quit [Quit: Leaving.]
sonologico has quit [Ping timeout: 245 seconds]
sonologico has joined #ocaml
rgrinberg has joined #ocaml
dh` has joined #ocaml
dh` has quit [Client Quit]
dh` has joined #ocaml
olle has quit [Ping timeout: 268 seconds]
sonologico has quit [Ping timeout: 268 seconds]
sonologico has joined #ocaml
wingsorc__ has joined #ocaml
sonologico has quit [Ping timeout: 245 seconds]
gwizon has quit [Quit: Lost terminal]
olle has joined #ocaml
<d_bot> <Et7f3 (@me on reply)> ./configure CFGLAGS='-ggdb'; make; make install
Haudegen has quit [Ping timeout: 245 seconds]
olle has quit [Ping timeout: 245 seconds]