adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.06.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.06/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
hdon has joined #ocaml
hdon has quit [Ping timeout: 264 seconds]
<Dairyfarm> Well, it worked.
<Dairyfarm> But ffmpeg, which was what I wanted to use with liquidsoap won't compile.
<Dairyfarm> Awesome, I don't think I needed the ffmpeg plugin anyways.
<Dairyfarm> Thanks tizoc.
hdon has joined #ocaml
infinity0_ has joined #ocaml
infinity0_ has quit [Changing host]
infinity0 is now known as Guest90917
infinity0_ has joined #ocaml
Guest90917 has quit [Killed (weber.freenode.net (Nickname regained by services))]
infinity0_ is now known as infinity0
<tizoc> Dairyfarm: cool, glad it worked
silver_ has joined #ocaml
silver has quit [Ping timeout: 268 seconds]
cbot has joined #ocaml
silver_ is now known as silver
pmetzger has quit []
<hdon> hi all :) is it possible to index collections by constructors? in C when using tagged unions (which aren't type-safe and require programmer discipline to ensure they are used safely) my tags (using enums) are also integers, which means i can use them as keys for arrays or other kinds of collections. further, i can count them by simply adding a tag like TAG_COUNT as the last item in my enum and perform
<hdon> arithmetic on the cardinality of my types which is useful for dimensioning collections whose storage requirements or shapes are related to the cardinality of my types. any advice here for an ocaml newb?
<hdon> a contrived example: suppose my students follow a dress code. shirts can be black or white, pants can be black, white, or beige. i want a representation of outfit frequency with O(1) access. pseudo code: enum Pants { Black, White, Beige, PantsMax }; enum Shirts { Black, White, ShirtsMax }; int outfitFreq[PantsMax*ShirtsMax]; int get(shirt, pants) { return outfitFreq[pants+shirt*PantsMax]; }
<hdon> one solution could be to write converter functions: type shirt = BlackShirt | WhiteShirt; type pants = BlackPants | WhitePants | BeigePants; let shirtColorCount = 2; let pantsColorCount = 3; let shirtToInt = (x:shirt) = fn | WhiteShirt => 0 | BlackShirt => 1; let pantsToInt (x:pants) = fn | WhitePants => 0 | BlackPants => 1 | BeigePants => 2; /* etc */
<hdon> but that means more typing and room for mistakes :)
<pierpa> You could use a hash table indexed by (shirt,pants)
<pierpa> no need to convert to an integer index
<hdon> pierpa: hash table doesn't have O(log(n)) lookup time and hashing overhead?
<pierpa> no
<hdon> oh cool
<pierpa> hash tables are O(1). That's the their point :)
zolk3ri has quit [Remote host closed the connection]
<pierpa> yes
<hdon> thanks
<pierpa> yw
<hdon> where can i find the source code for Hashtbl module?
<pierpa> they are in the standard library, so the normal ocaml distribution, I think.
<hdon> mmm thanks
<hdon> pierpa: gracias :)
<pierpa> de nada
<hdon> so, IIUC, lookup time with this will be nearly constant, because buckets will tend to hold no more than one key-value pair?
<pierpa> more or less. To be precise, lookup time is O(1).
<pierpa> in practice, it is fast enough, you don't need to worry.
<hdon> can constructors place limits on the values of their arguments beyond their number and types?
unyu has quit [Quit: The end of the world is nigh. Bring as much popcorn as you can!]
dtornabene has joined #ocaml
dtornabene has quit [Read error: Connection reset by peer]
dtornabene has joined #ocaml
sh0t has joined #ocaml
hdon has quit [Ping timeout: 264 seconds]
unyu has joined #ocaml
_xvilka_ has quit [Ping timeout: 268 seconds]
silver has quit [Read error: Connection reset by peer]
TheRuralJuror has quit [Remote host closed the connection]
tormen has joined #ocaml
isd has quit [Quit: Leaving.]
jbrown has quit [Ping timeout: 248 seconds]
tormen_ has quit [Ping timeout: 248 seconds]
<pierpa> AFAIK, no.
mfp has quit [Ping timeout: 248 seconds]
nomicflux has quit [Quit: nomicflux]
shinnya has quit [Ping timeout: 240 seconds]
iitalics has joined #ocaml
zlsyx has joined #ocaml
cbot has quit [Ping timeout: 260 seconds]
sh0t has quit [Remote host closed the connection]
cbot has joined #ocaml
cbot_ has joined #ocaml
pierpa has quit [Quit: Page closed]
cbot has quit [Ping timeout: 256 seconds]
hdon has joined #ocaml
jimmyrcom has quit [Ping timeout: 276 seconds]
hdon has quit [Ping timeout: 264 seconds]
hdon has joined #ocaml
pierpal has quit [Ping timeout: 276 seconds]
pierpal has joined #ocaml
govg has joined #ocaml
iitalics has quit [Quit: WeeChat 2.1]
marxS has joined #ocaml
<marxS> hi
hdon has quit [Ping timeout: 240 seconds]
hdon has joined #ocaml
malina has quit [Ping timeout: 276 seconds]
slash^ has joined #ocaml
caltelt has quit [Ping timeout: 240 seconds]
zv has joined #ocaml
govg has quit [Ping timeout: 268 seconds]
govg has joined #ocaml
cbot_ has quit [Quit: Leaving]
shinnya has joined #ocaml
hdon has quit [Ping timeout: 248 seconds]
letoh has quit [Ping timeout: 264 seconds]
hdon has joined #ocaml
kakadu has joined #ocaml
marxS has quit [Quit: Leaving]
letoh has joined #ocaml
nicolasbourdon has joined #ocaml
nicolasbourdon has left #ocaml [#ocaml]
hdon has quit [Ping timeout: 240 seconds]
hdon has joined #ocaml
hdon has quit [Ping timeout: 240 seconds]
hdon has joined #ocaml
hdon has quit [Ping timeout: 248 seconds]
argent_smith has joined #ocaml
mcspud has quit [Ping timeout: 265 seconds]
zlsyx has quit [Remote host closed the connection]
mcspud has joined #ocaml
GreyFaceNoSpace has joined #ocaml
pierpal has quit [Ping timeout: 268 seconds]
pierpal has joined #ocaml
hdon has joined #ocaml
govg has quit [Ping timeout: 248 seconds]
govg has joined #ocaml
tarptaeya has joined #ocaml
hdon has quit [Ping timeout: 260 seconds]
kakadu has quit [Ping timeout: 240 seconds]
kakadu has joined #ocaml
jnavila has joined #ocaml
zlsyx has joined #ocaml
mfp has joined #ocaml
zolk3ri has joined #ocaml
gareppa has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
gareppa has quit [Quit: Leaving]
jnavila has quit [Ping timeout: 240 seconds]
gareppa has joined #ocaml
gareppa has quit [Remote host closed the connection]
gareppa has joined #ocaml
gareppa has quit [Remote host closed the connection]
gareppa has joined #ocaml
dtornabene has quit [Remote host closed the connection]
jnavila has joined #ocaml
gareppa has quit [Quit: Leaving]
<kakadu> Hey, Drup. Which version of z3 should I have to link with z3overlay?
* kakadu has some linking errors using z3 4.4.1
gareppa has joined #ocaml
Haudegen has joined #ocaml
magicbit has joined #ocaml
gareppa has quit [Quit: Leaving]
nomicflux has joined #ocaml
silver has joined #ocaml
steenuil_ has joined #ocaml
nomicflux has quit [Quit: nomicflux]
steenuil has quit [Ping timeout: 268 seconds]
jnavila has quit [Ping timeout: 260 seconds]
Dairyfarm has quit [Remote host closed the connection]
ratsch has quit [Remote host closed the connection]
ratsch has joined #ocaml
malina has joined #ocaml
steenuil_ is now known as steenuil
sh0t has joined #ocaml
pierpal has quit [Ping timeout: 264 seconds]
shinnya has quit [Ping timeout: 240 seconds]
moolc has joined #ocaml
Guest32984 is now known as andreypopp
sh0t has quit [Remote host closed the connection]
kakadu has quit [Ping timeout: 240 seconds]
argent_smith has quit [Quit: Leaving.]
kakadu has joined #ocaml
zlsyx has quit [Remote host closed the connection]
nomicflux has joined #ocaml
letoh has quit [Ping timeout: 240 seconds]
Soni has quit [Quit: Leaving]
ygrek has joined #ocaml
Soni has joined #ocaml
jbrown has joined #ocaml
letoh has joined #ocaml
al-damiri has joined #ocaml
mengu has joined #ocaml
<Drup> kakadu: hmm, can you report ?
pzp has joined #ocaml
nomicflux has quit [Quit: nomicflux]
jimmyrcom has joined #ocaml
nomicflux has joined #ocaml
nomicflux has quit [Quit: nomicflux]
moolc has left #ocaml ["ERC (IRC client for Emacs 27.0.50)"]
<kakadu> Drup: I actually think it is not a problem of z3overlay but a problem of z3 opam package. Don't worry, it seems that it should be a problem companion_cube :) https://github.com/ocaml/opam-repository/issues/11882
<kakadu> of*
<companion_cube> I suppose it's a problem of LD_LIBRARY_PATH
<kakadu> why?
<companion_cube> ah wait
<companion_cube> the z3 package on opam comes with its own z3
<companion_cube> afair it doesn't use the system z3
<companion_cube> but if you don't setup LD_LIBRARY_PATH (or sth like that) properly you'd be linking against your old 4.4.1
<kakadu> Oh....
<companion_cube> it takes a while to compile, right?
<kakadu> I looked at opam install command and thought that it installs only the bingings
<kakadu> bindings*
<companion_cube> hmm
<kakadu> you obviously do some install preparation in the build script
<companion_cube> no, it builds everything
<kakadu> It seems that opam really installs new z3
<companion_cube> if you look in the opam dir, you should see a libz3.so
sh0t has joined #ocaml
mengu has quit [Remote host closed the connection]
zlsyx has joined #ocaml
zlsyx has quit [Ping timeout: 264 seconds]
sh0t has quit [Remote host closed the connection]
sh0t has joined #ocaml
mengu has joined #ocaml
mengu has quit [Ping timeout: 256 seconds]
keep_learning has quit [Ping timeout: 260 seconds]
mengu has joined #ocaml
mengu_ has joined #ocaml
mengu has quit [Remote host closed the connection]
pierpal has joined #ocaml
pzp has quit [Quit: Connection closed for inactivity]
hdon has joined #ocaml
pierpal has quit [Ping timeout: 248 seconds]
zlsyx has joined #ocaml
hdon has quit [Ping timeout: 260 seconds]
pierpal has joined #ocaml
<kakadu> Drup: you probably already *kow* :) about this but decided not to fix and not break the compatibility https://github.com/termite-analyser/z3overlay/blob/master/src/zZ3_sigs.ml#L160
pierpal has quit [Ping timeout: 264 seconds]
pierpa has joined #ocaml
pierpal has joined #ocaml
zlsyx has quit [Remote host closed the connection]
mengu_ has quit [Remote host closed the connection]
jnavila has joined #ocaml
hdon has joined #ocaml
<Drup> kakadu: ugh
<Drup> no, I didn't
<Drup> given the fact that z3overlay was never formally release, I don't care about compatibility
muelleme has joined #ocaml
gareppa has joined #ocaml
nicoo has quit [Read error: Connection reset by peer]
gareppa has quit [Quit: Leaving]
nicoo has joined #ocaml
muelleme has quit [Ping timeout: 240 seconds]
gareppa has joined #ocaml
zlsyx has joined #ocaml
gareppa has quit [Remote host closed the connection]
zlsyx has quit [Ping timeout: 240 seconds]
dxtr has quit [Ping timeout: 276 seconds]
jnavila has quit [Ping timeout: 240 seconds]
jnavila has joined #ocaml
mengu has joined #ocaml
GreyFaceNoSpace has quit [Quit: Ex-Chat]
hdon has quit [Ping timeout: 260 seconds]
exarkun has quit [Read error: Connection reset by peer]
sh0t has quit [Remote host closed the connection]
jnavila has quit [Ping timeout: 276 seconds]
hdon has joined #ocaml
exarkun has joined #ocaml
bairui_ has joined #ocaml
bairui has quit [Read error: Connection reset by peer]
steenuil has quit [Remote host closed the connection]
mengu has quit [Remote host closed the connection]
jnavila has joined #ocaml
jnavila has quit [Remote host closed the connection]
Haudegen has quit [Ping timeout: 260 seconds]
pierpal has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
zlsyx has joined #ocaml
mengu has joined #ocaml
argent_smith has joined #ocaml
hdon has quit [Ping timeout: 240 seconds]
zlsyx has quit [Remote host closed the connection]
bairui_ is now known as bairui
tarptaeya has quit [Ping timeout: 260 seconds]
tarptaeya has joined #ocaml
hdon has joined #ocaml
hdon has quit [Ping timeout: 255 seconds]
tarptaeya has quit [Quit: Konversation terminated!]
govg has quit [Ping timeout: 264 seconds]
zv has quit [Ping timeout: 240 seconds]
govg has joined #ocaml
zv has joined #ocaml
hdon has joined #ocaml
hdon has quit [Changing host]
hdon has joined #ocaml
govg has quit [Ping timeout: 240 seconds]
<hdon> hi all :) is it possible for variant constructors to constrain their arguments beyond type? pseudo-code illustration: type pet = Dog(numLegs:int) when numLegs <= 4
govg has joined #ocaml
<thizanne> hdon: no
<hdon> oh. what options are available for me? wrap the constructor in a function?
<thizanne> probably
<hdon> mmm thanks thizanne
<mrvn> make the constructor private with a function that checks for numLegs <= 4 and creates one.
<thizanne> abstract the type away, provide functions that create values of this type, and make sure that your functions enforce your invariant
<hdon> mmm good thinking. thanks both!
<mrvn> type private pet = Dog of int has the benefit that anyone can read the number of legs but only your function can create a Dog.
silver has quit [Read error: Connection reset by peer]
<mrvn> type numLegs = One | Two | Three or Four is also an option
<hdon> mrvn: mmm... good point mrvn. i do end up writing a lot of intOfNumLegs and numLegsOfInt sort of functions though :3
<mrvn> yep.
<companion_cube> you can also write a private record and use the field directly
<companion_cube> type dog = private {legs: int}
<thizanne> it's hard to tell what the actual right solution of your problem is without knowing more about your problem than needing to be able to cut off dogs' legs
<mrvn> you might also have 1/2 eyes, 1/2/3 heads, bool thumbs / claws / hooves.
* hdon nods
<mrvn> If you have a bunch of those then a record or object is the way to go
<mrvn> object if you have cats, dogs, sheep, ...
<mrvn> Ocaml could really use a type t = SmallInt of 5; I've needed that often.
<companion_cube> problem is decidability of type checking, as always
<mrvn> companion_cube: should be just as difficult as type numLegs = One | Two | Three | Four.
<companion_cube> you could do with runtime assertions inserted by the compiler, of course, but that's not a trivial decision to make
<mrvn> fun x y -> SmallInt (x + y) would be a problem.
<companion_cube> worse: fun x y -> SmallInt (x * y)
<thizanne> sounds like a ppx could actually do this
<mrvn> thizanne: doing that with runtime checks would be doable.
<thizanne> or just translating [%smallint 5] to `Five
<mrvn> thizanne: yep. That would limit everything to literals. No (x + y) possible.
<mrvn> Often that's enough.
<thizanne> and having a smallint + that either does runtime checking or does `Tree + `Four = `Five
<mrvn> If you do the later then you might as well just have a constuctor function that checks the invariant.
<mrvn> well, except for match legs with 0 | 1 | 2 | 3 -> "cripple" | 4 -> "healthy"
<mrvn> Transforming to `Number would do range checking.
<mrvn> thizanne: let me know when you have a [%smallint x] ppx :)
<thizanne> I won't
<mrvn> :(
<thizanne> but that does seem like something you could have
<thizanne> (or just a module)
<companion_cube> or you can use ppx_deriving with `type t = One | Two | Three | Four` to at least have the int conversion
kakadu has quit [Remote host closed the connection]
<companion_cube> assert (x <= M.upto); ? :p
<thizanne> shh
<companion_cube> ah, well, different behavior
<companion_cube> yours works in nondebug
<companion_cube> should be invalid_arg anyway
<thizanne> yes you should actualy have a proper exception
<companion_cube> in this case Invalid_arg is fine, I think
isd has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
pierpal has joined #ocaml
pierpal has quit [Ping timeout: 240 seconds]
zlsyx has joined #ocaml
mengu has quit [Remote host closed the connection]
hdon has quit [Ping timeout: 248 seconds]
wagle has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
wagle has joined #ocaml
nomicflux has joined #ocaml
sh0t has joined #ocaml
hdon has joined #ocaml