adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.07.1 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.07/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml | Due to ongoing spam, you must register your nickname to talk on the channel
<eskatrem> Hi, if I have a type like: `type mytype = | A of int | B of float;;`, how are A and B called?
okuu has quit [Ping timeout: 240 seconds]
<smondet[m]> eskatrem: they're called "Constructors"
<eskatrem> thanks smondet[m]
<eskatrem> So my question is: can two types can have the same constructors?
<smondet[m]> Yes they can but it is not good practice because the 2nd one hides the first one from the type inference
<smondet[m]> and it makes code harder to read
<eskatrem> OK fair enough
<eskatrem> I want to deal with some various tree structures so I wanted to reuse the constructors names
<smondet[m]> You can use modules
<smondet[m]> module Foo = struct type t = A of int end module Bar = struct type t = A of float end
<eskatrem> neat, thanks
<smondet[m]> That way Foo.A and Bar.A are clearly separate.
<eskatrem> and I can write a Foo to Bar converter?
<smondet[m]> just a function of type Foo.t -> Bar.t ? yes of course
<eskatrem> let foo_to_bar x = let x = A n in A (float n)
<eskatrem> ok gonna try that, thank you smondet[m]
<eskatrem> ah ok, I do Foo.A and Bar.A, thanks
nullifidian_ has quit [Read error: Connection reset by peer]
nullifidian_ has joined #ocaml
eskatrem has quit [Read error: Connection reset by peer]
stux|RC-only has quit [Ping timeout: 268 seconds]
mfp has quit [Ping timeout: 245 seconds]
_whitelogger has joined #ocaml
silver has quit [Read error: Connection reset by peer]
tormen_ has joined #ocaml
tormen has quit [Ping timeout: 246 seconds]
sonologico has joined #ocaml
stux|RC-only has joined #ocaml
ansiwen has quit [Quit: ZNC 1.7.1 - https://znc.in]
ansiwen has joined #ocaml
_whitelogger has joined #ocaml
_whitelogger has joined #ocaml
gravicappa has joined #ocaml
<andrewlitteken> Can someone with 4.08 try something for me? I was going to work on issue: https://github.com/ocaml/ocaml/issues/7886, but am reasonably sure this doesn't occur anymore in the current version of the repository
AnAverageHuman has quit [Ping timeout: 256 seconds]
ricekrispie has left #ocaml ["Leaving"]
stux|RC-only has quit [Ping timeout: 268 seconds]
stux|RC-only has joined #ocaml
stux|RC-only has quit [Ping timeout: 250 seconds]
ygrek__ has quit [Ping timeout: 268 seconds]
eskatrem has joined #ocaml
assemblyman has joined #ocaml
_whitelogger has joined #ocaml
SomeDamnBody has joined #ocaml
nullifidian_ is now known as nullifidian
jao has quit [Ping timeout: 245 seconds]
gravicappa has quit [Ping timeout: 246 seconds]
Birdface has joined #ocaml
assemblyman has quit [Quit: ™]
nullifidian_ has joined #ocaml
nullifidian has quit [Read error: Connection reset by peer]
keep_learning_M has quit [Ping timeout: 258 seconds]
sonologico has quit [Ping timeout: 252 seconds]
ggole has joined #ocaml
sonologico has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
nikolaos2 has joined #ocaml
nullifidian__ has joined #ocaml
<Armael> andrewlitteken: indeed, it was fixed (cf my answer on github)
nullifidian_ has quit [Ping timeout: 268 seconds]
<Armael> (thanks for pointing it out, at least we can properly close the issue!)
kakadu has joined #ocaml
powerbit has joined #ocaml
mfp has joined #ocaml
carlos1 has joined #ocaml
carlos1 has quit [Quit: WeeChat 2.2]
carlosdagos has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
ravenousmoose has joined #ocaml
Anarchos has joined #ocaml
gravicappa has joined #ocaml
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
FreeBirdLjj has joined #ocaml
vsss has quit []
silver has joined #ocaml
carlosdagos has quit [Ping timeout: 250 seconds]
carlosdagos has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
FreeBirdLjj has joined #ocaml
<eskatrem> Hi, is there a way to use List.map for a function of multiple arguments? something like `List.map (fun a b -> a + b) [1; 2; 3] [4; 5; 6];;` (which obviously doesnt work)
<kakadu> you need specialized map (List.map2 in that case)
<eskatrem> oh, thanks kakadu I didnt know about map2
<eskatrem> yes, map2 works, thanks again
Haudegen has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 264 seconds]
keep_learning_M has joined #ocaml
ihavelotsoffries has joined #ocaml
<ihavelotsoffries> hello everyone
<eskatrem> hi ihavelotsoffries
<ihavelotsoffries> Hello eskatrem :)
<ihavelotsoffries> Is it possible to match for multiple variants when matching a tuple component?
<ihavelotsoffries> in `match (a, b) with .... ` I want to match a case where a is either A, B or C, and b is D or E.
<octachron> (A|B|C), (D|E)
<otini> btw you can also write `match a,b with ...`. The parentheses are not necessary to denote a tuple in OCaml.
<ihavelotsoffries> Ah, excellent.
<ihavelotsoffries> Let me try! thank you ocabot and otini.
AnAverageHuman has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 268 seconds]
ihavelotsoffries has quit [Ping timeout: 258 seconds]
FreeBirdLjj has joined #ocaml
unyu has quit [Quit: ERC (IRC client for Emacs 26.1)]
FreeBirdLjj has quit [Remote host closed the connection]
unyu has joined #ocaml
ygrek__ has joined #ocaml
keep_learning_M has quit [Quit: This computer has gone to sleep]
nicoo has quit [Ping timeout: 256 seconds]
nicoo has joined #ocaml
okuu has joined #ocaml
nikolaos2 has quit [Ping timeout: 252 seconds]
eskatrem has quit [Read error: Connection reset by peer]
loli has quit [Quit: WeeChat 2.4]
zolk3ri has joined #ocaml
okuu has quit [Remote host closed the connection]
<Ankhers> How common is it to be explicit with your functions type definitions instead of letting them be inferred?
* companion_cube does it, but it's quite uncommon afaik
<Ankhers> Any particular reason it is uncommon?
<ggole> It's annoying to type them twice if you have a .mli
<ggole> And the annotation syntax is kinda noisy
<companion_cube> the cool thing is, you can do it partially
<companion_cube> I tend to at least annotate the return type, or parts of it
<companion_cube> let f x y : foo = …
<ggole> It is nice that you can skip bits with _
<companion_cube> but repeating the types is pretty acceptable imho, it makes the code more readable anyway
<companion_cube> yeah exactly
<companion_cube> let f x : _ list = …
stux|RC-only has joined #ocaml
Jesin has quit [Quit: Leaving]
Jesin has joined #ocaml
tarptaeya_ has left #ocaml [#ocaml]
tane has joined #ocaml
ravenousmoose has joined #ocaml
Haudegen has quit [Remote host closed the connection]
raduom has joined #ocaml
ziyourenxiang_ has quit [Ping timeout: 245 seconds]
ravenousmoose has quit [Quit: Textual IRC Client: www.textualapp.com]
amfabasti has joined #ocaml
raduom has quit [Read error: Connection reset by peer]
gravicappa has quit [Ping timeout: 268 seconds]
Haudegen has joined #ocaml
wiml has joined #ocaml
ggole has quit [Quit: Leaving]
<wiml> Can anyone explain to me (or point to docs) about the interaction of libraries (.mllib, .cma) and packs (-for-pack, etc)? I have module foo.ml with various toplevel items, I want to split out just some of its submodules into separate .ml files (e.g. Foo.Bar). Is this possible or am I just barking up the wrong tree?
<companion_cube> use dune, forget about packs
<wiml> What do you mean?
<wiml> (I mean, I know about dune.)
<companion_cube> dune does packing of libraries automatically, so in a library Foo, a file bar.ml will be Foo.Bar
<wiml> Can you have both foo.ml and bar.ml and have dune produce Foo and Foo.Bar (as opposed to A.Foo and A.Bar, which I already know how to do)? I do use dune, but I couldn't get it to do this, so I was dropping down a level.
<companion_cube> if your lib is `foo`, Foo.ml will be the toplevel module
<companion_cube> and inside you can `module Bar = Bar` to re-export
<wiml> Oh, I see. So Bar still exists as a toplevel module?
<wiml> It's just re-exported as a submodule.
<companion_cube> it's in scope as Bar inside the foo lib, as `Foo.Bar` outside
tane has quit [Quit: Leaving]
<wiml> Huh. Okay, I thought it was also in scope as Bar to the outside world, which would cause problems in my case (pretty generic submodule names like S). If not, then that works.
<wiml> Or, right, dune renames it to Foo__Bar to avoid that, doesn't it.
<companion_cube> it does magic inside, yes
<companion_cube> but functionally you get the equivalent of pack, but more lightweight
Jeanne-Kamikaze has joined #ocaml
<wiml> Hmmm, so what dune does is compile them as Foo__Bar, then create a wrapper module Foo__ with module Bar = Foo__Bar, then implicitly open Foo__ in Foo
cantstanya has quit [Remote host closed the connection]
cantstanya has joined #ocaml
Birdface has quit [Ping timeout: 268 seconds]
Jeanne-Kamikaze has quit [Remote host closed the connection]
_whitelogger has joined #ocaml
wiml has quit [Quit: Leaving]
crowley95 has quit [Ping timeout: 250 seconds]
crowley95 has joined #ocaml
crowley95 has quit [Ping timeout: 264 seconds]
crowley95 has joined #ocaml
demonimin has joined #ocaml
demonimin has quit [Ping timeout: 246 seconds]
keep_learning_M has joined #ocaml
eskatrem has joined #ocaml
_whitelogger has joined #ocaml
demonimin has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
demonimin has quit [Ping timeout: 250 seconds]
nicoo has quit [Ping timeout: 256 seconds]
cantstanya has quit [Ping timeout: 256 seconds]
keep_learning_M has quit [Quit: This computer has gone to sleep]
cantstanya has joined #ocaml
kakadu has quit [Remote host closed the connection]
try-again has joined #ocaml
keep_learning_M has joined #ocaml
ziyourenxiang_ has joined #ocaml