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
jbrown has quit [Ping timeout: 246 seconds]
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
ollehar has quit [Ping timeout: 258 seconds]
ollehar has joined #ocaml
sagax has quit [Ping timeout: 240 seconds]
<d_bot> <cironunes> anyone doing neo4j with ocaml/reason?
Haudegen has quit [Ping timeout: 246 seconds]
mfp has quit [Ping timeout: 260 seconds]
spew has quit [Quit: Connection closed for inactivity]
osa1 has joined #ocaml
osa1 has quit [Quit: osa1]
osa1 has joined #ocaml
aaaaaa has joined #ocaml
osa1_ has joined #ocaml
osa1 has quit [Ping timeout: 240 seconds]
osa1_ has quit [Ping timeout: 260 seconds]
govg has quit [Ping timeout: 256 seconds]
mjs22 has joined #ocaml
mjs22 has quit [Quit: Leaving]
ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
narimiran has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #ocaml
vicfred has quit [Quit: Leaving]
Tuplanolla has joined #ocaml
osa1 has joined #ocaml
gahr_ has joined #ocaml
gahr has quit [Read error: Connection reset by peer]
cbarrett has quit [Ping timeout: 240 seconds]
aecepoglu[m] has quit [Ping timeout: 244 seconds]
adrianbrink has quit [Ping timeout: 244 seconds]
lnxw37d4 has quit [Ping timeout: 240 seconds]
rwmjones_ has joined #ocaml
adrianbrink has joined #ocaml
rwmjones has quit [Ping timeout: 240 seconds]
aecepoglu[m] has joined #ocaml
banjiewen has quit [Ping timeout: 244 seconds]
strmpnk has quit [Ping timeout: 244 seconds]
cbarrett has joined #ocaml
banjiewen has joined #ocaml
strmpnk has joined #ocaml
lnxw37d4 has joined #ocaml
peddie has quit [Ping timeout: 244 seconds]
peddie has joined #ocaml
osa1 has quit [Quit: osa1]
osa1 has joined #ocaml
<d_bot> <ostera> hey folks, how can I access the `Types.signature` of a module? Assuming I've got my hands on a `Typedtree.structure` (and its corresponding module coercion)
<d_bot> <ostera> currently `ocamlc -dtypedtree a.ml` does not show anything about the inferred signature of `A` 🤔
<d_bot> <ostera> for nested modules I've found a path through this type-chain:
<d_bot> <ostera>
<d_bot> <ostera> ```
<d_bot> <ostera> * Typedtree.structure
<d_bot> <ostera> * Typedtree.structure_item
<d_bot> <ostera> * Typedtree.structure_item_desc
<d_bot> <ostera> * Typedtree.module_binding
<d_bot> <ostera> * Typedtree.module_expr
<d_bot> <ostera> * Typedtree.module_type
<d_bot> <ostera> * Typedtree.signature
<d_bot> <ostera> * Typedtree.signature_item
<d_bot> <ostera> ```
<d_bot> <ostera> but looking at `Typedtree.structure` I see a `str_type: Types.signature` that seems to be an empty list 🤷
<d_bot> <ostera> for a module like:
<d_bot> <ostera>
<d_bot> <ostera> ```ocaml
<d_bot> <ostera> (* a.ml *)
<d_bot> <ostera> let id x = x
<d_bot> <ostera> ```
osa1 has quit [Quit: osa1]
govg has joined #ocaml
nullcone has quit [Quit: Connection closed for inactivity]
osa1 has joined #ocaml
<d_bot> <octachron> `-dtypedtree` is very partial
<d_bot> <ostera> neeevermind, `Printtyp.printed_signature` showed me the signature _is there_, so I must be traversing typedtree wrong 🤦‍♂️
osa1 has quit [Client Quit]
govg has quit [Ping timeout: 240 seconds]
govg has joined #ocaml
narimiran has quit [Ping timeout: 256 seconds]
jbrown has joined #ocaml
osa1 has joined #ocaml
abc_ has quit [Quit: reboot or OOMed]
osa1 has quit [Ping timeout: 244 seconds]
osa1_ has joined #ocaml
osa1_ has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
mfp has joined #ocaml
mbuf has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
raver has joined #ocaml
sonologico has joined #ocaml
reynir has quit [Ping timeout: 260 seconds]
reynir has joined #ocaml
bartholin has quit [Quit: Leaving]
Haudegen has joined #ocaml
narimiran has joined #ocaml
ggole has joined #ocaml
waleee-cl has joined #ocaml
brown121407 has joined #ocaml
aaaaaa has quit [Quit: leaving]
osa1 has joined #ocaml
rowbee has left #ocaml ["WeeChat 2.9"]
mbuf has quit [Quit: Leaving]
brown121408 has joined #ocaml
osa1_ has joined #ocaml
osa1 has quit [Ping timeout: 244 seconds]
brown121407 has quit [Ping timeout: 244 seconds]
sagax has joined #ocaml
osa1_ is now known as osa1
Haudegen has quit [Remote host closed the connection]
ldbeth has joined #ocaml
<ldbeth> hi
<ldbeth> for CamlP5, is `-1' considered `<:expr< $e1$ $e2$ >>' or `<:expr< $int:s$ >>'?
<ldbeth> it's that for some reason `-1' been treated as `(-) 1'
<d_bot> <ostera> @octachron you wouldn't happen to know how I can get my hands on Typedtree.signature coming from a .mli file _after_ the compilation of the .ml 🤔 ?
<d_bot> <ostera> e.g, you run `ocamlc` and it goes through `Compile_common.implementation`, and somewhere within the ~backend continuation I feel like I should be able to get my hands on typedtree for the _signature_ of the module I'm about to compile
<d_bot> <ostera> I mean, the typedtree of the module itself includes a signature but it is unconstrained, so "private" stuff is there but I have no way of knowing what is in fact private
<d_bot> <octachron> Then you need the typedtree of the mli file?
<octachron> See https://github.com/ocaml/ocaml/blob/trunk/typing/typemod.ml#L2657 for how the compiler is looking for the cmi file to get the signature when typing an implementation file
osa1 has quit [Ping timeout: 240 seconds]
osa1 has joined #ocaml
Yagotzirck has joined #ocaml
raver has quit [Quit: Gateway shutdown]
raver has joined #ocaml
osa1 has quit [Ping timeout: 240 seconds]
osa1 has joined #ocaml
Yagotzirck has quit [Quit: Leaving]
ldbeth has quit [Remote host closed the connection]
ldbeth has joined #ocaml
ldbeth has quit [Client Quit]
chewbranca has quit [Ping timeout: 272 seconds]
mjvoge02 has quit [Ping timeout: 272 seconds]
mjvoge02 has joined #ocaml
chewbranca has joined #ocaml
ed_ac has joined #ocaml
cemerick has quit [Ping timeout: 272 seconds]
Amaan has quit [Ping timeout: 258 seconds]
<d_bot> <ostera> perfect, just what I needed! 🙌 thanks
OptimusMKD has joined #ocaml
cemerick has joined #ocaml
Amaan has joined #ocaml
adrien has quit [Ping timeout: 246 seconds]
osa1_ has joined #ocaml
ed_ac has quit [Quit: leaving]
ransom has joined #ocaml
osa1_ has quit [Quit: osa1_]
osa1_ has joined #ocaml
ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <stab> any idea why ocaml system all of a sudden dissapeared from my opam available switches...
<d_bot> <Et7f3> update ?
<d_bot> <stab> yeah i tried updating
<d_bot> <stab> no luck
<d_bot> <Et7f3> you system package managed updated your ocaml package
<d_bot> <Et7f3> because ocaml-system=ocaml of your system
<d_bot> <stab> Uh sorry i guess im confused on the difference between ocaml-base-compiler and ocaml-system in opam. I thought ocaml system was the complete release with tools vs just the compiler
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
osa1_ has quit [Quit: osa1_]
<d_bot> <stab> weird i can create a switch with ocaml-system but it doesnt show up in the list available
<d_bot> <stab> im guessing my installation is broken somehow
osa1 has quit [Quit: osa1]
osa1 has joined #ocaml
brown121408 has quit [Read error: Connection reset by peer]
brown121407 has joined #ocaml
jnavila has joined #ocaml
brown121407 has quit [Remote host closed the connection]
Asmadeus has joined #ocaml
mcc has joined #ocaml
c4rc4s has quit [Ping timeout: 256 seconds]
c4rc4s has joined #ocaml
vicfred has joined #ocaml
ransom has joined #ocaml
Asmadeus has left #ocaml ["moo"]
osa1 has quit [Ping timeout: 244 seconds]
osa1_ has joined #ocaml
nullcone has joined #ocaml
<d_bot> <stab> I feel like working on a project that has a ton of FFI causes me to artificially dread developing in Ocaml lol. Like i hate ffi so much
<d_bot> <Drup> ocaml-system is the package that tries to use ocaml installed outside of opam, notably, your distribution
<d_bot> <Drup> it ... often doesn't work so well, avoid it
<d_bot> <stab> So just base compiler then?
<d_bot> <Et7f3> yup better
ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
osa1_ has quit [Quit: osa1_]
<ollehar> In Haskell you can split the definition of a type to multiple files, right?
<ollehar> And implement typeclasses separately.
<ollehar> (Yes)
<ollehar> (But not sure if it's idiomatic Haskell)
<waleee-cl> ollehar: "split" typeclass instances is idiomatic, but types & (type)class defintions is mostly in a single file afai-have-seen
rwmjones_ is now known as rwmjones
<ollehar> waleee-cl: yeah?
<ollehar> waleee-cl: So I can add `show T` in one file and `generate_sql_select T` in another?
narimiran has quit [Ping timeout: 260 seconds]
<waleee-cl> if you have all db stuff in the other file I don't see any problem with it
<ollehar> alright, good info
<ollehar> funny how this is not possible in OOP
<waleee-cl> but I guess the more correct advice is: it depends
<ollehar> mm
Guest86335 has quit [Ping timeout: 240 seconds]
<waleee-cl> ollehar: in C++ OOP it's possible
<ollehar> waleee-cl: liar!
<ollehar> (will google)
<waleee-cl> and rust
<d_bot> <stab> Ish except the crate restriction
<waleee-cl> @stab ah, right, forgot that.
<ollehar> waleee-cl: well, rust does the typeclass thingy, no?
<d_bot> <stab> Although it has a good reason for existing
<waleee-cl> ollehar: I guess it's a bit similar to typeclasses
<d_bot> <stab> I mean so like if you squint at both of them they are just adhoc polymorphism so like I guess traits are sorta typeclasses
<waleee-cl> does @NAME work as in other channels discord-bridges btw?
<ollehar> stab, it's not only about polymorphism, but how to add new behaviour to old data neatly.
snowpanda has joined #ocaml
jnavila has quit [Quit: Konversation terminated!]
ransom has joined #ocaml
dian has quit [Quit: WeeChat 1.9.1]
<d_bot> <stab> i mean the technical term for the behavior is adhoc polymorphism no?
<d_bot> <stab> @name should except there is the issue of getting the ID right which probably isnt possible from irc
<d_bot> <stab> cause it's name#id
ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
adrien has joined #ocaml
ransom has joined #ocaml
bartholin has joined #ocaml
<ollehar> So in both Haskell and Rust you can add new behaviour to old data without touching old code, but not in OCaml? Boooo.
<ollehar> Maybe a module should be possible to split in multiple files?
<d_bot> <Et7f3> @stab @waleee-cl if you make a space after discord is smart enough (or the bridge) to assign the right ping
<d_bot> <Et7f3> I was pinged once by a irc user
<d_bot> <stab> ollehar: im not sure I understand how typeclasses are about adding behavior and not polymorphism. LIke sure both traits and typeclasses can have instance functions but those functions can only leverage the declared behavior of the typeclass
<d_bot> <stab> Your definition of adding new behavior seems odd to me. Like I can add new behavior to a type in another module... just write a function that does something with that data. Seems to me the thing that traits, typeclasses, and modular implicits explicitely (pun) give you is adhoc polymorphism
ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ollehar> just write a function that does
<ollehar> something with that data.
<ollehar> nope, this breaks encapsulation
<ollehar> stab, you want BOTH encapsulation and adhoc blaha.
<ollehar> some behaviour requires knowledge about the internal structure of types, that's the use-case I mean.
reynir has quit [Ping timeout: 240 seconds]
<d_bot> <stab> How does this break encapsulation?
<d_bot> <stab> Your type presents an interface via ur mli
<d_bot> <stab> Encapsulated however you want
<d_bot> <stab> Then I write a function over your interface
reynir has joined #ocaml
<d_bot> <stab> Type classes don’t grant you magical insight into the types internal structure? Like if a type is abstract it’s abstract
<d_bot> <stab> If it’s not abstract then your encapsulation is broken
<ollehar> stab, imagine the interface "show" or "stringable", which turns a type into a string
<ollehar> maybe I want type t to be entirely abstract, not exposing anything
<ollehar> the only way to implement `show` for t is to add it in the same file as t, in OCaml - but in Haskell and Rust you can actually split it up.
ransom has joined #ocaml
<d_bot> <stab> Sure but how is implementing show not about polymorphism because in Haskell right, you can’t implement that type class in a place where the type is abstract
jbrown has quit [Ping timeout: 244 seconds]
<d_bot> <stab> Unless the interface provided gives you enough to get the string you want
<ollehar> sure
<ollehar> it's just about where t is abstract or not.
<ollehar> or, how a module is structured.
<d_bot> <stab> But typelasses aren’t about adding functionality
<d_bot> <stab> Fundamentally it achieves polymorphism. They don’t do anything for the fact that you want to use the internal structure in another file
<d_bot> <stab> The internal structure is either exposed or it isn’t
<ollehar> "typelasses aren’t about adding functionality" wat
<d_bot> <stab> Like literally the equivalent to your example in Ocaml is creating a module for comparison
<d_bot> <stab> Like say I have a type foo
<d_bot> <stab> I can create a module FooCompare that implements a comparable module type and pass that to functors
<d_bot> <stab> Type classes give you very specifically adhoc polymorphism which you don’t have in Ocaml
vicfred_ has joined #ocaml
<d_bot> <stab> Like fundamentally a type class declares functionality it doesn’t add functionality
vicfred has quit [Ping timeout: 240 seconds]
ggole has quit [Quit: Leaving]
<ollehar> I guess. The instance adds the functionality.
<ollehar> But I think you get my point. :D
<d_bot> <stab> Ok but like the instance doesn’t add functionality, I could write the function show outside of the instance that takes the type and turns it to a string
<d_bot> <stab> The point of making it an instance of that type class is that now functions that operate over the type class will be able to call that show function
<ollehar> how?
<ollehar> how could you take an abstract type and implement "show"?
<d_bot> <stab> show x = do the thing to make it a string
<d_bot> <stab> Alright say the type is abstract and you can’t get the string without seeing the internal type
<d_bot> <stab> How are you going to implement Show
<ollehar> In Haskell and Rust, by putting it in the same module.
<ollehar> In OCaml, by putting it in the same file (which is what I want to avoid)
<d_bot> <stab> Sure but you could write the function show without the typeclass in the same module
<d_bot> <stab> Type classes and traits have nothing to do with the problem you are describing
<d_bot> <stab> You just want to extend modules to different files
<d_bot> <stab> That’s it
<ollehar> 21:19 < d_bot> <stab> You just want to extend modules to different files
<ollehar> This is done with type-classes
<ollehar> afaik?
<ollehar> I don't want to randomly spread out a module in files
<ollehar> :)
<d_bot> <Et7f3> you can define separately and use include
<ollehar> et, no, that won't scale with multiple behaviours
<d_bot> <stab> I’m not sure do type classes give you special access to the module
<d_bot> <Et7f3> use functor then ?
<d_bot> <stab> Don’t see a reason that they would
<ollehar> et, yeah, maybe, hm
<ollehar> wait, no
<d_bot> <stab> From what I’m reading type classes don’t allow you special access to a module
<d_bot> <Et7f3> do you want the behaviour of `-pack` ?
<ollehar> functors give internal access?
<d_bot> <stab> No? Functors access whatever the module type declares
<ollehar> right, the sig
<ollehar> et, don't know -pack, have to read :)
<ollehar> also, IRC won't auto-complete discord names :|
<d_bot> <stab> I don’t really understand why you want to be able to do what you’re asking either. Essentially you’re asking for an escape hatch where a module declares something abstract and doesn’t reference another file but that file can still access the abstract type?
<d_bot> <stab> Seems to break encapsulation no?
<d_bot> <stab> Like obviously you can declare a module from a bunch of files by using include
<ollehar> It won't live up to "add new feature without touching old code"
<d_bot> <Et7f3> discord won't auto-complete irc name also
<d_bot> <stab> But you can’t do that in Haskell either? Like you can’t just add a new file and access abstract types. Like what you are asking for is to break encapsulation by allowing arbitrary files to add to a module
<ollehar> not arbitrary files, you can enforce a file-structure and compile it to limit access
<d_bot> <stab> I can’t think of a Lang where you can do that. In rust right you have your module directory but your mod.rs has to reference the files that are a part of it
<d_bot> <Et7f3> csharp with extention
<ollehar> will check
<d_bot> <Et7f3> in dune: basically you declare Lib.mli that declare the global interface, (I think dune generate automatically a Lib.ml that include all other module but you can write such by hand) and you declare many file in this folder
<d_bot> <Et7f3> in this folder you write a .mli for each module to speak with each other and hide it with Lib.mli
<d_bot> <stab> Yeah that works like have the type you want to extend functionality on non abstract within the project then define your lib signature to hide it again
<ollehar> c# extensions look messy
<ollehar> :d
<waleee-cl> I think Scala gains a similar functionality in Scala 3 (dotty)
<ollehar> yeah?
<waleee-cl> (I still think the type system gets a bit bonkers over there though)
<d_bot> <stab> I’m still confused about type classes because I’m fairly confident they don’t do what you want. Like if a field is private in the file the field is still private
<d_bot> <stab> Nonetheless what Et recommended sorta does what you want, it at least allows an internal signature and a signature that is presented to the user
<ollehar> I'll read up ^^
<ollehar> waleee-cl: I'm not touching neither Scala nor C++
<d_bot> <stab> Scala is nice if you are dealing with java legacy code tbh
<d_bot> <stab> otherwise id rather use something else
<ollehar> shit, my suggestion to php-internals is shit
<ollehar> it's not clear to me if scala extension methods have private access or not. I assume not.
<ollehar> yeah, good points, stab, regarding files referencing other files.
vicfred_ has quit [Quit: Leaving]
ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]