<gnuvince>
Is there a way with OCaml to have pattern matching where you can ignore some fields in the variants? I have an AST module, and all nodes have a pos field, and it's really annoying to always match them. Would it be possible to change from match exp with Nil pos -> ... to match exp with Nil -> ...?
<Drup>
gnuvince: use _ ?
<Drup>
adrien_oww: the crazy part is that it get through 50 other languages to get back to the original program =')
<gnuvince>
Drup: that's what I'm doing at the moment, it's just a bit ugly to have those all around.
introom has joined #ocaml
yezariaely has quit [Quit: Leaving.]
shinnya has joined #ocaml
dsheets has quit [Ping timeout: 256 seconds]
cago has left #ocaml []
osa1 has quit [Ping timeout: 261 seconds]
osa1 has joined #ocaml
mort___ has joined #ocaml
mika1 has quit [Quit: Leaving.]
Yoric has quit [Ping timeout: 246 seconds]
thomasga has joined #ocaml
thomasga1 has quit [Read error: Connection reset by peer]
dsheets has joined #ocaml
hkBst has quit [Quit: Konversation terminated!]
UncleVasya has quit [Quit: Leaving]
paolooo has joined #ocaml
osa1 has quit [Ping timeout: 258 seconds]
NaCl has joined #ocaml
NaCl has quit [Changing host]
NaCl has joined #ocaml
tane has joined #ocaml
paolooo has quit [Ping timeout: 250 seconds]
pygmalion has joined #ocaml
ollehar has quit [Ping timeout: 256 seconds]
Arsenik has joined #ocaml
Arsenik has quit [Max SendQ exceeded]
pygmalion has quit [Ping timeout: 248 seconds]
ollehar has joined #ocaml
Arsenik has joined #ocaml
ineol has joined #ocaml
mort___ has quit [Quit: Leaving.]
ollehar has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
mfp has quit [Read error: Connection reset by peer]
mfp has joined #ocaml
thomasga has quit [Quit: Leaving.]
ygrek has quit [Ping timeout: 240 seconds]
Simn has quit [Quit: Leaving]
smondet` has joined #ocaml
<ggole>
gnuvince: if every single leg of the ADT has a pos entry, you might split things into pos * ADT
pygmalion has joined #ocaml
<ggole>
The real answer is named constructor arguments, which OCaml doesn't have yet
<mrvn>
and if you don't you should
<mrvn>
ggole: like type t = Foo of (x:pos) * foo | Bar of (x:pos) * bar?
<ggole>
I think the current suggestion is more like records
<ggole>
With some machinery to allow fields with the same name
pygmalion has quit [Ping timeout: 276 seconds]
ontologiae_ has quit [Ping timeout: 256 seconds]
<flux>
ggole, didn't F# just get something like named constructors?
<ggole>
Not sure: I don
<ggole>
't follow F# news
<flux>
it is sort of sad that OCaml is getting all these cool features in that won't be the "small" language it used to be
<flux>
but on the other hand these new cool features are new cool features :-)
<mrvn>
I want Constructors as first class values
<flux>
iirc they had that but it complicated compiler too much. or something.
<ggole>
Yeah, there's lots of odd stuff in OCaml now
<flux>
it'd be nice as well
<ggole>
So you can have constructor variables?
<ggole>
That's useful every now and then
<mrvn>
type t = Foo of int;; Foo;; ==> int -> t
<flux>
the biggest problem with new features is getting them to co-exist with old features nicely
<ggole>
On the other hand, you can almost always factor them out
<mrvn>
syntactic suggar for (fun x -> Foo x)
<flux>
for example mrvn's recent "how to recursively refer types from classes and vice versa" is one example where that has IMHO failed
<ggole>
Hmm, the ML people had that but seem to think it was a minor mistake
<ggole>
On the other hand ML constructor names are not lexically distinct from variable names: so maybe it wouldn't matter in OCaml
<flux>
I think mrvn's (and mine) needs for constructors-as-functions would mostly be satisfied by a 'hole' syntax, as in pa_hole
<flux>
but I think pa_hole doesn't work these days..
<mrvn>
One thing constructor as function would make nicer would be "foo x y z" without the need for ()
<mrvn>
Foo x y z
<ggole>
Yes, consistent application syntax would be nice
<ggole>
For type constructors too
<mrvn>
I often have to write (Foo (x, y))
<mrvn>
ggole: for types it would be nice to have type ('a, 'b) t = 'a 'b
<ggole>
Hmm?
<mrvn>
e.g. a (int, Hashtbl.t) t
<flux>
how about the revised syntax? I think it's nice how it reflects the application syntax.
<Drup>
why ?
<ggole>
Er
<flux>
but I don't think anyone uses revised syntax..
<ggole>
Not following you mrvn
<Drup>
(the "why ?" was for mrvn)
<mrvn>
ggole: avoids the need for the more complex functor syntax
<mrvn>
ggole: Sometimes you want to implement an algorithm independent of some container type. Then you can use different containers depending on circumstances.
<mrvn>
ggole: mostly with phantom types
<ggole>
Oh, you want first class type constructors
* ggole
nods
<ggole>
That's not really a syntax thing
<mrvn>
no, thats a big change in the type system.
AltGr has quit [Quit: Konversation terminated!]
<mrvn>
while we are ranting here is another little thing that bugs me: There is Hashtbl.find, Hashtbl.find_all. But no Hashtbl.find_option (return None instead of exceptions Not_found). There is Hashtbl.remove but no Hashtbl.pop. There is Array.to_list but no String.to_list. ...
ttamttam1 has quit [Quit: ttamttam1]
<mrvn>
Some interfaces miss the simplest function or differ from other interfaces.
<Drup>
mrvn: if only those were the only problems in the standard library ..
bacam has quit [Ping timeout: 264 seconds]
bacam has joined #ocaml
breakds has quit [*.net *.split]
contempt has quit [*.net *.split]
Neros has quit [*.net *.split]
tianon has quit [*.net *.split]
cdidd has quit [*.net *.split]
ccasin has quit [*.net *.split]
ggherdov has quit [*.net *.split]
IbnFirnas has quit [*.net *.split]
PM has quit [*.net *.split]
Leonidas has quit [*.net *.split]
flux has quit [*.net *.split]
Ptival has quit [*.net *.split]
companion_cube has quit [*.net *.split]
vpm has quit [*.net *.split]
zzz_ has quit [*.net *.split]
wagle has quit [Read error: Connection reset by peer]
wagle has joined #ocaml
<mrvn>
The problem is that even if you write the functions they don't get included for years and years.
djcoin has quit [Quit: WeeChat 0.4.0]
<mrvn>
Latest function in stdlib I missed is Queue.untake or push_front
breakds has joined #ocaml
contempt has joined #ocaml
Neros has joined #ocaml
tianon has joined #ocaml
cdidd has joined #ocaml
ccasin has joined #ocaml
ggherdov has joined #ocaml
IbnFirnas has joined #ocaml
PM has joined #ocaml
Leonidas has joined #ocaml
flux has joined #ocaml
Ptival has joined #ocaml
companion_cube has joined #ocaml
vpm has joined #ocaml
zzz_ has joined #ocaml
<mrvn>
OMG, you broke the internet
skchrko has quit [Remote host closed the connection]
smondet` has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
walter has quit [Quit: This computer has gone to sleep]
travisbrady_ has joined #ocaml
hcarty_ has joined #ocaml
ollehar has quit [Ping timeout: 256 seconds]
Asmadeus_ has joined #ocaml
ulfdoz_ has joined #ocaml
Derander_ has joined #ocaml
contempt has quit [Ping timeout: 252 seconds]
noplamodo has joined #ocaml
quelu_ has joined #ocaml
contempt has joined #ocaml
ontologiae_ has joined #ocaml
whitequa1k has joined #ocaml
<ggole>
mrvn: sounds like you want a Deque, not a Queue
travisbrady has quit [*.net *.split]
ulfdoz has quit [*.net *.split]
whitequark has quit [*.net *.split]
quelu has quit [*.net *.split]
gnuvince has quit [*.net *.split]
noplamodo_ has quit [*.net *.split]
Asmadeus has quit [*.net *.split]
Derander has quit [*.net *.split]
thizanne has quit [*.net *.split]
hcarty has quit [*.net *.split]
transfinite has quit [*.net *.split]
travisbrady_ is now known as travisbrady
introom has quit [Remote host closed the connection]
thizanne has joined #ocaml
pygmalion has joined #ocaml
Asmadeus_ is now known as Asmadeus
ulfdoz_ has quit [Ping timeout: 273 seconds]
transfinite has joined #ocaml
tane has quit [Quit: Verlassend]
emmanuelux has joined #ocaml
pygmalion has quit [Ping timeout: 240 seconds]
ontologiae_ has quit [Ping timeout: 260 seconds]
dsheets has quit [Ping timeout: 240 seconds]
ulfdoz has joined #ocaml
Simn has joined #ocaml
<pippijn>
whitequa1k: ping
<pippijn>
whitequa1k: how do you build merr? "ocamlbuild -use-ocamlfind merr.native?
<pippijn>
whitequa1k: the first part where it checks "does merr.native -help work?" succeeds
<pippijn>
but then, between that and running merr, ocamlbuild removes the link
<pippijn>
whitequa1k: it works if I do _build/merr/merr.native
breakds has quit [Remote host closed the connection]
<whitequa1k>
I see
<whitequa1k>
patch it up?
<pippijn>
yes
<pippijn>
but: Error: Unbound module Libmerr
<pippijn>
oh
<whitequa1k>
oh
<whitequa1k>
interesting
<pippijn>
it was named "Merr" before?
<pippijn>
or was it always Libmerr?
<pippijn>
I think always Libmerr..
<whitequa1k>
yes
<pippijn>
but libmerr is not built here
<whitequa1k>
and now, if you pulled my patches, it only contains Levenshtein
<pippijn>
I need to explicitly do that, I guess
<pippijn>
yes, I did
<whitequa1k>
re: your "add license clause" commit
<whitequa1k>
there are quite a few problems with it
travisbrady has quit [Quit: travisbrady]
<pippijn>
ah
<pippijn>
yes, I suspected that
<whitequa1k>
first, I don't think there is anything you can do to affect previously distributed versions of work
<whitequa1k>
most licenses (I am sure about GPL, need to look at MPL) explicitly state that this is impossible
<pippijn>
right, so I am explicit about not doing that
<whitequa1k>
well, it doesn't matter :)
<pippijn>
ok
<pippijn>
I can remove that part
<whitequa1k>
now about relicensing
<whitequa1k>
to my best understanding: 1) you always have the right to relicense your work however you want, 2) in order to be able to relicense your contributors' work, you have to offer them to sign a CLA
<whitequa1k>
"contributor-level agreement"
<pippijn>
ah
<pippijn>
I need to do 2) then
<whitequa1k>
and by "sign" I mean "tick a checkbox". seems like it's enough for the legal stuff.
<whitequark>
I think that pretty much everyone requires email
<whitequark>
it's more unique than name?
<pippijn>
right
alang has quit [Ping timeout: 240 seconds]
mort___ has joined #ocaml
pygmalion has joined #ocaml
Yoric has quit [Ping timeout: 245 seconds]
alang has joined #ocaml
pygmalion has quit [Ping timeout: 276 seconds]
<wmeyer>
pippijn: if GPL of treematch is burden, feel free to change it, complexity of treematch is not worth that protection, and BTW, I appreciate more that you can use treematch rather than it will be GPLed.
<adrien_>
GPL or LGPL+le?
jave_ has quit [Ping timeout: 240 seconds]
mye has joined #ocaml
<pippijn>
adrien_: GPL, it's a code generation tool
<pippijn>
no need to link anything
<adrien_>
you can make the tool GPL and its output not GPL
<pippijn>
wmeyer: no, treematch is yours
<pippijn>
wmeyer: you own the copyright to it
<pippijn>
adrien_: yes
<pippijn>
it is
<pippijn>
the output is whatever you want
breakds has joined #ocaml
<wmeyer>
well, but it may evolve
<pippijn>
yes
<wmeyer>
now it's text to text processing tool, but it might change
<pippijn>
it's not my work
<pippijn>
if I do anything to it, that will be my contribution to your work
chrisdotcode has joined #ocaml
roboguy_ has joined #ocaml
osnr has quit [Read error: Connection reset by peer]
<wmeyer>
pippijn: let's agree then if you ever need my license to change feel free to ask and I will just do it.
smondet has quit [Quit: Gotta Go Home ...]
<pippijn>
wmeyer: ok, thanks
ollehar has joined #ocaml
tane has quit [Quit: Verlassend]
pygmalion has joined #ocaml
pygmalion has quit [Ping timeout: 240 seconds]
walter has joined #ocaml
<whitequark>
hm, I need a data structure
<whitequark>
I have key-value pairs where both keys and values in each pair are unique
<whitequark>
and I want fast lookup of key by value (yes, this stretches "key" a bit :p), and checking if a key already exists
<whitequark>
(basically I am assigning unique names to unique objects, and looking them up in order to dump a recursive data structure.)
<whitequark>
a hash table mapping values to keys, and a set of keys, I guess
<Drup>
whitequark: you can use the multimap from companion_cube for this.
<Drup>
you don't really need this for only 2 indexes, but you will end up redoing almost the same thing
travisbrady has quit [Quit: travisbrady]
<whitequark>
hm
<pippijn>
whitequark: a bimap?
<whitequark>
right
cthuluh has quit [Ping timeout: 264 seconds]
<mrvn>
you can combine 2 hashtbl. One for key -> value and one for value -> key.
cthuluh has joined #ocaml
<Drup>
(this is exactly what indexed-set is doing, btw)
<mrvn>
Drup: one hashtbl per index?
<Drup>
yes
<Drup>
well, one Map
<whitequark>
mrvn: I think I even only need a Set of keys
<mrvn>
then you can't lookup a value by key.
<whitequark>
mrvn: don't need to
<mrvn>
*scroll back*
<pippijn>
indentation in ixSet.ml is confusing
<whitequark>
oh, Sets are applicative
<whitequark>
so yeah, a hashtbl of key, unit
<pippijn>
well, only at the end
<mrvn>
Hmm, you only need a simple hashtbl.
<pippijn>
ixSet does a lot.. why?
<pippijn>
is it more efficient than 2 maps?
rrolles has joined #ocaml
<pippijn>
it works with classes and a universal type
<mrvn>
You add each object to your hashtable with the ID you assign to it. Hashtbl.mem tells you if an object is already there or simply Hashtbl.find and catch the exception
mort___ has quit [Quit: Leaving.]
<rrolles>
hey, I'm wondering what the cleanest way to deal with this compilation issue is
<rrolles>
I have a file, PE32.mli, which has no corresponding .ml file and consists of a bunch of type definitions ... then there's another file, PEParse.ml, which "open"s PE32
<rrolles>
so I'm trying to use PEParse.cmx/cmo in another project in another directory, and it's complaining while trying to link
<rrolles>
Error: Error while linking ../../PE32/PEParse.cmo:
<rrolles>
Reference to undefined global `PE32'
<rrolles>
Makefile:30: recipe for target `NXcroticism.exe' failed
<rrolles>
make: *** [NXcroticism.exe] Error 2
<whitequark>
mrvn: oh, I wasn't specific enough
<whitequark>
rrolles: please don't do this
<whitequark>
pastebin.com
<rrolles>
ok
<pippijn>
interesting
<pippijn>
rrolles: where did you get a PE parser?
<rrolles>
I wrote it
<pippijn>
nice
<pippijn>
open source?
<rrolles>
not yet
<pippijn>
ok
<rrolles>
it's not robust enough yet
<whitequark>
PE
<whitequark>
ugh :/
<pippijn>
open it anyway
<mrvn>
rrolles: you forgot to link the PE32 objects
<rrolles>
well, there is no PE32.cmx
<pippijn>
why not?
<rrolles>
I tried to put PE32.cmi in the link command but it bails
<rrolles>
it's just a .mli, no .ml
<whitequark>
mrvn: so. suppose I have a type Env.t. I want to bind a value to a name inside Env.t, and then look the name back up with a value
<mrvn>
rrolles: you need the PE32.ml or its compilat
<Drup>
whitequark: I understood you need "key" access by value, if you don't, the problem become far more simple indeed.
<whitequark>
mrvn: the interesting part is what happens when the name is already bound
<rrolles>
should I just duplicate PE32.mli and call it PE32.ml, then include the PE32.cmo object?
<pippijn>
when can you get away with not having a .ml?
<whitequark>
mrvn: I don't want to replace or shadow existing binding; instead, I want to mangle the name
<pippijn>
rrolles: no need to duplicate, just have a .ml and no .mli
<mrvn>
whitequark: Hashtbl.add table name value
<rrolles>
ah, fair enough
<whitequark>
mrvn: that does not give me lookup by value
<pippijn>
x86 typecheck?
<pippijn>
what do you typecheck?
<mrvn>
whitequark: you said you didn
<mrvn>
't need by value
<whitequark>
mrvn: vice versa. don't need it by name.
<whitequark>
only need to check existence of a name.
<mrvn>
whitequark: then swap the two
<pippijn>
rrolles: you should publish it :) open software development, people can help you
<whitequark>
mrvn: sure, but then I'll have to iterate the entire hashtable
<mrvn>
whitequark: checking existance is a lookup
<mrvn>
whitequark: so you DO need both
<whitequark>
yeah, that's why I said two hashtables.
<rrolles>
yeah, I think I will
<rrolles>
I've written tons of code for this project that I'm considering open sourcing
<rrolles>
x86 disassembler / assembler, PE parser, x86 -> IR translator, an SMT solver, etc
<mrvn>
whitequark: type ('a, 'b) KeyValue = Key of 'a or | Value of 'a * 'b
<mrvn>
whitequark: put that into a Hashtbl.
<pippijn>
rrolles: that's really cool
<pippijn>
rrolles: where are you planning on putting it?
<whitequark>
mrvn: huh? why would I need that?
<pippijn>
rrolles: github?
<rrolles>
dunno yet
<mrvn>
whitequark: if you only want one table
<rrolles>
I'm focusing on making it all work first :)
<rrolles>
anyway, thanks everybody for your suggestions, renaming the .mli to .ml seems like the cleanest solution, and now it compiles
<whitequark>
mrvn: well, I don't care about amount of tables. I want some abstract type
<pippijn>
good
ontologiae_ has joined #ocaml
<mrvn>
rrolles: you might want to build a module for your parser with META file and all. Its verry simple with oasis.
oriba has joined #ocaml
<whitequark>
I look at oasis generated stuff and kind of not want to use it
<whitequark>
reminds me of autoconf & friends
<mrvn>
whitequark: it does some configuring and testing for needed packages. But nothing as bad as autoconf.
<mrvn>
whitequark: I don't look at the generated stuff. I look at the stuff I need to write (_oasis) and how it well it works in the end.
<mrvn>
whitequark: At first I looked at writing my own myocamlbuild and such and that way way worse.
<whitequark>
mrvn: and what if oasis does it wrong / doesn't do what you want?
mye has quit [Quit: mye]
<mrvn>
whitequark: I come here and hit the author :)
<whitequark>
haha
<whitequark>
who's that?
<pippijn>
"Closure allocation basically involves allocating memory for each of the free variables of the function"
<mrvn>
Sylvain Le Gall and others
<pippijn>
why for all free variables?
<pippijn>
why not just the captured ones?
<whitequark>
pippijn: an optimizing compiler only allocates the captured ones
<mrvn>
pippijn: unless the closure is never fully applied that is the same
<whitequark>
that's called lambda lifting I think
<mrvn>
pippijn: if you write function x -> function y -> ... then it should capture each seperately I think
rrolles has quit [Read error: Connection reset by peer]
<whitequark>
or no
<mrvn>
fun x y -> on the other hand not
alang_ has joined #ocaml
alang has quit [Ping timeout: 246 seconds]
Simn has quit [Quit: Leaving]
The_third_man has quit [Ping timeout: 264 seconds]
gbluma has joined #ocaml
Cypi has quit [*.net *.split]
rednovae has quit [*.net *.split]
gbluma_ has quit [*.net *.split]
olasd has quit [*.net *.split]
mathieui has quit [*.net *.split]
dtg_ has quit [*.net *.split]
madroach has quit [*.net *.split]
troydm has quit [*.net *.split]
srcerer has quit [*.net *.split]
testcocoon has quit [*.net *.split]
ousado has quit [*.net *.split]
josch_ has quit [*.net *.split]
Qrntz has quit [*.net *.split]
lenstr has quit [*.net *.split]
tlockney has quit [*.net *.split]
adrien_oww has quit [*.net *.split]
cow-orker has quit [*.net *.split]
_habnabit has quit [*.net *.split]
emias has quit [*.net *.split]
ollehar has quit [*.net *.split]
gnuvince has quit [*.net *.split]
osa1 has quit [*.net *.split]
ulfdoz has quit [*.net *.split]
emmanuelux has quit [*.net *.split]
contempt has quit [*.net *.split]
bacam has quit [*.net *.split]
yroeht has quit [*.net *.split]
brendan has quit [*.net *.split]
j0sh has quit [*.net *.split]
quelu_ has quit [*.net *.split]
ineol has quit [*.net *.split]
shinnya has quit [*.net *.split]
Drup has quit [*.net *.split]
asmanur has quit [*.net *.split]
BiDOrD_ has quit [*.net *.split]
ski has quit [*.net *.split]
mrvn has quit [*.net *.split]
rossberg__ has quit [*.net *.split]
whitequark has quit [*.net *.split]
bholst has quit [*.net *.split]
metasyntax has quit [*.net *.split]
alexey has quit [*.net *.split]
Armael has quit [*.net *.split]
pippijn has quit [*.net *.split]
aggelos__ has quit [*.net *.split]
noplamodo has quit [*.net *.split]
Derander_ has quit [*.net *.split]
gustav_ has quit [*.net *.split]
Tamae has quit [*.net *.split]
milosn has quit [*.net *.split]
tizoc has quit [*.net *.split]
bobry has quit [*.net *.split]
orbitz has quit [*.net *.split]
Nahra has quit [*.net *.split]
rks` has quit [*.net *.split]
lopex has quit [*.net *.split]
iZsh has quit [*.net *.split]
bernardofpc has quit [*.net *.split]
Khady has quit [*.net *.split]
jdoles has quit [*.net *.split]
stomp has quit [*.net *.split]
hcarty_ has quit [*.net *.split]
wagle has quit [*.net *.split]
mfp has quit [*.net *.split]
caligula_ has quit [*.net *.split]
def-lkb has quit [*.net *.split]
cross has quit [*.net *.split]
wmeyer has quit [*.net *.split]
samebchase has quit [*.net *.split]
nicoo has quit [*.net *.split]
SuperNoeMan has quit [*.net *.split]
walter has quit [*.net *.split]
weie has quit [*.net *.split]
dextrey has quit [*.net *.split]
fds_ has quit [*.net *.split]
thelema has quit [*.net *.split]
adrien_ has quit [*.net *.split]
gasche has quit [*.net *.split]
oriba has quit [*.net *.split]
chrisdotcode has quit [*.net *.split]
demonimin has quit [*.net *.split]
q66 has quit [*.net *.split]
bitbckt has quit [*.net *.split]
ohama has quit [*.net *.split]
davekong has quit [*.net *.split]
vext01 has quit [*.net *.split]
xenocons has quit [*.net *.split]
jlouis has quit [*.net *.split]
deavid has quit [*.net *.split]
fayden has quit [*.net *.split]
rgrinberg has quit [*.net *.split]
ivan\ has quit [*.net *.split]
rwmjones has quit [*.net *.split]
hnrgrgr has quit [*.net *.split]
patronus_ has quit [*.net *.split]
vbmithr_ has quit [*.net *.split]
Jenza has quit [*.net *.split]
othiym23 has quit [*.net *.split]
Cypi has joined #ocaml
walter has joined #ocaml
pygmalion has joined #ocaml
ttm has joined #ocaml
venk has joined #ocaml
oriba has joined #ocaml
ollehar has joined #ocaml
chrisdotcode has joined #ocaml
demonimin has joined #ocaml
gnuvince has joined #ocaml
osa1 has joined #ocaml
ulfdoz has joined #ocaml
emmanuelux has joined #ocaml
whitequark has joined #ocaml
contempt has joined #ocaml
quelu_ has joined #ocaml
noplamodo has joined #ocaml
Derander_ has joined #ocaml
hcarty_ has joined #ocaml
wagle has joined #ocaml
bacam has joined #ocaml
mfp has joined #ocaml
shinnya has joined #ocaml
bholst has joined #ocaml
yroeht has joined #ocaml
mrvn has joined #ocaml
Drup has joined #ocaml
jlouis has joined #ocaml
dtg_ has joined #ocaml
ohama has joined #ocaml
q66 has joined #ocaml
deavid has joined #ocaml
fayden has joined #ocaml
madroach has joined #ocaml
rgrinberg has joined #ocaml
troydm has joined #ocaml
srcerer has joined #ocaml
metasyntax has joined #ocaml
asmanur has joined #ocaml
alexey has joined #ocaml
testcocoon has joined #ocaml
Armael has joined #ocaml
gustav_ has joined #ocaml
Tamae has joined #ocaml
milosn has joined #ocaml
dextrey has joined #ocaml
iZsh has joined #ocaml
ivan\ has joined #ocaml
weie has joined #ocaml
pippijn has joined #ocaml
BiDOrD_ has joined #ocaml
fds_ has joined #ocaml
brendan has joined #ocaml
tizoc has joined #ocaml
aggelos__ has joined #ocaml
caligula_ has joined #ocaml
j0sh has joined #ocaml
bobry has joined #ocaml
bernardofpc has joined #ocaml
def-lkb has joined #ocaml
ski has joined #ocaml
davekong has joined #ocaml
orbitz has joined #ocaml
Nahra has joined #ocaml
rossberg__ has joined #ocaml
rwmjones has joined #ocaml
Khady has joined #ocaml
rks` has joined #ocaml
cross has joined #ocaml
wmeyer has joined #ocaml
jdoles has joined #ocaml
lopex has joined #ocaml
samebchase has joined #ocaml
nicoo has joined #ocaml
thelema has joined #ocaml
stomp has joined #ocaml
SuperNoeMan has joined #ocaml
adrien_ has joined #ocaml
hnrgrgr has joined #ocaml
ousado has joined #ocaml
gasche has joined #ocaml
vext01 has joined #ocaml
xenocons has joined #ocaml
bitbckt has joined #ocaml
othiym23 has joined #ocaml
Jenza has joined #ocaml
vbmithr_ has joined #ocaml
patronus_ has joined #ocaml
josch_ has joined #ocaml
Qrntz has joined #ocaml
lenstr has joined #ocaml
tlockney has joined #ocaml
adrien_oww has joined #ocaml
cow-orker has joined #ocaml
_habnabit has joined #ocaml
emias has joined #ocaml
yacks has quit [Max SendQ exceeded]
rednovae has joined #ocaml
olasd has joined #ocaml
mathieui has joined #ocaml
pygmalion has quit [Ping timeout: 245 seconds]
chrisdotcode has quit [Quit: brb - restarting router]
alang_ has quit [Ping timeout: 240 seconds]
srcerer has quit [Ping timeout: 248 seconds]
yacks has joined #ocaml
<whitequark>
assert has very strange precedence rules
<whitequark>
eg `assert not foo' does something weird
<pippijn>
assert is like a function, isn't it?
<mrvn>
yes
<pippijn>
function application, constructor application, assert, lazy
<whitequark>
oh, it's not a keyword
<pippijn>
so it seems normal to me
<pippijn>
whitequark: it is
<pippijn>
but it has the precedence of a function
<whitequark>
then why the hell it has that precedence
<mrvn>
# assert (not false);;
<mrvn>
- : unit = ()
<whitequark>
I have not encountered even a single time that is useful
<pippijn>
assert a = b; would be nicer
<pippijn>
I agree
<whitequark>
it just kinda reaffirms The Golden Rule Of Ocaml
<whitequark>
"if it has an error, add more parens"
<pippijn>
hehe
<mrvn>
pippijn: # assert 1 = 2;;
<mrvn>
Error: This expression has type int but an expression was expected of type bool
<mrvn>
Why isn't assert actually a function?
<whitequark>
so it could be optimized away in non-debug builds?
<mrvn>
whitequark: that could still happend
<whitequark>
well, I heard that ocaml kind of sucks at inlining
ulfdoz has quit [Ping timeout: 256 seconds]
<pippijn>
mrvn: because of assert false
<whitequark>
so I could totally see how it can not optimize asserts
<mrvn>
maybe so you don't do let f g = g false in f assert;;
<pippijn>
whitequark: it could have been external assert : 'a -> bool = "%assert"
<pippijn>
but it's type-checked specially
<pippijn>
so it's not a function
<pippijn>
eh
<whitequark>
assert false ?
<pippijn>
I mean assert : bool -> unit
<whitequark>
how is it special?
<pippijn>
assert false has type #a
<pippijn>
'a
<mrvn>
pippijn: let assert x = if x then () else raise (Assert_failure ...)
<wmeyer>
pippijn: I think yes
<whitequark>
pippijn: why is that good?
<mrvn>
# raise;;
<mrvn>
- : exn -> 'a = <fun>
<pippijn>
whitequark: so it works as raise
<whitequark>
hm
<mrvn>
pippijn: functions with polymorphic return type are normal.
<whitequark>
^
<pippijn>
mrvn: yes, but assert is normally unit
<pippijn>
except for assert false
<whitequark>
why not make it always 'a ?
<mrvn>
assert is just a conditional raise. I see no reason why assert is special.
<pippijn>
whitequark: you get warnings then
<pippijn>
assert (foo); blah blah
<pippijn>
"unsound type"
<wmeyer>
this is fine as long as the result is not used anymore, which happens with non-local control flow
<whitequark>
As a special case, assert false is reduced to raise (Assert_failure ...), which is polymorphic (and is not turned off by the -noassert option).
<wmeyer>
raise is special and assert is special because the value returned is not used
<whitequark>
I think the option -noassert is why
<whitequark>
I don't think you can specially handle assert false with an external
<pippijn>
raise FooExn; blah blah;
<pippijn>
this gives you a warning
<pippijn>
assert (1 = 1); blah blah;
<whitequark>
oh also
<pippijn>
this does not
<mrvn>
whitequark: it could be %assert and optimize accordingly.
<whitequark>
Otherwise, the exception Assert_failure is raised with the source file name and the location of expr as arguments.
<whitequark>
it also accesses the syntactic features of `expr'
<mrvn>
pippijn: because in the true branch assert returns ()
<whitequark>
so you can get one line of backtrace even without +b
<pippijn>
mrvn: but the typer doesn't know that 1 = 1
<pippijn>
mrvn: so assert (1 = 1) still returns 'a
<mrvn>
pippijn: doesn't matter
<pippijn>
yes it does
alang_ has joined #ocaml
<mrvn>
# let f x = if x then () else raise (Assert_failure ("file", 1, 0));;
<mrvn>
val f : bool -> unit = <fun>
chrisdotcode has joined #ocaml
<mrvn>
pippijn: That is what assert should be
<whitequark>
the "file", 1, 0 part already precludes it from being a function
<mrvn>
type wise
<whitequark>
or an external
<pippijn>
yes
<pippijn>
but it isn't
<pippijn>
because assert false is special
<mrvn>
whitequark: that is compiler magic. %assert could handle that.
<whitequark>
mrvn: that's some ugly magic :/
<pippijn>
whitequark: %identity is magic, too
<whitequark>
pippijn: %identity works like a function
<mrvn>
whitequark: %name are simply compiler buildins
<whitequark>
mrvn: yes exactly
<mrvn>
and the %assert buildin could handle the -noassert option and assert false special case.
<whitequark>
%identity is a function. %assert is essentially a macro, in this case
<pippijn>
Warning 21: this statement never returns (or has an unsound type.)
<pippijn>
this is what you get with assert : bool -> 'a
<mrvn>
pippijn: it isn't -> 'a
<pippijn>
mrvn: I got it
<pippijn>
you want assert : bool -> unit
<pippijn>
but assert false is typed as bool -> 'a
<mrvn>
no
<pippijn>
so, too bad
<pippijn>
no?
<pippijn>
# let a : int = assert false;;
<pippijn>
Exception: Assert_failure ("", 1, 14).
<mrvn>
hmm, you are right
<mrvn>
didn't get that you ment "assert false" has a different type, only thought you ment it raises an exception even with assertions turned off. But you are right.
<wmeyer>
whitequark: this are not ugly compiler hacks, look at ugliness of a C compiler, so I'd not say about OCaml is uggly. There will be always some hacks and glitches in the compiler, however I think OCaml has a beautiful architecture
alang_ has quit [Ping timeout: 264 seconds]
* whitequark
looks at LLVM
<pippijn>
haha
<whitequark>
:p
<wmeyer>
whitequark: LLVM is not top notch lol
<pippijn>
not at all
<whitequark>
show me something top notch?
<wmeyer>
look at what Norman Ramsey does
<mrvn>
assert false should be impossible ()
<wmeyer>
whitequark: well, C--, SLED, Lambda-RTL
<mrvn>
or Raise Impossible
<mrvn>
s/R/r/
<pippijn>
c-- is really good
<whitequark>
C--, yeah, top notch, yeah
* whitequark
has stopped reading after that
<mrvn>
whitequark: B?
<wmeyer>
whitequark: you may think like this, but I prefer much more even outdated burg selector than what LLVM does, bleeeh
* pippijn
likes BURS
<wmeyer>
with the new paper, based on RTL semantic information, the selector is even better
<whitequark>
wmeyer: what specifically you dislike in LLVM, I am curious?
ontologiae_ has quit [Ping timeout: 268 seconds]
<wmeyer>
whitequark: it contains 10x more code than it should?
alang_ has joined #ocaml
<wmeyer>
and btw, they don't have pattern matcher, they have single IR
<wmeyer>
what is good in LLVM you think then?
<wmeyer>
tablegen does not impress me
<wmeyer>
unlucky me, I worked full time on LLVM, and full time on a C++ compiler
<whitequark>
it's fast and generates fast code?
<pippijn>
I worked on a C++ frontend with you
<pippijn>
I feel lucky about that
<wmeyer>
that was a good project pippijn
<pippijn>
whitequark: gcc produces fast code, too
<pippijn>
and the architecture is a mess
<whitequark>
pippijn: gcc is pretty much unmaintainable
<whitequark>
llvm isn't
<pippijn>
(gcc is getting better, but I'm not going to push that argument)
<wmeyer>
still LLVM is not a bleeding edge in the compiler community
<whitequark>
oh, it sure isn't
<wmeyer>
so why to be impressed? :-)
<whitequark>
but it is something I can plug into my compiler and make it work rather good, right now
<whitequark>
I don't honestly see an alternative for that use case
<wmeyer>
your choice, and your opinion
walter has quit [Quit: This computer has gone to sleep]
<wmeyer>
have nothing to do with that
<pippijn>
actually c-- could be an alternative
<pippijn>
or.. what's it called..
<wmeyer>
exactly
<wmeyer>
Quick C--
<pippijn>
wmeyer: that IR for SML
<wmeyer>
MLRISC
<wmeyer>
yes
<pippijn>
yeah, that
<wmeyer>
what they do in 2010 is actually much more advanced however
<whitequark>
C-- only works on x86
<pippijn>
whitequark: I consider targetting llvm similar, only slightly better, than targetting C
<whitequark>
it's hilarious that you suggest it
roboguy_ has quit [Remote host closed the connection]
<pippijn>
whitequark: mlrisc has alpha, x86_64, hppa, i386, ppc and sparc
<whitequark>
pippijn: that doesn't really change anything
<wmeyer>
whitequark: yes it does not :-)
<whitequark>
I don't see the most popular platform there anyway :)
<whitequark>
ARM, that is.
<pippijn>
wmeyer: nice
<wmeyer>
whitequark: it's a plain discussion, but let me tell you something, you are very fast at judging people's good work
Neros_ has joined #ocaml
<wmeyer>
at the same time you don't see the whole research put into the compilers
<whitequark>
I'll quote myself: "something I can plug into my compiler and make it work rather good, right now"
<whitequark>
there is a *lot* of value in that
Neros has quit [Read error: Operation timed out]
<whitequark>
I'm not saying C-- isn't good. I am saying it is not practical, not supporting the most popular platform around
<wmeyer>
whitequark: why not contribute a backend :D
* pippijn
would still use it, and write an x86_64 backend
<pippijn>
I'm like that ;)
<wmeyer>
that's good
<whitequark>
wmeyer: I don't think you quite realize the amount of work needed to write a good ARM backend
<pippijn>
I like using good software rather than popular software
ontologiae_ has joined #ocaml
<pippijn>
whitequark: I think he quite does
<wmeyer>
whitequark: i said LLVM does it 10x more than needed
<whitequark>
then he surely cannot be serious in his suggestion
srcerer has joined #ocaml
<pippijn>
wmeyer knows what writing compilers and backends means
<whitequark>
wmeyer: if I have to do none of it, LLVM is still better for me.
<pippijn>
LLVM is good for quick results
<whitequark>
exactly
<wmeyer>
yes, LLVM is approximetly a good choice, and good community around, but I have to say this compiler framework is disapointing to me
<whitequark>
it depends on your expecttations :)
<wmeyer>
it's better than gcc
<wmeyer>
still
<wmeyer>
but not even sub optimal
<wmeyer>
and it's C++
<whitequark>
... and because it's C++ I can link to it from whatever language I like
<wmeyer>
with hurdle
<whitequark>
which is better than "no, you *have* to use Haskell"
<whitequark>
(replace haskell with any language)
<wmeyer>
how about a DSL
<whitequark>
I'm not aware of any non-C-family language which can present a C ABI to the outside world and that would just work
<pippijn>
whitequark: aldor ;)
<pippijn>
but aldor is useless for now
<whitequark>
pippijn: foundry ;)
<whitequark>
and same
<whitequark>
wmeyer: a DSL?
<pippijn>
At present, Quick C-- has another significant limitation: it can-
<pippijn>
not use software libraries to implement RTL operators that are not
<pippijn>
supported in hardware.
alang__ has joined #ocaml
<pippijn>
that's a pity
<pippijn>
I wonder why not
<pippijn>
softfloat is important
<pippijn>
wmeyer: is this work open source?
<whitequark>
wmeyer: if you mean passing strings to backend, then it has a problem that you cannot query your backend for capabilities, etc
<wmeyer>
pippijn: If I had an idea, haven't seen any sources! but they claim they build backends :-)
<pippijn>
yeah, I saw that
<pippijn>
whitequark: are you planning GC or region inference?
<whitequark>
pippijn: regions plus user-definable allocators
<pippijn>
you have a syntax, right?
alang_ has quit [Ping timeout: 240 seconds]
<whitequark>
a syntax?
<pippijn>
a grammar
ollehar has quit [Ping timeout: 240 seconds]
<pippijn>
an abstract+concrete syntax
<whitequark>
well... yes? how could I not have it
<pippijn>
you don't need a syntax as first step when creating a language
<whitequark>
sure
<pippijn>
ok, so you have one
<pippijn>
you have a concrete syntax, too?
<whitequark>
yes
<pippijn>
any examples?
<whitequark>
it looks and feels mostly like Ruby
<pippijn>
is it typed?
<whitequark>
yep
<pippijn>
seems nice
alang__ has quit [Ping timeout: 268 seconds]
<pippijn>
so, region inference and allocators
<pippijn>
no GC?
<pippijn>
oh, region *inference* or manual?
<whitequark>
there will be facilities for exporting stack maps and introspecting type layout
<pippijn>
ok
<whitequark>
so one could write a GC, and there will be one in stdlib
<whitequark>
region inference
<pippijn>
good
<pippijn>
how do you export stack maps?
<pippijn>
you ask the rt "give me all stack maps"?
<whitequark>
cooperation with LLVM
<pippijn>
or you get one per function?
<pippijn>
I mean, how do you ask for them?
<whitequark>
ah. I didn't implemented this yet, but the plan is to have one per function
<whitequark>
and get the runtime to unwind the stack
<pippijn>
on program start, you collect all stack maps and provide an interface to a map of some kind?
<pippijn>
oh
<pippijn>
so the runtime will do that
<whitequark>
no, not like that. I ask the runtime to mark stack roots
<whitequark>
that's how it is visible to the user
<whitequark>
then it calls the GC-provided mark function
<pippijn>
the runtime will give a stack map for the current PC
<whitequark>
the machinery inside will most likely build and traverse a shadow stack
<pippijn>
how does FFI look?
<pippijn>
oh.. shadow stack
<pippijn>
that's expensive
<pippijn>
every pointer is a double indirection
<whitequark>
that's my first approximation
<pippijn>
that's fine
<pippijn>
ok
<whitequark>
FFI... you specify an explicit and concrete function signature, then specify the linkage name
<whitequark>
and it exports/imports the symbol
<pippijn>
ok
<pippijn>
and it pins all outgoing pointers?
<pippijn>
when calling C
ontologiae_ has quit [Ping timeout: 240 seconds]
<whitequark>
not quite. when I pass a pointer of some Foundry structure to C, it's an opaque value which C code can not introspect
<whitequark>
the only way it can interact with it is to call Foundry-provided functions
<pippijn>
ok, and you will pass the double indirection to C?
<whitequark>
(which LLVM's LTO will optimize to simple accesses)
<whitequark>
I focus on memory-restricted embedded applications
<pippijn>
do you have uniform representation?
<whitequark>
so the idea is that you will use GC as rare as it is possible
<pippijn>
packable arrays?
<pippijn>
like, packed char arrays
<whitequark>
most (often all) pointers will point to: 1) static data structures 2) stack-allocated ones 3) manually allocated ones in pools/heaps.
<whitequark>
uniform representation like tagged pointers in ocaml?
<pippijn>
like "everything is a word"
<whitequark>
no, I don't. I have user-definable value types
<pippijn>
char is a word, int is a word, pointer is a word
<whitequark>
so I also have monomorphization
<pippijn>
ok
<pippijn>
good
<pippijn>
I'm going home, it's late :)
<pippijn>
and I slept 3 hours last night
<whitequark>
sure, I'll be happy to continue this conversation
<whitequark>
ping me :)
<pippijn>
yeah, next time
<pippijn>
I'm curious
<pippijn>
good night
<whitequark>
night
<whitequark>
wmeyer: to summarize. I never meant that C-- was bad project, or bad research, or whatever. I'm just saying that "works right now" is a very good trait which most projects, good or bad, don't have.
<whitequark>
if it seemed some other way, then I suck at proper wording.
pygmalion has joined #ocaml
<whitequark>
it would take an enormous amount of work to amend C-- so that it will work for my use case, and it isn't even clear if the result would work better than LLVM. (you can't say for sure, can you?)
pygmalion has quit [Ping timeout: 240 seconds]
<wmeyer>
whitequark: no offense here taken :-) But you have to be careful when you say something is ugly, it was numerous times when you criticised some code, not having too much knowledge about the whole picture, I have to say it's best to avoid such comments.