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
jnavila has quit [Ping timeout: 260 seconds]
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
zv has quit [Ping timeout: 268 seconds]
<indicator> What's a good library to parse dates and do date arithmetic on them? I tried ptime, but it seems it's strictly for timestamps, no way to parse a simple ISO date
<d_bot> <hcarty> indicator: https://github.com/ocaml-community/calendar works well for that. It has parsing, printing and arithmetic functions. I think there's also a separate iso date parsing library on opam. And I think the Jane Street libraries have something for this
tane has quit [Quit: Leaving]
amiloradovsky has quit [Ping timeout: 268 seconds]
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
vicfred has quit [Quit: Leaving]
vicfred has joined #ocaml
mfp has quit [Ping timeout: 240 seconds]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 264 seconds]
Haudegen has quit [Ping timeout: 260 seconds]
<d_bot> <darrenldl> indicator: if you need good time zone support, Drup and I are working on Timere, which has good (or at least I claim so) time zone support for date times https://github.com/daypack-dev/timere
<d_bot> <darrenldl> I am still adding ISO8601 date parsing and printing. As for support of arithmetic on date times of individual fields, I'll have to think about it a bit more - always felt a bit dodgy to me
steenuil has quit [Read error: Connection reset by peer]
<d_bot> <darrenldl> (Timere provides a Duration module, but only handles up to days, and doesn't support "year" or "month" as a unit)
madroach has joined #ocaml
madroach_ has quit [Ping timeout: 256 seconds]
mxns has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
<d_bot> <jayylmao> does anybody here know how to use zed? I'm trying to just append a character to the end of a line. The way I've done this by creating a context with a new cursor is using `Zed_edit.goto_eot` (there's only one line actually) to seek to the end of the data, then using `Zed_edit.insert_char` After doing this, `Zed_edit.get_data` simply returns the original data I put into the engine. Do I need to explicitly run/apply my context o
ArthurStrong has joined #ocaml
ArthurStrong has quit [Quit: leaving]
hnOsmium0001 is now known as hnOsmium0002
hnOsmium0002 is now known as hnOsmium0001
narimiran has joined #ocaml
mxns has quit [Quit: ZNC 1.8.2 - https://znc.in]
mxns has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
delysin has quit [Quit: WeeChat 3.0]
shawnw has quit [Ping timeout: 268 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 272 seconds]
shawnw has joined #ocaml
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 264 seconds]
<indicator> Thanks, I'll try Core.Date -- by arithmetic I just mean adding days to dates (and maybe adding days/hours/minutes etc. to times)
dborisog has joined #ocaml
<d_bot> <darrenldl> indicator: that would be well defined for timestamp, but not necessarily for date times in general (cause DST), but i will add that to timere in some shape or form
mxns has joined #ocaml
mxns has quit [Ping timeout: 240 seconds]
Tuplanolla has joined #ocaml
bartholin has joined #ocaml
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
leah2 has quit [Ping timeout: 264 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 264 seconds]
leah2 has joined #ocaml
<d_bot> <octachron> @EduardoRFS , the infinite recursion seems quite orthogonal to the recursive module? One option would be to only make instances as needed. This might require to change the encoding argument of `case` to a thunk or a lazy value.
mxns has joined #ocaml
mfp has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 264 seconds]
Haudegen has joined #ocaml
jnavila has joined #ocaml
steenuil has joined #ocaml
delysin has joined #ocaml
olle_ has joined #ocaml
olle_ has quit [Ping timeout: 256 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 258 seconds]
webshinra has quit [Remote host closed the connection]
webshinra has joined #ocaml
artymort has quit [Ping timeout: 256 seconds]
zebrag has quit [Quit: Konversation terminated!]
FreeBirdLjj has joined #ocaml
zebrag has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 260 seconds]
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
troydm has joined #ocaml
nicoo has quit [Ping timeout: 240 seconds]
andreas303 has quit [Ping timeout: 240 seconds]
cantstanya has quit [Remote host closed the connection]
tryte has quit [Ping timeout: 240 seconds]
cantstanya has joined #ocaml
nicoo has joined #ocaml
tryte has joined #ocaml
toppler has quit [Quit: ERC (IRC client for Emacs 26.3)]
andreas303 has joined #ocaml
toppler has joined #ocaml
olle has joined #ocaml
tryte has quit [Ping timeout: 240 seconds]
tryte has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 264 seconds]
shawnw has quit [Ping timeout: 264 seconds]
waleee-cl has joined #ocaml
<d_bot> <Cyclomatic Complexity> The library is https://opam.ocaml.org/packages/data-encoding/ and doesn't do thunks :(
<d_bot> <EduardoRFS> @octachron yeah that's what I figured it out, but even by making case lazy. Was able to make it work with case being lazy + FCM
_ks has quit [Quit: WeeChat 2.9]
_ks has joined #ocaml
Franciman has joined #ocaml
<Franciman> Hi
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
steenuil has quit [Read error: Connection reset by peer]
steenuil has joined #ocaml
olle_ has joined #ocaml
l1x has quit [Quit: Connection closed for inactivity]
olle_ has quit [Ping timeout: 246 seconds]
raver has joined #ocaml
mxns has joined #ocaml
Jeanne-Kamikaze has joined #ocaml
mxns has quit [Ping timeout: 258 seconds]
Franciman has left #ocaml ["Leaving"]
Yagotzirck has joined #ocaml
foohalah has joined #ocaml
<foohalah> what's the best way to simulate inheritance in ocaml without classes?
<foohalah> in java, for example, say A and B implement some method foo() and are parents of C
<foohalah> *children
<foohalah> how can i define a method in C, say foo_parent, that calls the appropriate child method?
zebrag has quit [Quit: Konversation terminated!]
<companion_cube> At that point why not use classes?
<foohalah> i heard classes are bad
<companion_cube> Well inheritance is rarely useful
<foohalah> oh
<foohalah> why is that?
<companion_cube> But if you need it, use the built-in mechanism and save yourself some trouble
<companion_cube> People don't write OO style in ocaml much
<companion_cube> If it's the right tool for the job, though, use the mechanisms that exist
zebrag has joined #ocaml
mxns has joined #ocaml
toppler has quit [Remote host closed the connection]
rdivyanshu has joined #ocaml
confoo has joined #ocaml
<confoo> is it allowed for two modules to use methods from each other?
<thizanne> confoo: yes, but you need to use recursive modules ( https://caml.inria.fr/pub/docs/manual-ocaml/manual024.html )
mxns has quit [Ping timeout: 256 seconds]
<confoo> so i need to put them in the same file?
<thizanne> yes, you can't do that across files
<confoo> oh
<thizanne> but maybe what you actually want to do is have these "common" functions in another module?
<confoo> so I have a player type in player.ml which among other things consists of a {mode: int}, and based on the mode i want to call different functions in modeA.ml and modeB.ml
<confoo> but I also want to pass in the player in the modeA and modeB functions
<confoo> so in modeA i will have some signature like "let run (player:Player.player) = ... "
<confoo> but in player i will have something like "if player.mode = 1 then run player ... "
<confoo> could you suggest a good organization for this?
<confoo> let me know if that makes sense? thizanne
<thizanne> confoo: that's a bit too few info to design an optimal organization
<confoo> Hum, what else would you need/
<qwr> not sure I followed correctly, but if it's about Player datatype, put it into separate module interface used by both...
<qwr> or actually, by all 3 (Player, ModeA, ModeB) using PlayerType
<thizanne> confoo: a general advice would be that you need to decouple things, because obviously you have too many interdependencies
<thizanne> do you really need to have `mode` as part of the player datatype? Do you really need to take a player in modeA and modeB?
<thizanne> eg., if players have a mode inside them, then does it really make sense for modeA and modeB functions that manipulate players to have that mode information?
<confoo> the reason i wanted to do that is because i have a function CollectReward which iterates through all the players, and gives a different reward based on the mode of the player
<confoo> qwr what do you mean by module interface? apologies i have never heard of this, i am beginner
<qwr> .mli - can have only types and optionally function signatures, needs corresponding .ml unless there are only types
<thizanne> confoo: only give to functions the minimal amount of information that they need
<thizanne> you could try removing the mode from the player type, and give a player and a mode to functions that need it
<thizanne> that may or may not be the right solution, depending on a lot more things on your program
<qwr> confoo: do other player functions use this CollectReward?
<confoo> yeah, they do
mxns has joined #ocaml
<qwr> the general answer is that if you _actually_ need recursive call graph between different module _files_, then a function value has to be passed as argument, but it might be better to try organize the code in a way to avoid such coupling
<qwr> i think the passing could be also done using module functors, in which case it happens compile time
mxns has quit [Ping timeout: 272 seconds]
<qwr> though using functors might be overengineering for your case
<confoo> :o
<confoo> can you please elaborate on the purpose of mli files? up until now in our class we haven't needed to use them
<confoo> is it kind of like .h file in C programming?
<qwr> kind of, but they represent module signature, which can be represented also inside another module and can also be inferred from module definition (which is why you don't need to write .mli for each .ml)
<qwr> and also modules can be nested, files obviously not
<qwr> if you could imagine language where each source code file is implicitly a function it might help to understand ocaml modules in the sense, that they are separate concept from source files, but each source file is always implicitly module or module signature
dborisog has quit [Ping timeout: 272 seconds]
<confoo> i see, that makes sense
sm2n has joined #ocaml
tane has joined #ocaml
<confoo> so is there no way to only import like a record type declaration from one class and not form a circular dependency problem?
<confoo> one file, sorry
<confoo> since the only thing i really need is the "type player"
sm2n_ has quit [Ping timeout: 256 seconds]
<qwr> then put type player into separate playerType.mli and use it from each of the other modules
<confoo> oh, didn't know you could do this
<confoo> and how is the linking done?
<confoo> playerType.player?
<confoo> or do i need to "open playerType"?
<qwr> open PlayerType is simpler, though PlayerType.player works equally well
<qwr> open just imports the module namespace
<confoo> do I need a playerType.ml then?
<qwr> no, the .ml isn't required in this case, you don't have functions to implement
<confoo> weird, i am getting some compilation error
<qwr> what error?
mxns has joined #ocaml
<companion_cube> qwr: mli only modules are not worth it
<qwr> companion_cube: the type in his case could be put in .ml also, but there is no difference imho
foohalah has quit [Remote host closed the connection]
<d_bot> <ulrikstrid> Where can I read the docs for the .ocamlformat file?
<companion_cube> qwr: the difference is that a .ml file will build without question
<d_bot> <Splingush> From my understanding, the options you can pass to the command-line-tool are the same you'd use in the format-file.
<d_bot> <Splingush> e.g.
<d_bot> <Splingush> ```
<d_bot> <Splingush> // .ocamlformat
<d_bot> <Splingush> version=0.15.0
<d_bot> <Splingush> profile = janestreet
<d_bot> <Splingush> let-binding-spacing=sparse
<d_bot> <Splingush> ```
<d_bot> <Splingush> where the options listed in the help are
<d_bot> <Splingush> ```
<d_bot> <Splingush> --let-binding-spacing={compact|sparse|double-semicolon}
<d_bot> <Splingush> --profile={conventional|default|compact|sparse|ocamlformat|janestreet}
<d_bot> <Splingush> ```
<d_bot> <ulrikstrid> Thanks @Splingush
<d_bot> <ulrikstrid> Can I convert a int to bytes easily? and vice versa
<d_bot> <ulrikstrid> Currently doing it via a float and `Int64.bits_of_float` but that seems heavy handed, and I don't need a full 64 bits
<d_bot> <ulrikstrid> Is this reliable?
<d_bot> <ulrikstrid> ```ocaml
<d_bot> <ulrikstrid> let to_bytes num =
<d_bot> <ulrikstrid> let bytes = Bytes.create 2 in
<d_bot> <ulrikstrid> Bytes.set_int16_be bytes 0 num
<d_bot> <ulrikstrid> ```
Yagotzirck has quit [Quit: Leaving]
minimario has joined #ocaml
minimario has quit [Remote host closed the connection]
confoo has quit [Remote host closed the connection]
hnOsmium0001 has joined #ocaml
rdivyanshu has quit [Quit: Connection closed for inactivity]
narimiran has quit [Ping timeout: 260 seconds]
olle_ has joined #ocaml
GuerrillaMonkey has joined #ocaml
Jeanne-Kamikaze has quit [Ping timeout: 272 seconds]
amiloradovsky has joined #ocaml
obood has joined #ocaml
jnavila has quit [Ping timeout: 256 seconds]
<obood> Is there a good reference on ocamlbuild somewhere
<obood> Can someone explain this syntax? "type 'a iterator = < get : 'a; has_value : bool; next : unit >"
<thizanne> obood: that's an objet type
<obood> Yes, how about the 'a?
<thizanne> it's a parameter of the type
<obood> Cool!
<obood> I also saw this. ```method has_value = Poly.(current <> [])```
<obood> what does it mean?
<thizanne> what's the part that you don't understand ?
raver has quit [Remote host closed the connection]
<thizanne> Poly.(...) is a local opening of the Poly module
<obood> ah ok
<obood> Why couldn't I just do current <> [] directly?
<thizanne> probably because you open a module that shadows the definition of <> so that it only works for integers
<thizanne> Core (and Base) indirectly does that
nicoo has quit [Remote host closed the connection]
<thizanne> the reasoning is that polymorphic (=) and (<>) may lead to bugs because they won't have the interesting properties on some types
GuerrillaMonkey has quit [Quit: Leaving]
Jeanne-Kamikaze has joined #ocaml
<thizanne> and there's currently no way in OCaml to restrict them to only "types where they certainly make sense"
nicoo has joined #ocaml
<obood> I see.
mrallen1 has quit [Ping timeout: 260 seconds]
ec has quit [Ping timeout: 260 seconds]
waleee-cl has quit [Ping timeout: 260 seconds]
Duns_Scrotus has quit [Ping timeout: 260 seconds]
Duns_Scrotus has joined #ocaml
waleee-cl has joined #ocaml
mrallen1 has joined #ocaml
ec has joined #ocaml
amiloradovsky has quit [Ping timeout: 258 seconds]
obood has quit [Remote host closed the connection]
<oni-on-ion> thizanne, object type is the same as object ?
opulence has joined #ocaml
amiloradovsky has joined #ocaml
<opulence> can anyone explain why optional arguments can't be last?
<opulence> what's the theory behind that?
<opulence> `add x ?(y=5) = x + y`
<d_bot> <mnxn> optional arguments cant be last because it wont be possible to recognize when the function arguments are over
<d_bot> <mnxn> For that example, `add 1` could be the int `6` or the partially applied function `?y:int -> int`
ArthurStrong has joined #ocaml
opulence has quit [Remote host closed the connection]
tane has quit [Quit: Leaving]