companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.14.0 released: https://ocaml.org/releases/4.14.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
Soni has quit [Ping timeout: 260 seconds]
Soni has joined #ocaml
zebrag has joined #ocaml
birdgoose has joined #ocaml
tiferrei2000 has joined #ocaml
tiferrei has quit [Ping timeout: 240 seconds]
bobo has joined #ocaml
spip has quit [Ping timeout: 260 seconds]
waleee has quit [Ping timeout: 240 seconds]
Sankalp has quit [Ping timeout: 246 seconds]
Sankalp has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
Haudegen has joined #ocaml
birdgoose has quit [Read error: Connection reset by peer]
shawnw has joined #ocaml
lobo has quit [*.net *.split]
Fardale has quit [*.net *.split]
amosbird has quit [*.net *.split]
energizer has quit [*.net *.split]
nore has quit [*.net *.split]
copy has quit [*.net *.split]
copy has joined #ocaml
Fardale has joined #ocaml
lobo has joined #ocaml
amosbird has joined #ocaml
nore has joined #ocaml
mbuf has joined #ocaml
energizer has joined #ocaml
dinosaure has quit [*.net *.split]
gjvc has quit [*.net *.split]
gjvc has joined #ocaml
dinosaure has joined #ocaml
mro has joined #ocaml
gravicappa has joined #ocaml
Serpent7776 has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
wingsorc has quit [Ping timeout: 260 seconds]
olle has joined #ocaml
azimut has quit [Ping timeout: 240 seconds]
Anarchos has joined #ocaml
mro has quit [Remote host closed the connection]
bartholin has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
<d_bot> <Bluddy> Just upgraded (on Windows 11) to wslg! It's awesome!
<d_bot> <Bluddy> linux with built-in gui
<d_bot> <Bluddy> highly recommended
dhil has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
mro has joined #ocaml
zebrag has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Ping timeout: 276 seconds]
Haudegen has joined #ocaml
tiferrei2000 has quit [Remote host closed the connection]
tiferrei has joined #ocaml
gravicappa has quit [Ping timeout: 260 seconds]
waleee has joined #ocaml
mro has joined #ocaml
<d_bot> <xextixnx> lool
<d_bot> <xextixnx> windows 11 rly
spip has joined #ocaml
bobo has quit [Ping timeout: 276 seconds]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Ping timeout: 252 seconds]
gravicappa has joined #ocaml
motherfsck has joined #ocaml
shawnw has quit [Ping timeout: 240 seconds]
mro has joined #ocaml
waleee has quit [Ping timeout: 248 seconds]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
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
azimut has joined #ocaml
xgqt has quit [Ping timeout: 248 seconds]
xgqt has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
mro has quit [Quit: Leaving...]
vicfred has joined #ocaml
bartholin has quit [Quit: Leaving]
waleee has joined #ocaml
rgrinberg has joined #ocaml
<d_bot> <Patate> having trouble finding a naming rule for C constants bindings for ocaml.
<d_bot> <Patate> I usually do the folowing. Convert the enum name to a prefix (`myEnumName` becomes `MY\_ENUM\_NAME\_`)
<d_bot> <Patate> Then I take this prefix off the values names (`MY_ENUM_NAME_VALUE1` becomes `VALUE1`)
<d_bot> <Patate> Problem is somtimes I have something like `MY_ENUM_NAME_64`... And as one might guess, `64` is not a valid constructor name...
Haudegen has joined #ocaml
<d_bot> <Patate> I would like to find a nice way to handle these cases, other that writing the full name, as it is cool to write MyEnumName.VALUE1 rather than MyEnumName.MY_ENUM_NAME_VALUE1
<d_bot> <Patate> How would you do it?
<d_bot> <sirverik> any idea what happened to my utop?
<d_bot> <sirverik> was working fine until I did a print line and quit
<d_bot> <sirverik> is this punishment for using sideeffects?
<d_bot> <sirverik> T_T
<d_bot> <Patate> What is the problem? when you launch it, it is stuck?
<d_bot> <sirverik> yep
<d_bot> <sirverik> tried apt purge and reinstall
<d_bot> <Patate> weird... it does not respond to anything?
<d_bot> <sirverik> recently installed merlin
<d_bot> <sirverik> had to apt install m4 to be able to get opam-depext to install merlin
<d_bot> <sirverik> my ubuntu is a bit old
<d_bot> <sirverik> 18.04
<d_bot> <octachron> I would propose to switch to an opam-managed version of OCaml to get a more recent version.
<d_bot> <octachron> But you can also try to delete local utop files: `.utop-history`
<d_bot> <sirverik> ok that sounds like a good idea
<d_bot> <sirverik> I'll try it later
<d_bot> <sirverik> thanks!
<d_bot> <octachron> and `.utoprc`
<d_bot> <octachron> and `~/.config/utop` if it exists
aspe has joined #ocaml
aspe has quit [Quit: aspe]
cross has quit [Quit: leaving]
cross has joined #ocaml
cross has quit [Client Quit]
cross has joined #ocaml
cross has quit [Client Quit]
cross has joined #ocaml
<d_bot> <Patate> I would love to have someone's advice on this.
<d_bot> <Patate>
<d_bot> <Patate> I would like to automatically translate a C enum like
<d_bot> <Patate> ```C
<d_bot> <Patate> enum VeryLongEnumNameType {
<d_bot> <Patate> VERY_LONG_ENUM_NAME_TYPE_2D,
<d_bot> <Patate> VERY_LONG_ENUM_NAME_TYPE_3D,
<d_bot> <Patate> VERY_LONG_ENUM_NAME_TYPE_CUBE
<d_bot> <Patate> };
<d_bot> <Patate> ```
<d_bot> <Patate> to
<d_bot> <Patate> ```ocaml
<d_bot> <Patate> type very_long_enum_name_type = 2D | 3D | Cube
<d_bot> <Patate> ```
<d_bot> <Patate> so it is shorter, but as you might expect, constructor cannot start with '2' or '3'.
<d_bot> <Patate> thought of converting to TwoD and ThreeD, but there are many places with other values than 2 or 3...
<d_bot> <Patate> What exception to the "delete enum's name prefix" could I make when there is a numerical value, so that it stays short and cool?
<d_bot> <octachron> Since Vulkan mostly use `2D` and `3D`, why not use `D3` and `D2`?
<companion_cube> that looks a bit horrible :D
<d_bot> <octachron> (Since anyway you will need special rule to recognize those tokens in the context where Vulkan use CamlCaseWithAMDExceptions)
<d_bot> <Patate> Thought of that, but ther is also another annoying case
<d_bot> <undu> maybe `Type_2D | Type_3D | Type_Cube`?
<d_bot> <Patate> As I also remove BIT and FlagBits suffixes, this
<d_bot> <Patate> ```C
<d_bot> <Patate> typedef enum VkSampleCountFlagBits {
<d_bot> <Patate> VK_SAMPLE_COUNT_1_BIT = 0x00000001,
<d_bot> <Patate> VK_SAMPLE_COUNT_2_BIT = 0x00000002,
<d_bot> <Patate> VK_SAMPLE_COUNT_4_BIT = 0x00000004,
<d_bot> <Patate> VK_SAMPLE_COUNT_8_BIT = 0x00000008,
<d_bot> <Patate> ...
<d_bot> <Patate> }
<d_bot> <Patate> ```
<d_bot> <Patate> leads to
<d_bot> <Patate> ```ocaml
<d_bot> <Patate> type sampleCount = 1 | 2 | 4 | 8
<d_bot> <Patate> ```
<d_bot> <Patate> just leaving last word before
<d_bot> <undu> yeah, could that work?
<d_bot> <Patate> Sure
<d_bot> <NULL> `type sampleCount = x1 | x2 | x4 | x8`
<d_bot> <undu> that can't be automated, though
<d_bot> <Patate> Would you find it nice?
<d_bot> <Patate> ```ocaml
<d_bot> <Patate> type sampleCount = Count_1 | Count_2 | Count_4 | Count_8
<d_bot> <Patate> ```
<d_bot> <Patate> It sure can
<d_bot> <NULL> Meh
<d_bot> <Patate> 😆 Thats why I am struggling
<d_bot> <Patate> every option seems "meh" to me xD
<d_bot> <Patate> I like how I did not talk about vulkan ^^
<d_bot> <undu> the VK is telling
<d_bot> <undu> ah, no
<d_bot> <NULL> When will we be able to locally override the behaviour of ints ? (Probably unreasonable)
<d_bot> <Patate> probably
<d_bot> <octachron> For FlagsBits the issue is that there are indices for bit sets. So you will have to handle them specially anyway.
<d_bot> <Patate> Sure, but I thought of using sum types for them too... no?
<d_bot> <NULL> Imagine opening `Float` and everything numerical is float
<d_bot> <Patate> oof
<d_bot> <octachron> No, there is too much impedance mismatch. You want to have an efficient `mem` function.
<d_bot> <octachron> @NULL you can already redefine the algebraic operators, then you only have to add `.` to literals.
<d_bot> <Patate> or have a regexp do it for you 😛
<d_bot> <Patate> Not sure to know what you mean...
<d_bot> <Patate> Ctypes' enums convert sum type constructor to int64 constants, so in the end you just + them and put them in the function call/data structure... right?
<companion_cube> that'd be kind of useful for zarith, I must say :p
mbuf has quit [Quit: Leaving]
<d_bot> <NULL> Won't your `C1 C2 C4 C8` be translated into `0 1 2 3` ?
<d_bot> <Patate> yes
<d_bot> <Patate> Would have somthing like
<d_bot> <Patate> ```ocaml
<d_bot> <Patate> use [ Option_toto; Option_tata ]
<d_bot> <Patate> ```
<d_bot> <Patate> under the hood, it knows Option_toto = 5, Option_tata = 78, and + them
<d_bot> <Patate> Would have somthing like
<d_bot> <Patate> ```ocaml
<d_bot> <Patate> use [ Option_toto; Option_tata ]
<d_bot> <Patate> ```
<d_bot> <Patate> under the hood, it knows Option_toto = 8, Option_tata = 64, and + them
<d_bot> <Patate> so the C implementation of use receives (8 | 64)
<d_bot> <octachron> Why not use directly `a <+> b` on the OCaml side? Since you can't pattern match on sets of flags, having constructors rather than private ints doesn't bring much to the table.
<d_bot> <Patate> ...
<d_bot> <Patate> yes
<d_bot> <Patate> And I can do it without much of a hassle, as they all end with -FlagBits.
<d_bot> <Patate> The problem is that I would have liked it to work, potentially on other headers than vulkan's... So using consistent rules not depending on the API conventions would have been nice...
<d_bot> <octachron> It is not really possible, semantics is always coded using side-channel in C.
<d_bot> <octachron> You could define a system of plugins/extensions that could be enabled or disabled depending on the C source conventions.
<d_bot> <Patate> Yes, thought about that
<d_bot> <Giorgi> yo guys , how can i filter out list of tuples [(1,1.5,3);(3,3.3,4)] to remove non integer values and turn everything into a single list like this? [1,3,3,4]
<d_bot> <Giorgi> do i use List.filter for that?
<d_bot> <Patate> what have you got so far?
<d_bot> <NULL> Since you have to know the types at compile time, you can't be smarter than just putting the ints manually
<d_bot> <Patate> he seems to have (int * float * int) list
<d_bot> <Giorgi> min
<d_bot> <Patate> that means for exemple the information that this particular enum corresponds to bits is not explicit?
<d_bot> <Patate> no
<d_bot> <Patate> filter removes elements from your list, it would remove whole tuples.
<d_bot> <Patate> you can remove one element in the tuple, for every tuple in your list
<d_bot> <Giorgi> do i need to specify list type?
<d_bot> <NULL> You don't
<d_bot> <Patate> you give it (int * float * int), but your pattern matches (int * float) values
<sleepydog> you're not building a list here, you're just searching for the first round number
<sleepydog> also what Patate said
<d_bot> <Giorgi> okay i give up
<d_bot> <Giorgi> ty all
<d_bot> <NULL> How unsatisfying
<d_bot> <Patate> Thanks @undu @octachron @NULL (hope I did not miss someone), I will continue to search for a way that doen't seem too "meh" to me
<d_bot> <Patate> @Giorgi try your function with [(1.5, 3); (3.3, 4)] instead
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <octachron> Oh, my code generator worked with the last version of Vulkan specification without code change. I don't remember the last time that this has happened.
vshender has joined #ocaml
vshender has quit [Client Quit]
wingsorc has joined #ocaml
<d_bot> <ec> Can I capture the *rest* of the polyvars in a signature like this?
<d_bot> <ec>
<d_bot> <ec> ```ocaml
<d_bot> <ec> val f : ('v, [> `A of 'x]) result
<d_bot> <ec> -> ('v, 'x, [> _THE_REST_HERE]) result
<d_bot> <ec> ```
<d_bot> <ec> By which I mean … if the input argument has ``[`A, `B, `C]``, I want to capture `` `A`` in one way, and the rest in another way.
rgrinberg has joined #ocaml
wingsorc has quit [Remote host closed the connection]
wingsorc has joined #ocaml
wingsorc has quit [Client Quit]
wingsorc has joined #ocaml
gravicappa has quit [Ping timeout: 252 seconds]
<d_bot> <octachron> No, this is not possible with OCaml polymorphic variants.
vshender has joined #ocaml
vshender has quit [Quit: rcirc on GNU Emacs 28.1]
<d_bot> <ec> hm. okay. that's unfortunate. the closest I could get was "lifting" my problem into a location with total knowledge of the variants — so they aren't actually polymorphic anymore — and using something like:
<d_bot> <ec> ```ocaml
<d_bot> <ec> val f : ('v, [`A of 'x | Module.all_the_others]) result
<d_bot> <ec> -> ('v, 'x, [> Module.all_the_others]) result
<d_bot> <ec> ```
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
birdgoose has joined #ocaml
olle has quit [Ping timeout: 256 seconds]
olle has joined #ocaml
Tuplanolla has joined #ocaml
olle has quit [Ping timeout: 246 seconds]
jpds has quit [Remote host closed the connection]
Haudegen has quit [Ping timeout: 276 seconds]
jpds has joined #ocaml
motherfsck has quit [Quit: quit]
motherfsck has joined #ocaml
tiferrei has quit [Ping timeout: 240 seconds]
tiferrei has joined #ocaml
rgrinberg has joined #ocaml
tiferrei has quit [Ping timeout: 240 seconds]
tiferrei has joined #ocaml
tiferrei has quit [Ping timeout: 240 seconds]
perrierjouet has quit [Quit: WeeChat 3.5]
tiferrei has joined #ocaml
perrierjouet has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
dhil has quit [Ping timeout: 252 seconds]
tiferrei has quit [Ping timeout: 240 seconds]
tiferrei has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]