companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.0 released(!!1!): https://ocaml.org/releases/5.0.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
Tuplanolla has quit [Quit: Leaving.]
mima has quit [Ping timeout: 245 seconds]
waleee has quit [Ping timeout: 245 seconds]
waleee has joined #ocaml
Awww has quit [Quit: Client closed]
Gurgl has joined #ocaml
waleee has quit [Quit: WeeChat 4.0.2]
waleee has joined #ocaml
oriba has quit [Ping timeout: 246 seconds]
sim642 has quit [K-Lined]
sim642 has joined #ocaml
waleee has quit [Ping timeout: 256 seconds]
uncomfy has joined #ocaml
uncomfy has quit [Remote host closed the connection]
uncomfy has joined #ocaml
uncomfy has quit [Remote host closed the connection]
uncomfy has joined #ocaml
uncomfy has quit [Remote host closed the connection]
uncomfy has joined #ocaml
uncomfy has quit [Remote host closed the connection]
uncomfy has joined #ocaml
chrisz has quit [Ping timeout: 246 seconds]
chrisz has joined #ocaml
spip has quit [Ping timeout: 240 seconds]
hannes has quit [Ping timeout: 244 seconds]
uncomfy has quit [Remote host closed the connection]
Gurgl has quit [Quit: Client closed]
bartholin has joined #ocaml
spip has joined #ocaml
zozozo has quit [Ping timeout: 258 seconds]
mima has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
azimut has quit [Ping timeout: 246 seconds]
ursa-major has quit [Quit: WeeChat 4.0.3]
Tuplanolla has joined #ocaml
zozozo has joined #ocaml
Techcable has quit [Ping timeout: 245 seconds]
Serpent7776 has joined #ocaml
masterbuilder has quit [Quit: leaving]
masterbuilder has joined #ocaml
mima has quit [Ping timeout: 260 seconds]
noonien has quit [Quit: The Lounge - https://thelounge.chat]
noonien has joined #ocaml
noonien has quit [Ping timeout: 246 seconds]
azimut has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
tom1212 has joined #ocaml
<tom1212> Hello! is it possible to give a name to a first class module in signature, like so? https://tpaste.us/d1dj (doesn't typecheck with "unbound module F")
<discocaml> <froyo> nope, sounds like you need a functor here
<tom1212> thanks! went with https://tpaste.us/4ajq in the end
<discocaml> <froyo> fair
<tom1212> why is it not possible to put a constraint on the module returned by univariate_polynomial https://tpaste.us/MRa5?
mima has joined #ocaml
<discocaml> <hockletock> what does `module Ring with type t = 't` do?
<tom1212> the 't links the type of the input module to the type coeff of the returned module
<tom1212> okay, managed to achieve what I wanted https://tpaste.us/a1qZ
<tom1212> I think ^^'
<tom1212> well, not quite, let's fix it
<tom1212> noice
<tom1212> this allows to defunctorize while still keeping the invariant that the coefficients have a ring structure
<tom1212> at the price of some Obj.magic in the implementation 🙃
deadmarshal_ has quit [Remote host closed the connection]
waleee has joined #ocaml
Anarchos has joined #ocaml
mima has quit [Ping timeout: 248 seconds]
azimut has quit [Ping timeout: 246 seconds]
azimut has joined #ocaml
Techcable has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
deadmarshal_ has joined #ocaml
tom1212 has quit [Ping timeout: 246 seconds]
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
tom1212 has joined #ocaml
bartholin has quit [Quit: Leaving]
Serpent7776 has quit [Ping timeout: 248 seconds]
<tom1212> once I found a correct architecture for a wrapper over some ctypes types+functions, I'm thinking to generate it automatically
<tom1212> thinking of two approaches: either generate with PPX or parse the ocaml files to generate new ocaml modules
<tom1212> which one would you recommand and which tools do you think could help?
<tom1212> s/recommand/recommend
<tom1212> parsing the generated ctype type/function definitions seems the way to go
<discocaml> <Kali> i think this already exists
<discocaml> <Kali> ppx_cstubs
<discocaml> <Kali> maybe not what you're looking for though
<tom1212> nice! I've already written a simple program that generates Ctypes stubs from C header files (seems like ppx_cstubs does it backward)
<tom1212> I like that you can embed C code in your caml files though
<tom1212> basically there are over 6k functions using ctypes types that I'd like to restructure in smaller modules with uniform interfaces
<tom1212> I think it would be nice to automate a bit the process
<tom1212> so that say when I want to change the architecture of the lib it can be done more easily
<companion_cube> 6k functions?? :o
<companion_cube> aht are you binding?
<tom1212> yep!
<companion_cube> what*
<companion_cube> oh, an algebra library, cool
<tom1212> I'd like to generate nice doc for those functions too, with https://github.com/realworldocaml/mdx, that I would partially scrap from the library official manual
Anarchos has joined #ocaml
<tom1212> yeah! I'd like to demonstrate the power of ocaml with algorithms working on abstract structures, so that you can instantiate with various objects
<tom1212> such as Pollard's p-1 factoring method that works on groups (Z/pZ, elliptic curve over finite fields)
<tom1212> that would be cool :)
<companion_cube> my naive advice on such a thing would be: keep the bindings as simple and direct as possible
<companion_cube> and make a nicer API on top if you have the motivation — and that's where you can put abstractions and the likes
<tom1212> great advice!
<tom1212> sounds like you can just translate C programs to ocaml ones with the generated ctypes functions from little experiments
<companion_cube> if you already have C code, then yes indeed! You'll just need to know how names map (but if you generated the bindings you'll know)
John_Ivan has quit [Quit: Disrupting the dragon's slumber one time too often shall eventually bestow upon all an empirical and indiscriminate conflagration that will last for all goddamn eternity.]
<tom1212> exactly
<tom1212> been thinking about different patterns for organizing the code
<companion_cube> for some example of that, some of Bunzli's bindings are classic I think
<companion_cube> tsdl, tgls, etc.
<tom1212> one relies on functors, others on modules with parametric type
<companion_cube> more opinionated advice: if you can avoid functors, avoid them
<companion_cube> staying at the expression level is a lot easier
<companion_cube> (that's my opinion)
<Anarchos> companion_cube and objects are very rarely used.
<companion_cube> true, true
<companion_cube> the biggest drawback of objects is that half the community refuses to use them altogether
<companion_cube> but you can use records of functions, or first-class modules, instead
<tom1212> yeah avoiding objects because the late binding is not great for performance
John_Ivan has joined #ocaml
<tom1212> from a UX perspective you have to define all your modules beforehand with the functor approach, whether with the parametric type approach that's not needed (although I still enforce some invariants on the parametric type such as a special structure)
<companion_cube> functors are a pain to use
<companion_cube> especially if you have many of them
<tom1212> their typechecking is unsound no?
<companion_cube> hm, no
Anarchos has quit [Quit: Vision[]: i've been blurred!]
<tom1212> yeah functors are more for "programming in the large", not good replacement for OOP-like programming
<tom1212> records of functions may be better suited
<companion_cube> indeed
<companion_cube> (at runtime, functors are also records btw)
<tom1212> cool :)
<companion_cube> (well. Functors are functions from records to records.)
<tom1212> but still I'm not found of the parametric types 'a t because the type variable 'a has a restricted domain (in the API you build 'a polynomials where 'a = Ring.t for instance)
<tom1212> fond*
<companion_cube> so can't you build `Ring.t polynomials`?
<tom1212> yes you can
<tom1212> the latter is a bit weird
<companion_cube> these looks pretty nice
<tom1212> thanks ^^
<companion_cube> so `create_poly` makes a polynomials whose coefficients are polynomials themselves?
<tom1212> yep, you have the arity in the type this way
<tom1212> rings of multivariate polynomials
<tom1212> you'd loose this info if you build with `create (module Poly) [...]`
<tom1212> I mean, in the type, the underlying library would still figure out that it's computing with a multivariate poly
ursa-major has joined #ocaml
<tom1212> one thing that is very easy to do with loosely typed library is that you can add/multiply compatible types (rationals with integers for instance)
<tom1212> with ocaml you'd have to explicitly embed an integer in a rational
<companion_cube> right
<discocaml> <._null._> one thing that is very easy to do with loosely typed library is that you can add/multiply incompatible types (rationals with strings for instance)
<tom1212> that's a bit annoying, but hey that's the price to pay to use well-typed libs!
<tom1212> yep
<tom1212> still a language with overloaded operators could achieve this
<discocaml> <._null._> Static typed-based dispatch ?
mima has joined #ocaml
<tom1212> yes
szkl has joined #ocaml
mima has quit [Ping timeout: 256 seconds]
tom1212 has left #ocaml [#ocaml]
tjammer_ has quit [Ping timeout: 246 seconds]
tjammer has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]