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)
<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>
<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]
<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]