companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.2.0 released: https://ocaml.org/releases/5.2.0 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 245 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 268 seconds]
Tuplanolla has quit [Quit: Leaving.]
gzar has quit [Quit: WeeChat 4.5.1]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
wbooze has joined #ocaml
_whitelogger has joined #ocaml
mstevens has joined #ocaml
jbowen has joined #ocaml
wbooze has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
Haudegen has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
wbooze has quit [Quit: Leaving]
wbooze has joined #ocaml
alfiee has joined #ocaml
Inline has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 248 seconds]
euphores has quit [Quit: Leaving.]
euphores has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
Inline has quit [Quit: Leaving]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 265 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 272 seconds]
<discocaml> <sirius06615> I am a skilled full-stack developer with expertise in building scalable web and blockchain applications. On the frontend, I specialize in modern frameworks like React.js and Next.js to deliver seamless user experiences, while on the backend, I excel in Node.js, Express.js, and Python-based frameworks to create robust APIs and server-side logic. My database experience spans PostgreSQL, MongoDB, and cloud-based solutions like Firebase.
<discocaml> <sirius06615>
<discocaml> <sirius06615> In blockchain development, I have extensive experience with Ethereum, Solana, and SUI, using tools like Web3.js, ethers.js, and Hardhat to develop and deploy decentralized applications. I’ve worked on DeFi protocols, secure wallets, and NFT marketplaces, handling everything from smart contract creation to metadata integration. With strong cryptographic knowledge and hands-on experience in DevOps, I ensure secure and efficient application
<discocaml> <jalsol> but do you know what a monad is
Serpent7776 has joined #ocaml
wbooze has quit [Remote host closed the connection]
wbooze has joined #ocaml
bartholin has joined #ocaml
olle has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
Serpent7776 has quit [Ping timeout: 248 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 268 seconds]
Tuplanolla has joined #ocaml
alfiee has joined #ocaml
pi3ce has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
pi3ce has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
wbooze has quit [Ping timeout: 265 seconds]
<discocaml> <gooby_diatonic> A burrito
Serpent7776 has joined #ocaml
pi3ce has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
pi3ce has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
<discocaml> <darrenldl> ~~but do you know what a burrito is~~
<olle> Something endocunftor in the something
<olle> endo-functor?
alfiee has joined #ocaml
wbooze has joined #ocaml
alfiee has quit [Ping timeout: 245 seconds]
no-name has quit [Remote host closed the connection]
no-name has joined #ocaml
no-name has quit [Quit: The Lounge - https://thelounge.chat]
no-name has joined #ocaml
no-name has quit [Client Quit]
no-name has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
rgrinberg has joined #ocaml
<discocaml> <gooby_diatonic> A monoid in the category of endofunctors
<olle> That one yea
<discocaml> <alyxshang> I don't want to be mean but the amount of Javascript seems distinctly sus.
no-name has quit [Quit: The Lounge - https://thelounge.chat]
alfiee has joined #ocaml
anpad has quit [Ping timeout: 268 seconds]
alfiee has quit [Ping timeout: 246 seconds]
anpad has joined #ocaml
anpad has quit [Client Quit]
<discocaml> <gooby_diatonic> He's a code artisan
<discocaml> <Joe> What are people’s thoughts an experiences with First Class Modules? I’ve been making heavy use of them for a project and have found them really powerful but annoyingly verbose.
<companion_cube> Basically that, yeah
<companion_cube> In the end objects can be just more convenient
<discocaml> <Joe> I’ve wanted to try to replace some of it with classes but I’m a little limited by a lot of the modules needing to be used as reason JSX components
<discocaml> <gooby_diatonic> Is there even any situation where an object can't do something a first class module can?
<discocaml> <leviroth> Yeah, first class modules can contain types.
<companion_cube> Hmm you can unpack multiple modules and include them in a bigger one or pass them to a functor ig
anpad has joined #ocaml
<discocaml> <Joe> I’ve thought of a few different possibilities like maybe even trying to extend reason to allow class components or mixing my modules with classes.
<discocaml> <Joe> It actually hasn’t been too bad as I did hide a lot of the verbosity and complexity behind functors and bigger modules
<discocaml> <Joe> It would just be really nice to have some row polymorphism
<olle> Row poly if anything looks weird on the eyes...
<olle> [in ocaml]
<olle> That pesky hash operator
<discocaml> <Joe> I’m writing a document templating system where the top-level documents take a module with component definitions, — the module has to at least define the components required by that particular service. This works with using modules but is verbose. I *think* if I used an object it would be able to infer the required components rather than needing to specify them explicitly in a signature I provide.
<discocaml> <Joe>
<discocaml> <Joe> This isn’t actually using first class modules at that point but it is another pain point.
alfiee has joined #ocaml
Opus has quit [Remote host closed the connection]
alfiee has quit [Ping timeout: 244 seconds]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Opus has joined #ocaml
olle has quit [Ping timeout: 252 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
no-name has joined #ocaml
<discocaml> <Joe> Additionally has anyone tried mix in classes and modules as suggested here:
wbooze_ has joined #ocaml
wbooze has quit [Ping timeout: 260 seconds]
wbooze_ has quit [Ping timeout: 252 seconds]
wbooze has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 260 seconds]
<discocaml> <alyxshang> Of course, Javascript forces one to write code as art. But in all seriousness, if you are reading this Mr. Javascript-enjoyer, shouldn't you perhaps investigate different ways of implementing things and gain a broader view of this field before announcing that you do almost everything in Javascript? I say this with the warmest intentions.
<discocaml> <alyxshang> TL;DR: Skill comes from experience and experience comes from having the broadest possible view of one's field and limiting oneself to Javascript only for whatever reason seems like you are limiting yourself unneccessarily.
<discocaml> <alyxshang> Don't want to be here, sounding like a neckbeard and discourage anyone from their goals/hopes/dreams.
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
<za3k> okay i have maybe a dumb question (keep in mind I have not finished learning OCaml). My understanding is that there's no function-level polymorphism (ex. I can't write an 'a -> string function for debugging)
<za3k> but i've been reading 'compiling with continuations' and it seems like standard ML *did* have that, and I understood Ocaml to be based on standard ml
<za3k> so how'd that happen?
<dh`> I'm not sure I understand what you mean
<za3k> so for example there's List.map, Array.map, Dynarray.map, etc etc
<za3k> But you can't write 'map' which takes any of the above, because there's no mechanism to extend functions (also no untagged unions but that's a different kind of function anyway)
<discocaml> <gooby_diatonic> There's just no non-trivial computation that can be generalised over all types
<za3k> [incidentally, my top feature requests for the standard library would be a standardized unit testing framework, and a generic 'string_of' in the same way we have a generic Marshal and Printf.sprintf]
<dh`> you can, it just becomes a mess with modules
<za3k> yeah i mean haskell does it with typeclasses
<za3k> i don't know enough to say how standard ML did it
<dh`> same as ocaml
<dh`> the term you're looking for is "parametric polymorphism"
<za3k> yeah
<discocaml> <gooby_diatonic> If they had a 'a.'a -> string it must've been very ugly
<za3k> am i wrong about Standard ML supporting this?
<dh`> a function like f x = x (whose type is forall t, t -> t, or equivalently in ocaml notation 't -> 't)
<za3k> I feel like one of my steps is probably wrong I just don't know which
<za3k> (at LEAST one)
<dh`> can be thought of as having an additional parameter 't that's the type
<discocaml> <gooby_diatonic> I prefer library authors making proper pretty printers
<za3k> for debugging purposes it's really nice to have a repr-equivalent, although having a central registry would be fine
<dh`> and 't can be any type
<za3k> printf debugging has been a huge pain
<dh`> the thing you don't have is that it can't have qualifiers or requirements or properties
<za3k> anyway my goal was not to gripe about printf debugging :)
<dh`> so it has to be able to be _any_ type
<za3k> yeah, so for example map would not have type 'a -> 'a, it would need qualifier
<za3k> you can't map over an int
<dh`> type classes are qualifiers
<za3k> ok wait does ocaml have typeclasses?
<discocaml> <yawaramin> OCaml isn't based on Standard ML, it's based on ML, which is quite different in many ways
<dh`> so a generic map has some type like forall t, Mappable t => t -> t
<discocaml> <yawaramin> OCaml does not have type classes
<za3k> ah thanks yawaramin, that's at least one step i got wrong
<dh`> and the Mappable class includes some kind of traversal operations so that the generic map function can call them
<za3k> that's pretty surprising, i didn't think ML was really in use long
<dh`> ML is very old
<discocaml> <yawaramin> as old as C
<dh`> (actually for a generic map the generic map function itself would probably be an element of the Mappable class)
<za3k> yeah i thought it was more of a paper than a system basically :) i'm not old enough to know firsthand
<dh`> anyway, anything you can write with typeclasses you can write with modules, it just has a tendency to be ugly
<dh`> or verbose
<za3k> oh very unrelated question, can someone point me at a worked example of using 'Map'? I absolutely cannot figure out the two-part type construction from the docs and am feeling dumb
<dh`> module IntKey = struct type t = int let compare = compare end
<za3k> yeah i totally bounced off haskell between typeclasses and monadic sugar, I found it very opaque to read
<dh`> module IntMap = Map.Make(IntKey)
<dh`> the haskell world likes to write incomprehensible one-liners and call the results elegant
<za3k> well i do that in ocaml
<discocaml> <yawaramin> za3k: there's a worked example in the module documentation https://ocaml.org/manual/5.3/api/Map.html
<dh`> it's much easier to be incomprehensible in haskell, and also the community kind of values it, which we generally don't here
<za3k> and then IntMap.empty; IntMap.add x y; and so on?
<dh`> yes
<za3k> Yeah there's no inline compose operator which I've found actually blocks some of that
<dh`> and the type of your maps is IntMap.t
<za3k> thanks dh
<za3k> yawaramin: there sort of it, but it's verbose and doesn't include an example of making and using a map afterwards
<dh`> for some types you don't need to explicitly define the key module because something already exists, e.g. to make StringMap you can use the stdlib String module
<za3k> i did read it but i appreciated the extra help from dh
<dh`> btw, add is: let map' = IntMap.add key value map
<discocaml> <yawaramin> za3k: `let m = PairsMap.(empty |> add (0,1) "hello" |> add (1,0) "world")`
<discocaml> <yawaramin> that's from the doc i linked
<discocaml> <yawaramin> example of making and using the map
<dh`> that is really not helpful to a beginner
<za3k> oh I guess there's an Int.compare and an Int.t so I could use that too, but your explanation was much clearer explicitly
<dh`> hmm there is now? pretty sure there wasn't some years back when I first started
<dh`> ah, since 4.08
<dh`> a ways back but not that far
<dh`> anyway it's good to have an example of your own key because you'll need it as soon as you want something like a map from int * string
<za3k> exactly
<dh`> the thing I was writing yesterday features a whole bunch of int * string maps
<za3k> so i hear effects is getting worked on
<za3k> i thought i'd point people at scheme's dynamic-wind and dynamic-unwind if they somehow weren't familiar
<discocaml> <yawaramin> the map module doc example shows an example of int * int keys, wouldn't that be fairly simple to adapt to int * string?
<za3k> perhaps of interest but probably above my skill level to talk about
<dh`> also beware that while let compare = compare to get the builtin compare works for basic types, for many things the basic compare exists but doesn't work usefully
<za3k> hmm, what does it do for tuples, lists, records ?
<dh`> yawaramin: yes, but that example lost when it started using syntax like PairsMap.(empty |> add) that a beginner isn't going to follow
<za3k> i literally didn't know the .( notation, so agree
<dh`> builtin compare for tuples compares the members, same for records
<za3k> but also it fails to do anything
<za3k> lexicographic in some order?
<dh`> however, if you have a pair like say IntMap.t * StringMap.t
<dh`> you need to use IntMap.compare and StringMap.compare
<za3k> sure, because Map and some other types don't work some sensible way
<dh`> it's a question of things that appear in their internals, which in an ideal world you wouldn't have to think about
<za3k> the docs on 'compare' are pretty sparse
<dh`> but in the absence of a typeclass to attach the generic compare to, the choice is to either make it somewhat ad hoc or live without it
<za3k> they don't really talk about what it works sensibly on
alfiee has joined #ocaml
<dh`> some things will tell you to not use the generic compare
<za3k> ok one last question before i go for today (although I may be back if I try to tackle C integration)
<dh`> I'm not sure that map _doesn't_ work
<za3k> sometimes I get an error like "in" not being expected, or an unmatched "done"
<za3k> which really means the problem is something in unbalanced somewhere, or I added too many ;'s, or forget an 'in', etc
<dh`> but generally it's safest to assume that for anything with a nontrivial implementation that provides a compare function, you should use it
<za3k> any tips to track this down? special syntax highlighting or the like?
<dh`> there's no good way
<dh`> easiest is usually commenting out large chunks until you find the chunk that contains the problem, then narrowing it down
<za3k> I've found adding parentheses helps too
<dh`> the syntax is not really quite robust enough and this is how that shows up
<za3k> like adding parens around a huge chunk in a way that *shouldn't* affect anything
<dh`> right
<za3k> and if it does affect things, the problem was in that area
<za3k> anyway okay, sounds like not yet
<za3k> i think that's something that could be fixed by tooling someday
<dh`> syntax highlighting might help
alfiee has quit [Ping timeout: 244 seconds]
<dh`> also parens matching
<dh`> and autoindent
<dh`> but not always
<discocaml> <gooby_diatonic> You learn to find the errors with experience tbh, there's only so many ways to mess up the syntax, and they are annoying enough that they stick mentally
<za3k> yeah i was thinking an equivalent for paren-matching but for let...in
<za3k> basically just expand that to ocaml syntax
<za3k> autoindent would probably help a lot, yeah, but that drives me insane
<discocaml> <yawaramin> dh: good feeback, worth sending a small PR to update the doc
<za3k> yes, please use dh's specific example (along with a comment that you could use Int instead of IntKey and why)
<za3k> as a beginner i though it was an incredibly good example :)
<za3k> also can i just say i appreciate how friendly everyone has been in general
<discocaml> <yawaramin> we were told ro be nice by the publicists
<za3k> oh!! did i mention that the devs gave the go-ahead for me to publish the printed manual for other people
<za3k> well one dev at least, no real central person to ask :P
<za3k> i added post-it tabs to look up modules quickly and it at least doubled the value, too bad i can't get my publisher to do that
<dh`> I still have to send the previous issue we talked about :-)
<dh`> but maybe I should do this too
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 248 seconds]
wbooze has quit [Ping timeout: 248 seconds]
alfiee has joined #ocaml
<za3k> https://github.com/ocaml/ocaml/issues/13822 <-- printexc backtraces, I planned to get to that one but i certainly won't be upset if you steal it
alfiee has quit [Ping timeout: 276 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 276 seconds]
alfiee has joined #ocaml
emp has quit [Ping timeout: 252 seconds]
theblatte has quit [Ping timeout: 252 seconds]
theblatte has joined #ocaml
alfiee has quit [Ping timeout: 260 seconds]
emp has joined #ocaml
ohperitel has quit [Ping timeout: 252 seconds]
pie_ has quit [Ping timeout: 252 seconds]
pie_ has joined #ocaml
ohperitel has joined #ocaml
rgrinberg has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 246 seconds]
kron has quit [Quit: kron]
kron has joined #ocaml
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 244 seconds]
Serpent7776 has quit [Ping timeout: 272 seconds]
bartholin has quit [Quit: Leaving]
alfiee has joined #ocaml
alfiee has quit [Ping timeout: 252 seconds]