<mcc>
usually when i am trying to understand something in ocaml, i've referred to that Real World Ocaml book, but they don't … seem? to have a bit on this feature
<mcc>
i get the sense this was something that was added recently
<mcc>
algabraic data types. do the types, with sum and product, actually form an algebra?
<dmbaturin>
mcc: Seems so. Bottom is the identity element.
ghostpl_ has quit [Ping timeout: 245 seconds]
rgrinberg has quit [Quit: Leaving.]
<mcc>
what is bottom type in ocaml? unit?
rgrinberg has joined #ocaml
bytbox has quit [Ping timeout: 240 seconds]
<dmbaturin>
I'm just starting with type theory though, so I can't be sure if things I say are correct yet. :)
<mcc>
ok
<dmbaturin>
mcc: No, bottom is a type with no values at all. I'm not sure one can express it in ML explicitly.
<mcc>
ok
<mcc>
wp says its for nonreturning functions
<mcc>
so... 'a?
<dmbaturin>
Maybe a type that is left abstract and not defined anywhere can count as it. But since it has no values, a sum type with bottom should be equivalent to the original type.
<mcc>
ok
<dmbaturin>
Well, 'a is not a type, it's a variable that may mean any concrete type.
<dmbaturin>
Also, what exactly you mean by algebra? :)
hilquias` has joined #ocaml
<mcc>
i mean like, is it an associative algebra, is it a ring, is it anything
<mcc>
i see a set and two operations so i'm curious
<dmbaturin>
...a tuple of anything with bottom can't be created, so apparently the bottom is the identity element for product types too.
<dmbaturin>
Since it has no values like the bottom and can be considered equivalent to it.
<mcc>
hm ok
<dmbaturin>
mcc: Field and ring people use the word "algebra" for some specific structure, but I forgot what it was.
<mcc>
nod
<dmbaturin>
I'm not sure if ('a, 'b) and ('b, 'a) can be considered equivalent.
<dmbaturin>
But what we made up so far looks like a ring it seems.
<mcc>
hm, ok
<mcc>
stuff in aa is typically not commutative unless u ask for it
<mcc>
commutative ring would be an abelian ring
<dmbaturin>
Sum types are probably commutative though. Foo of 'a | Bar of 'b can have all the values as Bar of 'b | Foo of 'a.
hilquias` has quit [Remote host closed the connection]
<mcc>
in this article. they use the syntax type a. a expr' -> a
<mcc>
ok so the a is a type variable, i get that
<mcc>
… what the heck is the period?
<mcc>
"type a ."is that just… what you do that?
<mcc>
there?
<dmbaturin>
Good question. I took it as magic required in signatures when you use GADTs.
bjorkintosh has joined #ocaml
<dmbaturin>
Perhaps we'll have to wait for the language lawyers to wake up. :)
bjorkintosh has quit [Ping timeout: 246 seconds]
<mcc>
heh
<mcc>
alas, i think i will fall asleep
<dmbaturin>
Well, there's a mailing list too.
<mcc>
oo
mcc has quit [Quit: battery dying sry]
rgrinberg has quit [Quit: Leaving.]
ggole has joined #ocaml
Jefffrey has quit [Remote host closed the connection]
ghostpl_ has joined #ocaml
ghostpl_ has quit [Ping timeout: 250 seconds]
rgrinberg has joined #ocaml
reem has quit [Remote host closed the connection]
reem has joined #ocaml
_pakchoi_ops has joined #ocaml
laughing-octo-sh has joined #ocaml
MercurialAlchemi has joined #ocaml
oscar_toro has quit [Quit: Lost terminal]
rgrinberg has quit [Quit: Leaving.]
_pakchoi_ops has quit [Quit: No Ping reply in 180 seconds.]
rgrinberg has joined #ocaml
_pakchoi_ops has joined #ocaml
matason has joined #ocaml
laughing-octo-sh has quit [Ping timeout: 252 seconds]
matason has quit [Ping timeout: 256 seconds]
ebzzry has quit [Remote host closed the connection]
manud has joined #ocaml
ebzzry has joined #ocaml
rgrinberg has quit [Quit: WeeChat 1.1.1]
rgrinberg has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ebzzry has quit [Remote host closed the connection]
ebzzry has joined #ocaml
ebzzry has quit [Remote host closed the connection]
axiles has quit [Quit: Quitte]
Haudegen has quit [Ping timeout: 245 seconds]
larhat has joined #ocaml
Haudegen has joined #ocaml
matason has joined #ocaml
matason has quit [Client Quit]
Simn has joined #ocaml
bjorkintosh has joined #ocaml
reem has quit [Remote host closed the connection]
axiles has joined #ocaml
reem has joined #ocaml
ghostpl_ has joined #ocaml
MercurialAlchemi has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
ghostpl_ has quit [Ping timeout: 252 seconds]
manud has quit [Quit: manud]
manud has joined #ocaml
Nahra has quit [Remote host closed the connection]
reem has quit [Remote host closed the connection]
reem has joined #ocaml
rgrinberg has quit [Ping timeout: 256 seconds]
magthe has joined #ocaml
<magthe>
any Archlinux users around?
<adrien_znc>
just ask your question :) (I'm not one but there are several here)
zpe has joined #ocaml
reem has quit [Remote host closed the connection]
<magthe>
am I supposed to be able to successfully run `opam install core utop` using ocaml from extra?
reem has joined #ocaml
<magthe>
I thought I would, but didn't... first issuing `opam switch 4.02.1`, and then `opam install core utop` worked fine though, but then I have ocaml 4.02.1 installed both on the system level and locally as my user, right?
<ggole>
I think that depends on how you configured/installed opam
_pakchoi_ops has quit [Ping timeout: 245 seconds]
<dmbaturin>
magthe: Generally, this can work. I did use opam with the compiler from the repos, although not on arch.
maufred has quit [Remote host closed the connection]
matason has joined #ocaml
maufred has joined #ocaml
<magthe>
ggole: installed it from AUR
Submarine has joined #ocaml
Submarine has joined #ocaml
<magthe>
the first complaint was when compiling camlp4 -- I was told to install it system wide, so after grabbing that from extra too I got a little further
<magthe>
then I got stuck on herelib
<magthe>
it's not a big deal, just surprising
<whitequark>
herelib? hm
ghostpl_ has joined #ocaml
reem has quit [Remote host closed the connection]
reem has joined #ocaml
dsheets_ has quit [Ping timeout: 264 seconds]
octachron has joined #ocaml
mort___ has joined #ocaml
<magthe>
whitequark: yupp, the error messages were not as helpful as with camlp4, so I gave up and switched to letting opam compile ocaml too
manud has quit [Quit: manud]
manud has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Ping timeout: 250 seconds]
Kakadu has joined #ocaml
dav has quit [Ping timeout: 252 seconds]
dav has joined #ocaml
dsheets_ has joined #ocaml
ddosia has joined #ocaml
antkong_ has joined #ocaml
yomimono has joined #ocaml
manud has quit [Quit: manud]
reem has quit [Remote host closed the connection]
MercurialAlchemi has quit [Remote host closed the connection]
<magthe>
I'm playing around with functors for the first time, I do get it all to work when I put all stuff, module sigs and implementation in a single .ml file, but when I try to put the sigs in a separate .mli it all breaks down... all examples I find either do like I've done, on single file, or use ocaml interactively (Real World OCaml), any pointers to examples of splitting sigs and structs of functors into separate
<magthe>
files?
ebzzry has quit [Remote host closed the connection]
ebzzry has joined #ocaml
bezirg has joined #ocaml
<whitequark>
can you post your existing code?
bezirg has quit [Client Quit]
bezirg has joined #ocaml
<ggole>
Functors in signatures look like module Foo (Arg : ArgSig) sig ... end
<ggole>
er, module Foo (Arg : ArgSig) : sig ... end
<ggole>
(You can also use the functor keyword, but who does that?)
<ggole>
Also, there's almost no difference between splitting things between an .ml and .mli and a struct ... end and sig ... end
<ggole>
So you can test your understanding using modules in a single file easily enough
segmond has quit [Ping timeout: 256 seconds]
rgrinberg has joined #ocaml
bezirg has quit [Quit: Leaving.]
<magthe>
ggole: yes, so far is all good... I *am* testing my understanding using modules in a single file... what I'd like now is to split into several files, and that's where I fail.
rgrinberg has quit [Ping timeout: 272 seconds]
<ggole>
Put the sig ... end bit in the .mli and the struct ... end bit in the .ml and you should be fine
segmond has joined #ocaml
<ggole>
If you run into trouble, we'll help you out - functors can be a bit head scratchy at first
<magthe>
ggole: I'll make a second attempt and see how far I get
<magthe>
ggole: putting the innards of a sig in a separate file is straight forward, but how do I get the `Arg` into the .ml file?
<magthe>
oh, I'll put some stuff in a pastebin to show, hold on
<magthe>
ggole: if I move the stuff between struct...end into a separate .ml, how do I get the info related to the sig etc (`module FuncTree (TE : TreeElement) : FT with type elt = TE.t = struct`) into it?
<magthe>
ggole: am I doing it all wrong?
<ggole>
No, we've been talking past each other a bit
<ggole>
I thought that you were wrapping all of this in a flat module
<magthe>
ggole: well, in a way that's what I'd like to do... but I don't se how I can
* magthe
has poor knowledge of ocaml syntax
Jefffrey has quit [Quit: Leaving...]
<ggole>
Uh, I'm not quite sure what you're asking now
<ggole>
You want to know how to write a .mli for what's there?
<ggole>
Or just split things up a bit?
ontologiae_ has joined #ocaml
<magthe>
ggole: let's start with just splitting it up a bit... I can put `TreeElement` "as is" into treeElement.mli... the same for `FT`
<magthe>
is there some way I can put `FuncTree` as a flat module into funcTree.ml?
paradoja has joined #ocaml
<ggole>
Not really
<magthe>
ggole: hmm, moving the innards of `TreeElement` into treeElement.mli didn't work that either... the compiler says that `TreeElement` isn't a type
<magthe>
so I'm guessing the `module type ...` has to live inside another module
dsheets_ has joined #ocaml
<ggole>
Yeah, when I said "the sig ... end in .mli and the struct ... end in .ml", I thought that you had module Foo : sig ... end = struct ... end and wanted to split it up
<ggole>
I would put the element type and functor impl in one file
<magthe>
in a single .ml?
<ggole>
Yeah
<ggole>
The stdlib does things that way
<magthe>
oki
<ggole>
It's somewhat standard to call the functor Make and the signature S, too
<ggole>
Set, Map and Hashtbl all follow this pattern
<magthe>
oki, I'll have a look-see
<magthe>
then the implementations of the various `TreeElements` can easily go in other places... but since they are `module type ...` they can't themselves be top-level modules?
<ggole>
No, implementations of the argument are just modules (and can be, and often are, top-level)
<magthe>
ah, oki... I'll try
bytbox has joined #ocaml
bytbox has quit [Read error: Connection reset by peer]
bytbox has joined #ocaml
dbp has quit [Ping timeout: 265 seconds]
<magthe>
ggole: ah, oki, that worked fine... and then the whole thing with `with type t = ...` isn't needed anymore... cute
jao has quit [Remote host closed the connection]
<magthe>
ggole: would one usually place the instantiation of the modules (in my case `module IntTree = FuncTree (TEInt)`) where `TEInt` is defined, or where `IntTree` is used?
<ggole>
You should still need the with type t = ... (although in this case I think it should be with type elt = ...)
ebzzry_ has joined #ocaml
<ggole>
Instantiations of the modules go wherever the user of your tree library wants them
huza has quit [Quit: WeeChat 0.3.8]
ebzzry has quit [Ping timeout: 256 seconds]
<magthe>
ggole: ah, yes the `type elt = ... ` is needed, but if I break out the various implementations of `TreeElement` I no longer need any `type t = ...` (here it really is `t`)
AltGr has left #ocaml [#ocaml]
<ggole>
Oh I see. Right, that isn't needed.
bytbox has quit [Remote host closed the connection]
<magthe>
ggole: is there some way of ensuring telling the compiler that I intend `TEInt` to implement the `FuncTree.TreeElement` type?
<magthe>
currently it's ad-hoc (AFAIU)
<companion_cube>
let _ = (module TEInt : FuncTree.TreeElement) <--- ugly hack, but should work
<magthe>
companion_cube: where do I put that... in tEInt.ml?
<ggole>
Pretty much, although just passing it to your functor will do the same job
<companion_cube>
magthe: maybe that could be a test
<companion_cube>
a kind of compile-time test, that is
<ggole>
magthe: no, it needs to be outside of that module, probably in another file
<magthe>
couldn't put it in tEInt.ml, that created a circular depency
<ggole>
(If TEInt is nested in a file you can just stick in in there, but that doesn't sound like it is the case.)
<magthe>
ggole: nope, it's not, at least not now... but it's good to know that's an option
rgrinberg has joined #ocaml
rgrinberg has quit [Ping timeout: 250 seconds]
<magthe>
ggole, companion_cube: thanks for the help!
<companion_cube>
no pb
<ggole>
My pleasure.
<magthe>
oh, BTW, I've requested #ocaml to be added to lpaste.net's list of rooms... I hope no one minds if it gets added
segmond has quit [Ping timeout: 250 seconds]
bytbox has joined #ocaml
<adrien_znc>
I don't see an issue with that, quite the contrary :)
bytbox has quit [Remote host closed the connection]
arj has joined #ocaml
arj has quit [Max SendQ exceeded]
arj has joined #ocaml
arj has quit [Max SendQ exceeded]
arj has joined #ocaml
arj has quit [Max SendQ exceeded]
arj has joined #ocaml
segmond has joined #ocaml
BitPuffin has joined #ocaml
BitPuffin has quit [Remote host closed the connection]
jbrown has quit [Remote host closed the connection]
reem has joined #ocaml
ontologiae_ has quit [Ping timeout: 244 seconds]
segmond has quit [Ping timeout: 256 seconds]
<magthe>
adrien_znc: my sentiment also... ocaml seemed suspiciously lacking from the list of FP languages in that list
<companion_cube>
great!
reem has quit [Ping timeout: 272 seconds]
<companion_cube>
maybe this could go in the topic, so that newcomers know where to paste their code
<adrien_znc>
poke an op :P
* companion_cube
pokes adrien_znc
<adrien_znc>
I'm not an op
<companion_cube>
I see that "adrien" set the topic last
<companion_cube>
assume your multiple persona, or show your true op power!
<adrien_znc>
different accounts
vanila has joined #ocaml
moviuro has quit [Quit: ZNC on a FreeBSD jail, from an Archlinux laptop and OpenBSD openVPN server... what else?]
<whitequark>
haha
<whitequark>
/tmp/ccfefYnN.o:(.data+0x1b20): undefined reference to `_glBindSampler::caml(void)'
BitPuffin has joined #ocaml
<whitequark>
symbol name that accidentally looks like mangled to demangler
<rks`>
:)
shinnya has joined #ocaml
segmond has joined #ocaml
<flux>
ocaml strives for better c++ compatibility I see
<flux>
or at least it strives to confuse c++ developers ;)
* companion_cube
thinks whitequark is playing fun games such as making C++ demangler and OCaml mangler interact
<whitequark>
that would be trivial to do
<whitequark>
did you know the C++ mangler can serialize pretty much entire C++ expression AST?
<companion_cube>
yes
<companion_cube>
I retweeted your tweet ;)
segmond has quit [Ping timeout: 255 seconds]
moviuro has joined #ocaml
<ia0>
what is the current state of inter-module optimization in caml?
<ia0>
it looks like it does some things
<ia0>
in particular it looks like it does what I always wanted "removing debug stuff from binary"
<flux>
is there a nice reference counting library for ocaml?
<companion_cube>
I'm not sure what that would look like? you mean, with manual increment and decrement?
<companion_cube>
better use a finalizer
paradoja has quit [Ping timeout: 256 seconds]
<hcarty>
companion_cube: I can file something formally if you'd like. I've only briefly looked at the code thought so I wasn't sure if I was missing something.
<companion_cube>
that's fine, I'll fix it
ned has joined #ocaml
<hcarty>
companion_cube: And hooray for discovered bugs!
<companion_cube>
\o/
<companion_cube>
it's not that easy to test this particular case...
ned is now known as Guest58527
<flux>
companion_cube, well, something that would come with with_resource rcdfile (fun rawfile -> .. ) that would increment and decrement the reference counter
<companion_cube>
but rcdfile would be an already opened file?
<flux>
possibly not. I think glib has functions that return objects with refcount 0, and then they are deleted when it reaches 0 -again- :)
octachron has quit [Quit: Leaving]
<companion_cube>
well, it must be very tedious to use
<hcarty>
Some kind of (let%use out = open_output_file outfile in e) extension would be nice to have but I'm not sure how it could be made generic without being ugly.
<flux>
I would really like that you could choose to not close the resource in the scope, though
<companion_cube>
flux: but then it could be closed arbitrarily far away
<companion_cube>
the only sure way is to use the GC's finalizer
<flux>
companion_cube, well, you wouldn't do that ;)
<companion_cube>
and the problem with that is that it can take some time before the file is closed
<hcarty>
flux: Why not stick with open_resource + close_resource in that case?
<companion_cube>
flux: I'd rather have uniqueness types, or something similar
<companion_cube>
^^
<flux>
companion_cube, yes, but we are not going to have uniqueness types :)
<companion_cube>
I know
<flux>
hcarty, well, they sort of still depend on the code being structured in a way that has a nice way to put them at
<companion_cube>
flux: I think that for most file uses, lexical scoping is enough
<flux>
for example, with Lwt you could perhaps pass a lock to another task or you might not
<flux>
well, I'll chime in the next time I'll actually miss them ;-)
<flux>
companion_cube, so why didn't your code use them :-)
paradoja has joined #ocaml
<flux>
well, I forgive you, you were implementing them ;-)
<flux>
but nevertheles it sort of annoys that one needs to have a scoped accessor for all kinds of different resources, instead of building on the concept of 'resource' and 'scoped access'
<companion_cube>
sure, but there's no way for the type system to track resources
<companion_cube>
in OCaml, I mean
<ggole>
You can write try_finalize easily enough though
<companion_cube>
unless you miserably fail like I did there
<ggole>
Ideally you would only write it once and use it N times for whatever resources you need
<companion_cube>
ggole: you can do it in OCaml, with finalizers
<ggole>
Finalizers may never run before you exhaust the available fds
<companion_cube>
cateches: the world is divided in 5 categories: 1/ people who don't use OCaml 2/ people who use Core 3/ people who use batteries 4/ people who use bare stdlib 5/ people who use stdlib+some bizarre extension of stdlib
<companion_cube>
ggole: well, that's the best a GC can guarantee, I think
<haesbaert>
are lwts preemptive ? I'm guessing not
<MercurialAlchemi>
companion_cube: what about people who use containers?
<companion_cube>
MercurialAlchemi: 5/ :p
<companion_cube>
def`: looks pretty cool
<MercurialAlchemi>
companion_cube: pff :)
<ggole>
You can have a wrapper that runs a GC and closes unreachable fds when the fds run out
<Algebr>
For imperative code, what a good way to get a else if, just do a match?
<cateches>
companion_cube: so I just kinda have to pick a camp for a project and deal with it
<ggole>
(Or more likely, well before then.)
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
<ggole>
Algebr: if you want else if, use else if?
<companion_cube>
cateches: well, yes
<companion_cube>
you can start with bare stdlib and then switch to batteries or 5/ easily, though
<whitequark>
haesbaert: neither lwt nor async
<haesbaert>
ah ok, that makes sense
<Algebr>
ggole: I mean an actual else if rather than a nested if condition
<cateches>
okay
<ggole>
What's the difference?
<Algebr>
just looks nicer.
<ggole>
O_o
<ggole>
Wait, are you indenting the second bit?
cateches has quit [Quit: Page closed]
<Algebr>
doing whatever ocp-indent does
<ggole>
It should indent it just like an "actual else if" (whatever that might be)
<ggole>
Ifs do get pretty ugly when you start needing blocks, but that's not really related
<Algebr>
but there isn't an actual C like else if or python elif in the actual ocaml lanuage right
rgrinberg has quit [Quit: WeeChat 1.1.1]
<ggole>
You just type else if and keep going
<ggole>
if foo then bar else if baz then quux else zonk
rgrinberg has joined #ocaml
segmond has quit [Ping timeout: 272 seconds]
<ggole>
Rather like C.
<whitequark>
there isn't an "else if" in the C grammar, I think
bitbckt has joined #ocaml
<ggole>
It's else <statement>
<Algebr>
ha, I just checked as well
<ggole>
elif rubs me the wrong way for some reason
lordkryss has joined #ocaml
<ggole>
(But not as much as reverse keywords, blech.)
bytbox has joined #ocaml
<Algebr>
what are reverse keywords?
<ggole>
When a construct is terminated with the keyword it begins with, reversed
<ggole>
if ... fi, case ... esac, etc
bytbox has quit [Remote host closed the connection]
<Algebr>
oh, yea, those are annoying
segmond has joined #ocaml
psy has quit [Read error: No route to host]
destrius has quit [Ping timeout: 272 seconds]
destrius has joined #ocaml
<struktured>
ggole: the only thing worse than xml tags is that
slash^ has joined #ocaml
travisbrady has quit [Quit: travisbrady]
struktured has quit [Ping timeout: 250 seconds]
rgrinberg has quit [Ping timeout: 264 seconds]
rgrinberg has joined #ocaml
ontologiae_ has joined #ocaml
badkins has quit [Read error: Connection reset by peer]
ontologiae_ has quit [Ping timeout: 246 seconds]
struktured has joined #ocaml
ned- has joined #ocaml
Guest58527 has quit [Ping timeout: 250 seconds]
bytbox has joined #ocaml
axiles has quit [Quit: Quitte]
struktured has quit [Ping timeout: 264 seconds]
swgillespie has joined #ocaml
bytbox has quit [Remote host closed the connection]
MercurialAlchemi has quit [Remote host closed the connection]
dbp has joined #ocaml
MercurialAlchemi has joined #ocaml
ned has joined #ocaml
ned is now known as Guest45468
ned- has quit [Ping timeout: 244 seconds]
ontologiae_ has joined #ocaml
JuggleTux has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
larhat has quit [Quit: Leaving.]
Guest45468 has quit [Ping timeout: 250 seconds]
jwatzman|work has joined #ocaml
planetlarg has quit [Quit: Ex-Chat]
bytbox has joined #ocaml
mort___ has quit [Ping timeout: 250 seconds]
paradoja has quit [Ping timeout: 256 seconds]
travisbrady has joined #ocaml
martintrojer has quit [Max SendQ exceeded]
martintrojer has joined #ocaml
matthewhill has joined #ocaml
<Algebr>
Is there a way in Lwt to say grab a handle on whatever event I'm currently on? Like Lwt.current_event () or somethign like that
martintrojer has quit [Max SendQ exceeded]
martintrojer has joined #ocaml
matason has quit [Ping timeout: 252 seconds]
Submarine has joined #ocaml
Submarine has joined #ocaml
travisbrady has quit [Quit: travisbrady]
segmond has quit [Ping timeout: 252 seconds]
<Algebr>
Is it really the case that arguments to methods can't be type variables?
<mbac>
methods?
<Algebr>
I was writing a method and got this error, type 'c -> unit where 'c is unbound
arj has quit [Quit: Leaving.]
<rgrinberg>
Algebr: so you're defining a class?
<Algebr>
I'm subclassing something and adding a method
MrScout has joined #ocaml
ontologiae_ has quit [Ping timeout: 252 seconds]
<rgrinberg>
it's true that classes need explicit type parameters
<companion_cube>
filter built on top of filter_map
<ggole>
You can filter in place easily enough
<companion_cube>
ggole: with a resizable array, yeah
<companion_cube>
otherwise you'd need to return the new length?
<Algebr>
hmm, I can fold too
<ggole>
It leaves junk at the end
<ggole>
So yeah, return the point
<ggole>
Array is certainly a bit sparse
manud has joined #ocaml
<Drup>
Algebr: a reason not to use <insert a stdlib extension here> ?
segmond has quit [Ping timeout: 255 seconds]
<Algebr>
I'd rather not have dependencies
bytbox has quit [Ping timeout: 246 seconds]
ontologiae_ has joined #ocaml
Guest53396 has joined #ocaml
ptc has joined #ocaml
ptc is now known as Guest24093
<whitequark>
ggole: actually, I think you could print a value properly.
<whitequark>
you have all the data you need. M.E and M is in your environment
reem has joined #ocaml
<Drup>
Algebr: abandon that mindset, it's useless and actively harmful.
<Drup>
I can understand why you would want small dependencies
<Drup>
but no dependency is stupid most of the time and will lead you to reimplement yet another half assed stdlib extension inside your app
<ggole>
whitequark: doesn't the environment only give you the signature of M, which doesn't contain the problematic constructor?
<whitequark>
oh.
<whitequark>
haven't noticed that.
mort___ has quit [Quit: Leaving.]
<ggole>
If it's exposed it should print fine.
<whitequark>
but it will be present in debug info, however.
<whitequark>
assuming you go crawl the environment from where it was raised :)
<ggole>
It does seem like this should be possible
<whitequark>
and since toplevel now has debug info as well, that would also work in toplevel
<Algebr>
Drup: damn, throwing it down, but you're right.
<ggole>
There are some genuinely impossible cases but there's actually sane handling for that
<whitequark>
like which?
<ggole>
Eg type t = A : 'a -> t;; A 1
<Drup>
Algebr: don't worry, I had this discussion with several other people before you to sharpen my arguments.
<ggole>
Instead of just guessing and printing an int (yuck) it gives you <poly>, which is at least honest
<whitequark>
well, I don't think that's a problem
<whitequark>
exception printing is inconsistent with semantics
<whitequark>
this is consistent
<whitequark>
you aren't entitled to get information you can't in any way retrieve from within the language
<ousado>
are you talking about runtime type information?
<whitequark>
you can't get "1" from "A 1" above in any way
<whitequark>
ever
<whitequark>
you can only get an (<opaque> : existential)
<ggole>
Yeah, agreed
<whitequark>
whereas you can of course match on M.E in /some/ context
Guest24093 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<ggole>
Hmm, do open types have the same issue?
<whitequark>
yes
<whitequark>
exceptions are open types
<whitequark>
with funky syntax.
WraithM has quit [Quit: leaving]
<whitequark>
type x += Hi;; raise (Obj.magic Hi);; Exception: Hi. #
<ggole>
Ah, it prints it <extension>
<ggole>
That's a bit nicer
<def`>
what do you mean by exception printing is inconsistent with semantics?
<whitequark>
see ggole's example above
segmond has joined #ocaml
<whitequark>
ggole: I think that's less useful
<ggole>
module M : sig type t = .. val f : unit -> t end = struct type t = .. type t += A let f () = A end
<def`>
ah yes
<def`>
I missed the example. Yeah…
dsheets_ has joined #ocaml
<ggole>
whitequark: less useful? Because exceptions are somewhat likely to be unexpectedly seen at the toplevel where you would very much want the info?
<whitequark>
exactly
<ggole>
Yeah, I'm inclined to agree
BitPuffin has quit [Ping timeout: 255 seconds]
<Algebr>
this is not legal correct (fun (foo, (bar, baz)) as t -> ...)
<ggole>
(I can't remember if you need the ones around the outermost tuple or not...)
<Drup>
companion_cube: lol
<def`>
(I think you don't :)
<Drup>
companion_cube: "Maybe in that case we could also have an Option module in the stdlib" and you just showed in one sentence why this will not be in the stdlib.
_andre has quit [Quit: leaving]
tane has quit [Quit: Verlassend]
<companion_cube>
well, if we get a Result module with combinators, we can have an Option module
<companion_cube>
what I'm actually defending is: just the type in the stdlib, and in a library
<whitequark>
the people who say "stdlib should stay a support module for compiler" should just shut up, they're directly harmful to the community
bytbox has joined #ocaml
<companion_cube>
whitequark: sadly some of those people are the compiler maintainers
<rgrinberg>
whitequark: you might not like haskell but they have a pretty good governance model for "base"
<companion_cube>
Drup: really, no one ever proposed an Option module?
<whitequark>
companion_cube: no incentive for inria to care about community, i suppose
<companion_cube>
pretty much yeah
<Drup>
companion_cube: on the contrary, re-read the sentence
<companion_cube>
I mean, they care about Coq
<rgrinberg>
too bad the whole ocaml-platform effort thing died
<companion_cube>
I re-read, and saw no change
<Drup>
ok, two many negations in one sentence
<Drup>
too*
<Drup>
this is *not* the reason.
<companion_cube>
what's the reason then? (and for what? :D)
<Drup>
because the Core team said the stdlib should be small and refuse to add anything in it.
<Drup>
except things that can't be outside the compiler
<Drup>
(Bytes, for example)
<companion_cube>
oh, I see
<companion_cube>
too many negations indeed
<Drup>
yeah
<rgrinberg>
Drup: can't they make an exception for type definitions
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
<Drup>
rgrinberg: I don't know, I'm not the core team
<companion_cube>
if they accept to put just a type definition, fine, but the compatibility lib will also have to contain only the type
<Drup>
it's actually worse
<Drup>
the compatibility lib is not usable if the type is in pervasive
<Drup>
because it's globally opened
<Drup>
really, putting it in the stdlib is only a way to say "we agreed on it"
<companion_cube>
I didn't check, did yminsky put it in Pervasives? awww
<Drup>
of course he did :p
<Drup>
I mean, that's the most sensible place to put it, if you don't consider other things
<Drup>
and if we agreed on it, we don't need it in the stdlib.
<companion_cube>
no, that's not the most sensible place to put it
<companion_cube>
Pervasives is too big already
<companion_cube>
it should be almost empty
<companion_cube>
and contain aliases, not definitions
<rgrinberg>
companion_cube: you sound like a core user :D
<companion_cube>
how so? Core promotes the use of open everywhere
<companion_cube>
I don't like open
<companion_cube>
even when it's implicit
<rgrinberg>
I mean that core's equivalent to pervasives, `Std` is basicall a collcetion of aliases
<Drup>
rgrinberg: no, it's not
<Drup>
Std contains lots of values
<Drup>
it's enormous
<companion_cube>
I'm not against Std shadowing (==), though, it's a nice trick ^^
<companion_cube>
otoh batteries' BatPervasives is *terrible*
<flux>
nullcat, because the type [> `Ok (_ list) | `Error _] matches that case..
<flux>
you can always just do this: match `foo with `foo | `bar -> () and it works
<flux>
but you cannot do: match (`foo : [`foo]) with `foo | `bar -> ()
<vivien_>
Hello, I am trying to compile something from debian stable to windows, thanks to the "opam-windows-repository". I can't get i686-w64-mingw32-ocamlbuild working : it says it can't find dllunix.so. Did I miss something ? I have a dllunix.dll in ~/.opam/4.00.1/i686-and-so-on/lib/ocaml/stublibs
Anarchos has joined #ocaml
<flux>
nullcat, ah, and I see now what you understand. well, that [> ..] type is compatible with presult I suppose is the core of the issue :)
<BitPuffin>
SML has things like Word32 etc, does ocaml have anything like that, or do ya have to put up with integer
<flux>
actually I said wrong about the type. in any case, the type of 'f' is inferred to be val f : [< `Error of 'a | `OK | `Ok of 'b list ] -> int = <fun>
<nullcat>
flux: yeah that's what i mean. Just wondering why compiler cannot see the error of the third matching case in the poly example, which is (`Ok | `Error) ... since there is no "`Ok"
<whitequark>
BitPuffin: int32
<nullcat>
flux: i see
<BitPuffin>
whitequark: that's signed though
mort___ has joined #ocaml
<nullcat>
flux: totally makes sense now
<BitPuffin>
word32 is unsigned
<nullcat>
thanks!
<companion_cube>
I think there's a library for unsigned ints
<whitequark>
opam install uint
reem has quit [Remote host closed the connection]
<BitPuffin>
looks like that interfaces with C
<nullcat>
psnively: my async already upgrades to that version, and I can use 'wget' to get that tar.gz file on my machine
<nullcat>
psnively: did you run "$ opam update"?
<whitequark>
BitPuffin: well, so does int32
<whitequark>
oh, hi psnively
<psnively>
nullcat: Yeah. It’s very weird. opam update says I need to opam upgrade, but when I do, I get errors, just on the Jane Street stuff. But curl works.
<psnively>
Hi whitequark!
TheLemonMan has joined #ocaml
<flux>
psnively, ..are you using the external resolver?
<psnively>
“External resolver?"
<flux>
aspcud
<psnively>
Beats me.
<psnively>
How would I tell? :-)
<flux>
so I guess that's a no :)
<flux>
do you have aspcud installed?
<psnively>
Doubtful.
<flux>
well, then you are not using it :)
<flux>
opam's internal resolver seems a bit simple, I actually wonder if it's in fact buggy
<BitPuffin>
whitequark: would be nice to have something that doesn't depend on an external compiler :o
<psnively>
That does seem to simplify things… at least as far as answering your question goes.
<whitequark>
BitPuffin: ocaml depends on an external compiler
<flux>
but aspcud has resolved those issues 100% for the opam install/upgrade cases I have seen here.. ;-)
<whitequark>
I mean, building C extensions just reuses the same machinery ocamlc -custom and, to a degree, ocamlopt use
<BitPuffin>
whitequark: it does? for pure ocaml?
segmond has quit [Ping timeout: 240 seconds]
<whitequark>
sure
<BitPuffin>
I guess it probably uses an external assembler
<BitPuffin>
but it's not like it compiles to C
<whitequark>
it invokes a C compiler
<BitPuffin>
to assemble?
<whitequark>
yes
<BitPuffin>
hm
<psnively>
flux: OK. How do I install aspcud and tell OPAM to use it?
<whitequark>
assemble and link, because it doesn't really know linker flags
<flux>
psnively, what operating system do you have?
<BitPuffin>
whitequark: interesting, would be cool if someone wrote an assembler in ocaml :P
<flux>
I suppose it would be great to have aspcud as an opam package, even if it's not in ocaml
<psnively>
flux: Mac OS X Yosemite, 10.10.2.
<BitPuffin>
(and linker)
<whitequark>
BitPuffin: god why
<BitPuffin>
moar self host
<psnively>
BitPuffin: They did. It’s called LLVM. ;-)
<whitequark>
indeed
<vanila>
i thought LLVM was C++
<whitequark>
though LLD has no ocaml bindings and can't quite self-host
<BitPuffin>
psnively: err, it's written in cpp?
<psnively>
BitPuffin: Well, OK, technically it’s just OCaml bindings to LLVM...
<flux>
psnively, dunno then. find sources and install it the old way :)
<psnively>
BitPuffin: Picky, picky.
<whitequark>
psnively: brew install aspcud
<psnively>
flux: LOL OK, thanks.
<BitPuffin>
psnively: xD
<whitequark>
no need to build from source
<psnively>
whitequark: I avoid Homebrew and MacPorts like the bubonic plague, but thanks.
<flux>
psnively, opam also supports some cloud solver
<flux>
psnively, haven't used it but apparently it works fine
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
<Leonidas>
TheLemonMan: then use Core if you use the RWO examples
<companion_cube>
right
<Leonidas>
(just keep in mind that Core rewrites much of your Stdlib if you open it)
<Drup>
Algebr: "Fatal error: exception Invalid_argument("Option.get")" now :D
<Leonidas>
(so look at the Core docs not the Stdlib docs for help)
<Algebr>
yea, I'm absuing Option.get
<Algebr>
heh
<Drup>
bad !
<companion_cube>
oh wow, you can do this with lambda-term? neat
<Drup>
of course you can :D
<Algebr>
heh, I don't think it was intended for pseudo-games, but there it is.
<Drup>
you manipulate an array of UChar, you can do pretty much whatever you want
<Drup>
a matrix*
<Algebr>
yea, I was looking for an alien symbol for unicode
<Drup>
there is one
<tokenrove>
i hacked up a little game in ocaml with tsdl for #1gam on the weekend, which i'd love to get some code review on, but i still need to take a pass at cleaning it and its libraries up.
<Drup>
bah, don't clean
<Drup>
publish it first, clean after
<Drup>
the good old "let me just clean it before publishing" is equivalent to procrastination, just more perverse because it seems justified :D
<tokenrove>
but i am in the middle of finishing a deliverable on actual work and would like to come back to it and give it one more pass.
segmond has joined #ocaml
<Algebr>
haha, nice !
<companion_cube>
aww, I expected at least a screenshot, tokenrove ^^
ontologiae_ has quit [Ping timeout: 244 seconds]
<Drup>
Algebr: not handler by my monospace font, though
<Drup>
handled*
<tokenrove>
companion_cube: good point. (there's a screenshot on the linked blog post, near the bottom, but i'll add one to the readme. i was holding out hope that i would get the presentation layer implemented.)
<Drup>
tokenrove: oh, but it is published, just not anounced, that's fine :p
<companion_cube>
oh, neat
<tokenrove>
i was hoping to make board's interface parameterized by a presentation module to avoid having board deal with sdl at all. i still need to figure that out.
<tokenrove>
anyway, despite it being a weekend hack i would appreciate any feedback on the code, places to improve things, and any expressions of interest in the tsdl-image and tsdl-mixer libraries being fleshed out
<Algebr>
Drup: are you on debian?
<Drup>
Algebr: nope
<Drup>
Algebr: "foo |> (function ...." is pretty much the same as "match foo with ..." but with more parens and an additional operator :p
<Algebr>
ahh, oops.
olauzon has quit [Quit: olauzon]
<Drup>
considering the operation you do, I think rockets should not be an array.
<Algebr>
what instead?
<Drup>
a list
<Algebr>
yea, I was worried that lists would be slow
<Algebr>
although to be fair I didn't try lists at all
<Drup>
well,
<Drup>
you are copying the array constantly
<Drup>
you are *consing* on an array
<TheLemonMan>
"Error: Unbound module Core" eww
oriba has quit [Quit: oriba]
travisbrady has joined #ocaml
psnively has quit [Quit: psnively]
<Drup>
Algebr: " (* 0 is down, 1 is left, 2 is right *)"
<Algebr>
ahh, yep, I see
<Drup>
A sum type might be appropriate :D
<Algebr>
yea, I did initially
<Algebr>
but yea, need to change that
<Drup>
(I like the fact there is somewhere "if !go_down = 3"
<Algebr>
the single equal sign for equality threw me off occasionally
<Algebr>
Drup: one thing that was annoying was tons of | None -> (). Is there something better than that, or is that just nature of imperative code?
<Drup>
Option.iter
<apache2>
is there a way to make the compiler complain about == ?
<apache2>
I very rarely use == in ocaml, but I often end up typing it by accident
<whitequark>
let (==) = "no"
<whitequark>
well, that won't really show in an error message
<apache2>
whitequark: ah, heh :D that works, I guess, but that wouldn't be project-wide, would it?
<whitequark>
let (==) = `The_fuck_are_you_doing
<Algebr>
lol
<whitequark>
apache2: no. look at the -open flag
<apache2>
thanks
reem has joined #ocaml
reem has quit [Ping timeout: 265 seconds]
<Drup>
Algebr: I wonder if there is a way to have the terminal fire multiple events at once correctly, and remove the auto-repeat period
<Algebr>
Drup: that would be really nice
<Algebr>
|> is defined as let (|>) f x = x f , right?