<rgrinberg>
good job shilling for OCaml on HN everyone :D
jbrown has quit [Remote host closed the connection]
reem has joined #ocaml
<Algebr>
rgrinberg: link?
<Drup>
rgrinberg: I don't usually frequent HN, is the crowd very different from reddit ? if so, no thanks.
<Algebr>
Its better than reddit.
SomeDamnBody has joined #ocaml
<vanila>
is there a site better than HN?
<dmbaturin>
Speaking of which, I wonder what's Graham's opinion about statically typed functional languages. He never wrote about if AFAIR.
<vanila>
hes probably wise not to get into that debate, can only really lose followers
<Drup>
graham ?
rgrinberg has quit [Quit: Leaving.]
Haudegen has joined #ocaml
<dmbaturin>
vanila: Well, he never falls into pathological lisp advocacy, I don't think anyone would mind him participating in that debate in constructive ways.
<dmbaturin>
(If calling something the most powerful language doesn't count as pathological advocacy on its own :)
<dmbaturin>
Drup: Paul Graham and friends wrote hacker news in their own lisp.
<rgrinberg>
it's mostly the same type of people but a wider audience
swgillespie has joined #ocaml
swgillespie has quit [Client Quit]
wagle has quit [Remote host closed the connection]
<Drup>
wider audience ?
reem has quit [Remote host closed the connection]
reem has joined #ocaml
<rgrinberg>
well, on reddit it's mostly OCaml programmers only
<rgrinberg>
even proggit is smaller than HN
<Drup>
I was think r/programming, not r/ocaml
<Drup>
thinking*
<rgrinberg>
oh, well HN is bigger than r/programming and I *think* is more receptive to FP
<Drup>
that's not difficult
<dmbaturin>
Are there XML libs that support XPath? Alternatively, which XML library should I use if I need to make some internal representation out of XML data?
<Drup>
dmbaturin: xmlm
<Drup>
and no XPath support
<dmbaturin>
Generally, I don't mind looking up nodes in the internal representation by hand, as long as creating that representation from XML is not too much headache.
moei has quit [Read error: Connection reset by peer]
moei has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
oscar_toro has quit [Ping timeout: 250 seconds]
Jefffrey has quit [Quit: Leaving...]
zpe has joined #ocaml
reem has quit [Remote host closed the connection]
rgrinberg has quit [Quit: Leaving.]
darkf has joined #ocaml
ollehar1 has quit [Quit: ollehar1]
rgrinberg has joined #ocaml
zpe has quit [Ping timeout: 246 seconds]
reem has joined #ocaml
reem has quit [Remote host closed the connection]
wagle has joined #ocaml
mcclurmc has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
reem has quit [Read error: Connection reset by peer]
reem has joined #ocaml
jeroud has quit [Ping timeout: 245 seconds]
jeroud has joined #ocaml
jyc has quit [Ping timeout: 245 seconds]
mekaj has quit [Ping timeout: 245 seconds]
jyc has joined #ocaml
mekaj has joined #ocaml
The_Mad_Pirate has quit [Remote host closed the connection]
jyc has quit [Ping timeout: 245 seconds]
jyc has joined #ocaml
reem has quit [Remote host closed the connection]
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
badkins_ has joined #ocaml
badkins has quit [Ping timeout: 264 seconds]
reem has joined #ocaml
keen__________63 has joined #ocaml
keen__________62 has quit [Ping timeout: 250 seconds]
prsn has joined #ocaml
<prsn>
hi! I am basically a noob at ocaml, and I'm having an issue with tuareg-mode that I fear is me misunderstanding something about the language. When I type a sinle imperative line ending in ;;, tuareg mode indents the next line, which seems incorrect.
<prsn>
am I missing something?
<dmbaturin>
prsn: You should not use ";;" outside of the REPL. Also, ;; works as an expression separator, in sequences of statements you should use a single ;.
<prsn>
ah, i see, i was reading example code that was intended for the repl
reem has quit [Remote host closed the connection]
<prsn>
thanks
<prsn>
though.. using a single ; seems to cause it to indent even further
<dmbaturin>
If you need to call something for its side effect in the top level, use "let () = ..." matching as in let () = print_endline "hello"
<prsn>
ok
bitbckt has quit [Ping timeout: 245 seconds]
<dmbaturin>
As of the tuareg-mode indent issue, I can't really say anything as I don't use it. But some people here do.
hbar has quit [Ping timeout: 255 seconds]
bitbckt has joined #ocaml
bitbckt has joined #ocaml
mekaj has quit [Ping timeout: 245 seconds]
chris2 has quit [Ping timeout: 245 seconds]
reem_ has joined #ocaml
mekaj has joined #ocaml
struktured has quit [Read error: Connection reset by peer]
_habnabit has quit [Ping timeout: 245 seconds]
struktured has joined #ocaml
_habnabit has joined #ocaml
q66 has quit [Quit: Leaving]
hbar has joined #ocaml
alpen has quit [Ping timeout: 245 seconds]
mawuli has quit [Ping timeout: 245 seconds]
struktured has quit [Remote host closed the connection]
alpen has joined #ocaml
struktured has joined #ocaml
robink has quit [Ping timeout: 245 seconds]
rossberg has quit [Ping timeout: 245 seconds]
chris2 has joined #ocaml
rossberg has joined #ocaml
mawuli has joined #ocaml
robink has joined #ocaml
badkins_ has quit []
ggole has joined #ocaml
reem_ is now known as reem
mekaj has quit [Ping timeout: 245 seconds]
mekaj has joined #ocaml
alpen has quit [Ping timeout: 245 seconds]
hbar has quit [Ping timeout: 256 seconds]
alpen has joined #ocaml
bjorkintosh has quit [Ping timeout: 252 seconds]
bjorkintosh has joined #ocaml
hbar has joined #ocaml
hbar has quit [Ping timeout: 256 seconds]
<prsn>
What does "<|b|>" in ocamldebug source context mean? (it's not there in the sourcefile)
hbar has joined #ocaml
swgillespie has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
slash^ has joined #ocaml
chinglish has quit [Quit: Nettalk6 - www.ntalk.de]
<whitequark>
breakpoint, perhaps?
<prsn>
having played with it more, i think it's more like an indicator of where execution is, but there's also <|a|> and I don't know the difference
Submarine has joined #ocaml
Submarine has joined #ocaml
Simn has joined #ocaml
Kakadu has joined #ocaml
SomeDamnBody has joined #ocaml
SomeDamnBody has quit [Ping timeout: 250 seconds]
tane has joined #ocaml
mort___ has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
Submarine has quit [Quit: Leaving]
govg has quit [Ping timeout: 245 seconds]
rgrinberg has joined #ocaml
reem has quit [Remote host closed the connection]
reem has joined #ocaml
AlexRussia has joined #ocaml
reem has quit [Remote host closed the connection]
govg has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
tokenrov1 has joined #ocaml
smondet_ has joined #ocaml
jlouis_ has joined #ocaml
myst|wor1 has joined #ocaml
flasheater has joined #ocaml
bitemyap1 has joined #ocaml
tizoc` has joined #ocaml
dmbaturin_ has joined #ocaml
trystero has joined #ocaml
tristero has quit [*.net *.split]
myst|work has quit [*.net *.split]
bugabinga has quit [*.net *.split]
tokenrove has quit [*.net *.split]
tizoc has quit [*.net *.split]
bitemyapp has quit [*.net *.split]
dmbaturin has quit [*.net *.split]
jlouis has quit [*.net *.split]
smondet has quit [*.net *.split]
thizanne has quit [*.net *.split]
thizanne has joined #ocaml
contempt has quit [Disconnected by services]
contempt has joined #ocaml
reem has joined #ocaml
reem has quit [Ping timeout: 245 seconds]
igstan has joined #ocaml
igstan has quit [Client Quit]
mawuli has quit [Ping timeout: 245 seconds]
rossberg has quit [Ping timeout: 245 seconds]
rossberg has joined #ocaml
mawuli has joined #ocaml
gargaml has joined #ocaml
reem has joined #ocaml
lordkryss has joined #ocaml
bitbckt has quit [Ping timeout: 245 seconds]
jyc has quit [Ping timeout: 245 seconds]
reem has quit [Remote host closed the connection]
struktured has quit [Read error: Connection reset by peer]
igitoor has quit [Ping timeout: 245 seconds]
struktured has joined #ocaml
igitoor has joined #ocaml
_habnabit has quit [Ping timeout: 245 seconds]
bitbckt has joined #ocaml
bitbckt has quit [Changing host]
bitbckt has joined #ocaml
_habnabit has joined #ocaml
jyc has joined #ocaml
<gasche>
prsn: before/after I suppose
_habnabit has quit [Ping timeout: 245 seconds]
<gasche>
(I used the debugger recently; it's rather nice (although Emacs seemed confused about locations), but I still wouldn't use it very often)
Nahra has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
reem has joined #ocaml
<flux>
maybe it's your color setup somehow. you could try going over one of the symbols and using M-x customize-face on it.
<Drup>
asQuirreL: what are the problems ? =')
<asQuirreL>
flux, yeah thanks, that's essentially what I ended up doing, the default operator syntax highlighting set its own background for some reason, so I removed it
<Drup>
a part from the weird background
<asQuirreL>
Drup, just the weird background :P
<asQuirreL>
I found it quite distracting
<Drup>
ah, yeah, that's just your specific color-theme
<Drup>
tuareg doesn't do anything about it, I'm not sure how you managed to have that
<asQuirreL>
Yeah... previous faces didn't have that issue... but looking at the tuareg source, they are using this (background light) function, which I feel may be the source of the issue
<Drup>
hum, that's surprising
<asQuirreL>
(but then when I switch to the light version of my theme, the operators are still highlighted but now in a shade of yellow which is actually darker than the background)
<asQuirreL>
and evaluating (background light) myself gives me a void-function error, but I'm willing to leave this as an unsolved mystery...
<gasche>
adrien: it's on the list of things I must not be because I do not have the time
<gasche>
I'll let other people discuss the thing -- I only merge when it's ok to do so
<gasche>
that said, I'm fine with your project
<gasche>
it's not clear from your description whether the targets world.opt and install are changed or not
Submarine has joined #ocaml
Submarine has joined #ocaml
<adrien>
no, they aren't
<gasche>
(but I don't understand why they would be; I would rather expect the *internal* build steps to change)
<gasche>
that was my only potential qualm
<adrien>
gasche: only one question : do you use the debugguer to debug the compiler? and if so, how do you spawn it? :)
Haudegen has quit [Ping timeout: 245 seconds]
<gasche>
no
<adrien>
thanks
Haudegen has joined #ocaml
antkong has quit [Ping timeout: 250 seconds]
thorsten` has quit [Ping timeout: 240 seconds]
thorsten` has joined #ocaml
Nahra has joined #ocaml
Guest29895 is now known as andreypopp
ebzzry has quit []
ebzzry has joined #ocaml
darkf_ has joined #ocaml
darkf has quit [Ping timeout: 252 seconds]
asQuirreL has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
reem has quit [Remote host closed the connection]
jcdyer has joined #ocaml
matason has joined #ocaml
asQuirreL has joined #ocaml
darkf_ is now known as darkf
w0rp has quit [Read error: Connection reset by peer]
w0rp has joined #ocaml
asQuirreL has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
asQuirreL has joined #ocaml
baz_ has joined #ocaml
tane has quit [Quit: Verlassend]
c74d has quit [Ping timeout: 252 seconds]
jcdyer has quit [Ping timeout: 265 seconds]
reem has joined #ocaml
reem has quit [Ping timeout: 250 seconds]
ontologiae has joined #ocaml
matason has quit [Ping timeout: 245 seconds]
oriba has joined #ocaml
mort___ has quit [Quit: Leaving.]
tizoc` is now known as tizoc
baz_ has quit [Quit: baz_]
oriba_ has joined #ocaml
oriba_ has quit [Client Quit]
oriba has quit [Ping timeout: 264 seconds]
oriba has joined #ocaml
RossJH has joined #ocaml
hekmek has joined #ocaml
enitiz has joined #ocaml
leowzukw_ has joined #ocaml
leowzukw has quit [Ping timeout: 246 seconds]
oriba has quit [Quit: Verlassend]
prsn has quit [Quit: Lost terminal]
ollehar1 has joined #ocaml
ontologiae has quit [Ping timeout: 265 seconds]
mort___ has joined #ocaml
hilquias` has joined #ocaml
mort___ has quit [Client Quit]
hilquias has quit [Ping timeout: 255 seconds]
ebzzry has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
<adrien>
what's ocamlbuild*light* for?
<adrien>
I don't remember well
<adrien>
(it's in the compiler)
<adrien>
jpdeplaix, gasche ^
<adrien>
main difference is that it doesn't depend on Unix
<adrien>
which was useful for the bootstrap
<adrien>
and I wonder if it's still useful
Anarchos has joined #ocaml
Thooms has joined #ocaml
Submarine has quit [Ping timeout: 244 seconds]
q66 has joined #ocaml
tane has joined #ocaml
jcdyer has joined #ocaml
mcclurmc has quit [Read error: Connection reset by peer]
mcclurmc has joined #ocaml
wwilly has joined #ocaml
The_Mad_Pirate has joined #ocaml
<adrien>
also, is there anyone using ocamlbuild on a setup which doesn't have Unix?
<adrien>
mrvn: ^
reem has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
reem has quit [Ping timeout: 265 seconds]
SomeDamnBody has joined #ocaml
tnguyen has joined #ocaml
tnguyen has quit [Client Quit]
kandu has quit [Remote host closed the connection]
<Anarchos>
adrien yes
<whitequark>
what is that?..
<Anarchos>
adrien oh you mean the Unix module ?
<Anarchos>
i have the Unix module available, though not on a *nix/*nux platform
kapil__ has quit [Quit: Connection closed for inactivity]
<whitequark>
yes
darkf has quit [Quit: Leaving]
govg has quit [Quit: leaving]
petrus has joined #ocaml
sivoais has quit [Ping timeout: 255 seconds]
SomeDamnBody has quit [Ping timeout: 246 seconds]
chinglish has joined #ocaml
sivoais has joined #ocaml
kandu has joined #ocaml
MercurialAlchemi has joined #ocaml
<adrien>
Anarchos: yes, I was asking about the Unix module
mcclurmc has joined #ocaml
Haudegen has quit [Ping timeout: 246 seconds]
ontologiae has joined #ocaml
Submarine has joined #ocaml
ontologiae has quit [Ping timeout: 246 seconds]
Anarchos has quit [Ping timeout: 246 seconds]
waneck has joined #ocaml
mort___ has joined #ocaml
Haudegen has joined #ocaml
enitiz has quit [Quit: Leaving]
enitiz has joined #ocaml
chinglish has quit [Ping timeout: 264 seconds]
chinglish has joined #ocaml
keen__________64 has joined #ocaml
keen__________63 has quit [Ping timeout: 245 seconds]
<jpdeplaix>
adrien: I don't know :/
<adrien>
thanks :)
<adrien>
you're actually proving that it can be removed ;-)
<Drup>
wasn't it used at some point to build camlp4 ?
<Drup>
or the tk thingy
<adrien>
in our youth
<adrien>
ocamlbuild was used to build camlp4
<adrien>
and ocamlbuild bootstrapped itself
<Drup>
:|
<adrien>
since bytecode is only portable modulo Unix stubs, it was useful
<adrien>
now camlp4 isn't built with ocamlbuild anymore
<adrien>
it's not part of the distribution anymore
<adrien>
and ocamlbuild doesn't bootstrap itself anymore
<adrien>
(and the files have disappeared from boot/ too)
enitiz has quit [Read error: Connection reset by peer]
<adrien>
whitequark: commenting on mantis now
trystero is now known as tristero
oriba has joined #ocaml
Simn has joined #ocaml
Anarchos has joined #ocaml
rgrinberg has joined #ocaml
<Anarchos>
Does Map.iter modify in-place ?
MooseAndCaml has joined #ocaml
<Drup>
of course not, Map is not mutable
<mrvn>
Map.iter doesn't modify at all
<mcc>
anarchos: what do you mean by "modify"? Map.iter returns type unit
<mcc>
anarchose:as does its argument function
<MooseAndCaml>
Hi, can some one decipher this "Error: This expression has type Narr.n list but an expression was expected of type n list Type Narr.n is not compatible with type n" .. Both this function and n are inside the module Narr
<mrvn>
did you use Narr.n somewhere inside Narr?
<Drup>
MooseAndCaml: pastebin the whole module please
<mrvn>
if you use the module name inside a module then ocaml gets confused
chinglish has quit [Quit: Nettalk6 - www.ntalk.de]
<Drup>
(fwiw: next time, add .ml, it will give syntactic coloration)
hekmek has quit [Quit: Verlassend]
<mcc>
mooseandcaml: on what line is the error?
<MooseAndCaml>
oof.. I forgot the module name is my toplevel test -- let b = inject_vel_var (L1.hd a);; Its working with let b = Narr.inject_vel_var (L1.hd a);;
<Drup>
it's in the top level
<Drup>
let met guess, you loaded something twice and you open the old one only
mort___ has quit [Quit: Leaving.]
<MooseAndCaml>
i don't know. I think that error is just the module. Though the last function in that code is delivering an empty list.. Is that not a workable scoping for acc in inject_vel_var?
<Drup>
it's pretty hard to tell without knowing what you did exactly, and we can't test without the rest of the code.
Thooms has quit [Quit: WeeChat 1.0.1]
<MooseAndCaml>
For, writing it out helped me out of that rut, Ill keep at it. Thanks
<Drup>
(by curiosity, what are you doing with midi ? :D)
leowzukw has joined #ocaml
leowzukw_ has quit [Ping timeout: 252 seconds]
<MooseAndCaml>
Right now midi is just a convenient format for a narrative idea I'm working on. Lets me do some gruesome annotation work in a music sequencer
rgrinberg has quit [Quit: Leaving.]
ontologiae has joined #ocaml
<mcc>
neat
ontologiae has quit [Ping timeout: 252 seconds]
leowzukw has quit [Quit: Lost terminal]
<mcc>
whitequark: so atm i am just trying to decide how many exception types to make
<mcc>
whitequark: because there are various kinds of errors that can happen, and sometimes i care about the distinction between errors, and sometimes i do not
<mcc>
so like, there could be a "program is incomplete" error, or a reader error, or a macro/parsing error, or an error during execution
<mcc>
and if i had four exception types then catching them all gets messy
<mcc>
what i wound up doing is making a CompilationError and there's gonna be an ExecutionError
<mcc>
(apologies for lack of underscores)
<mcc>
and the constructor for CompilationError takes an enum that's like Incomplete|Invalid|Macro or something
<mcc>
so then i just match on that
<mcc>
what's frustrating
<mcc>
is i'm concerned at some point macros might have complex structure to their errors
<Drup>
is making lot's of different errors really worse than making an error with lots of sub errors ?
<mcc>
Yes.
<Drup>
I.. don't really see how, but ok ^^
<mcc>
Because in those situations where I don't care about sub-errors, I can pattern-match away the sub-error part.
<mcc>
If I _ that field it becomes one single exception catch. Right?
ghostpl has joined #ocaml
<Drup>
well, you can catch all errors too
qqr_ has joined #ocaml
<Drup>
but I suppose you have a common part with locations and all that, right
<mcc>
okay, maybe this is what i am missing. how do i do that?
<Drup>
try .. with e -> do_things_with e
<Drup>
it will catch all errors
<mcc>
huh, ok
<mcc>
is e an "object"?
<Drup>
it's an exception
<mcc>
is this the promised "objective" in "objective caml"?
<mcc>
okay
<ggole>
Exceptions are just values
<mcc>
yes, but normally i can't have an "e" and "e is either an int, or a string"
<ggole>
They're basically an open ended variant
<Drup>
sure you can have a "e"
<Drup>
let x = Failwith "bla"
<Drup>
there you go
<Drup>
you have an exception
<Drup>
you can even pattern match on it
<mcc>
but it sounds like I can have an "e" and "e is either a CompilationError, or an ExecutionError, or a Sys.Break"
oriba has quit [Quit: Verlassend]
<ggole>
If you want those things and nothing else, you need a type for that
reem has joined #ocaml
rand000 has joined #ocaml
<ggole>
But you might as well just define them as exceptions (unless there's something I'm missing)
<mcc>
so if I say "try ... with e -> do_things_with e" ... inside do_things_with e, how do I pattern-match e to discriminate it into a CompilationError or a Sys.Break?
<ggole>
Just match on it
<Drup>
match e with ...
<ggole>
You'll have to have a catch-all clause because exceptions are open
<mcc>
ok cool
<ggole>
But other than that, it's just matching
<whitequark>
try .. with CompilationError | ExecutionError | Sys.Break ->
<whitequark>
also works
<Drup>
indeed
<mcc>
i am trying to understand what kind of language construct this is-- the "open ended variant" idea. are there open ended variants other than exceptions in this language, or is exception special because it is useful to make it special?
<Drup>
it was a special case until 4.02
<Drup>
now, you can define new open variants
<ggole>
You can encode them manually
<ggole>
But it's a bit strange
swgillespie has joined #ocaml
<mcc>
uh oh
<mrvn>
are exceptions now open types or still their own magic?
<Drup>
mrvn: open types
<mcc>
so i want to look for open types in the manual if i want to understand this
<Drup>
from the typing point of view at least
<mcc>
May I express the opinion that this language seems to have added a BUNCH of features between 4.01 and 4.02
<ggole>
(Although I'm probably leading you down a bit of a rabbit hole here...)
<mcc>
well, it's interesting from a language design perspective
<mcc>
so i think... the thing that was really frustrating me with exceptions
swgillespie has joined #ocaml
<Drup>
mcc: an example of encoding is, for example, to encode sum types in arrays where the first element is an integer
<Drup>
you can totally do sum types in C with that
<Drup>
(it's arguably insane, but you *can*)
<mcc>
drup: i'm sorry you've lost me
<Drup>
give me a sec !
<mcc>
ok
<mcc>
so, i sit down and i think: I need an exception for "run failed". it could be of type "incomplete program", "invalid program", "failure during execution".
rgrinberg has joined #ocaml
<mcc>
so okay, i will make an exception, and i will give it an enum for Incomplete|Invalid|ExecuteFail
<mcc>
but then i realize i cannot do that, because the ExecuteFail should have some additional informaiton along with it, but that information uses types which haven't been defined yet. i have a module dependency issue.
<mcc>
the module that defines the types relevant to an execution failure has to come after the module where this exception is defined.
<mcc>
i then realized that actually, there are totally unrelated reasons why it is not a good idea to pack the "couldn't parse program" and "failed at runtime" into a single exception type.
<mcc>
So... actually, everything is okay.
<mcc>
But! I feel like that was a coincidence. If things were just a little different, I'd want one exception type but be forced into two solely for module ordering reasons.
<mcc>
But...
<ggole>
Usually you would define the exceptions in that module
<ggole>
Or do something sloppy like use strings
<mcc>
could i be like... exception UnifiedException = .. , say type UnifiedException += ExceptionKind1(blah), and then in a different module just say type OtherModule.UnifiedException += ExceptionKind2(blah2)?
<Drup>
don't do that, you will hate yourself when trying to introspect your exceptions
<mcc>
I believe you
<Drup>
(the string thingy)
<whitequark>
mcc: you can. type desc = ..;; exception Unified_exception of desc
<Drup>
mcc: for exceptions, you don't need "+="
<whitequark>
then in some other module type Unified.desc += Exception_kind_1 of blah
<mcc>
drup: okay, i guess see about the encoding, that is... odd
<Drup>
mcc you say it's odd, however lot's of C programmers are doing exactly that, in one way or another
<Drup>
manually
<mcc>
drup: yes but... that is why i am writing ocaml in the first place
<Drup>
oh sure
<mcc>
drup: so i don't have to do the terrible things i do in c
<Drup>
you are asking what is an encoding
<mcc>
ok understood
<mcc>
and you already told me encodings are weird
<Drup>
it's crafting one feature into another :p
<mcc>
whitequark: there's... so the difference there is that I have to add the constructor each time?
<Drup>
(and btw, this exactly how sum types are compiled)
<mcc>
or…
<mcc>
oh! oh i see now. cool.
mcclurmc has quit [Remote host closed the connection]
<mcc>
The way it converts uncaught exceptions to strings seems odd
<whitequark>
what does? O_o
<whitequark>
oh
<Drup>
(note that with depends types, you can make this encoding as safe as normal sum types n__n)
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
mcclurmc has quit [Ping timeout: 252 seconds]
<mcc>
'k
<ggole>
It's looking at the runtime representation of int-or-pointer and guessing how to print it
<ggole>
Which is pretty damn nasty
<mcc>
yes, that sounds hard
<mcc>
...wait, hold on
<mcc>
how does it know Token.CompilationError is a Token.CompilationError, then?
<Drup>
it doesn't
<ggole>
The type is known
<mcc>
is this because of exception's special open-typeness?
<Drup>
oh, the exception, they have a special table, don't they ?
<ggole>
Oh, exceptions
<mrvn>
same way it knows that a type t = Foo | Bar | Baz is a Foo
<ggole>
They have a special thing, right
<Drup>
to be sure that dynlinking works
<Drup>
(among other things)
<mcc>
mrvn: the thing is, it knows Token.CompilationError is a Token.CompilationError, but it doesn't know that the first argument to CompilationError's constructor is a Token.IncompleteError, it prints "2"
<mcc>
or whatever
<ggole>
It's a bit limited in some ways
<mcc>
i just… is it the case then that the reason it can decode CompilationError but not IncompleteError because of exception specialness?
<ggole>
It shows how exceptions are printed "one deep"
<mcc>
Got it.
<mcc>
thx
<ggole>
toplevel printing isn't the most obvious of subjects.
<mcc>
I can imagine :O
<Drup>
It's a bit voodoo
<mcc>
Honestly, if toplevel printing worked much better than this, i think i'd be annoyed
<Drup>
"I will look at the runtime representation and guess"
<mcc>
because it would imply the toplevel giving itself polymorphism abilities that it didn't expose to the code.
<mcc>
the rest of us plebs have to use ppx_deriving
<mcc>
(which is very nice, btu)
<whitequark>
Drup: no it's not a special table
<whitequark>
open types have a string description inside them
<Drup>
it's less efficient than normal variants then
<Drup>
or rather, less compact
<mcc>
*thinks* is that necessarily the case? if the strings are unified, then a string description is just the cost of a pointer.
<mcc>
…or wait, are the tags in tagged unions less than 32 bits
<mcc>
someone said they cap at 128 or something
<Drup>
if all the constructor are constants, it's a full int
<Drup>
so 63 bits
<Drup>
if not, it's less than that, don't remember the details
<ggole>
Non-nullary variant tags are limited to, uh, 253 or something like that
<mcc>
'k
<ggole>
Exceptions don't use those afaik
oscar_toro1 has left #ocaml [#ocaml]
<mrvn>
wasn't that just 32bit?
<ggole>
Might have been?
<mrvn>
64bit has more bits in the GC word.
matason has joined #ocaml
<ggole>
I think that the exception representation is tag word + cookie word + string pointer and then args
<mrvn>
ggole: exceptions use open types now so that might have changed
<whitequark>
it had
<mcc>
is ocaml32 still supported
<whitequark>
sure. there aren't two separate ocamls
<ggole>
No, that's not right: I got confused by the assembly
<ggole>
tag word + cookie word + args
<ggole>
The cookie is unique for each exception definition, even if they have the same name (and including functor applications)
<Drup>
Use open types, they have cookies ! :O
<ggole>
It's an interesting little wrinkle in the implementation
<whitequark>
yeah. cookie is for dynlinking
<whitequark>
as well
<mcc>
dynlinking sounds hard
<whitequark>
not really
<mcc>
well, linking sounds hard
<mcc>
C's pretty bad at it anyway
<ggole>
The cookie is also for ruling out incorrect matches iirc
<ggole>
If you have a functor application F, it shouldn't catch the exception thrown from functor application G even though they come from the same line of source
qqr_ has quit [Quit: Leaving]
<ggole>
So they are allocated unique ids (dynamically)
<ggole>
Bit strange since it all looks static in the source
<whitequark>
mcc: ocaml's good at linking.
<whitequark>
and will be even better soon
<Drup>
whitequark: you are refering to first class dynlink ?
<mcc>
i thought i'd extracted a tuple out of a variant before
<whitequark>
ggole: that's a very rationalizing explanation :]
<whitequark>
mcc: that works with polymorphic variants
<whitequark>
that doesn't work with normal variants because [bogus reasons]
<mcc>
okay.
<ggole>
If you want the whole exception value, then with Foo as e -> do_thing e
<whitequark>
basically xavier leroy didn't like it
<whitequark>
that's all
<Drup>
whitequark: that works perfectly fine with variants .. if you had parens
<ggole>
There's a performance issue, it wasn't an oversight
<Drup>
type foo = Foo of int * int <- doesn't work
<whitequark>
ggole: it's a syntactic issue
<Drup>
type foo = Foo of (int * int) <- works
<whitequark>
purely
<Drup>
whitequark: it is *also* a memory representation thing
<ggole>
Go and look up the Cardelli optimisation
<Drup>
the two type I defined are not represented the same way
<Drup>
mcc: to answer your question, put parens around the type part of the exception definition
<Drup>
yes, it's insane, I agree, but it will work
slash^ has quit [Read error: Connection reset by peer]
Thooms has joined #ocaml
<whitequark>
Drup: you can have the same representation.
<whitequark>
the only thing you need to do is allocate when you match | Foo e, where Foo is many-argument
<mcc>
...oh
<mcc>
so what i was about to say, what I just did was I changed the pattern to "Token.CompilationError _ as e"
<mcc>
and then just altered errorString to take an exn
<Drup>
that's another question, and if you are willing to write a patch to get rid of the difference, then you will gain a free drink from be
<Drup>
from me*
JuggleTux has joined #ocaml
<whitequark>
Drup: isn't it going to get rejected?
<mcc>
Would y'all have a recommendation on whether putting parenthesis in the type definition, or just passing around the exn like that, would be better code practice?
<Drup>
if there is no performance cost, no
<whitequark>
... hrm
<Drup>
nicoo tried to work on something
<Drup>
related
<Drup>
mcc: put the parens
<Drup>
it's virtually free except on very performance intensive code path
<Drup>
and compiler error reports is not :)
<Drup>
whitequark: let me rephrase, though : "If there is no performance cost, I thing it will be accepted" ;)
<mcc>
okay.
mcclurmc has joined #ocaml
<Drup>
(I have neither control, influence or even insight on the core team :D)
<ggole>
Hmm, the difference would be visible with ==
<ggole>
Do people care about that?
<whitequark>
ggole: I am not aiming to change the memory representation
<whitequark>
or was that for mcc
<ggole>
The copying that you suggest is what would be visible with ==, I mean
<Drup>
ggole: compile everything with opam, see if things break.
<whitequark>
it wouldn't
<ggole>
let f = function Foo e -> e in f x == f x
<ggole>
False if it allocates.
<whitequark>
write the type of f.
<mcc>
== is scary
<Drup>
mcc: is it ?
<Drup>
well, you should almost never use it
<ggole>
whitequark: this wouldn't break existing code, but the nonequality would still be visible
<whitequark>
ggole: no, really, write the type of f
<whitequark>
the code you wrote does not compile
<whitequark>
typecheck, rather
<Drup>
?
mcclurmc has quit [Ping timeout: 246 seconds]
<ggole>
Isn't it clear what I mean?
<ggole>
(The 'in' is wrong, ok)
<whitequark>
val f : [ Foo of int * int ] -> int * int
<Drup>
once again
<whitequark>
(abusing the syntax a bit)
<Drup>
Foo of (int * int)
<whitequark>
no
<Drup>
and this code is valid
<whitequark>
Foo of int * int
<Drup>
I don't understand your point
<whitequark>
I don't understand yours
<whitequark>
ggole: oooooh
<Drup>
this code is valid for a certain definition of Foo ...
<whitequark>
f x == f x
<whitequark>
i read that as "f x == x"
<whitequark>
sorry
<Drup>
ah, okay, I see
<ggole>
I'm saying if you copy the tuple, the non-identity is visible. Nothing more.
<ggole>
I'm not even sure whether that matters or not.
<whitequark>
yes, sure, you're pointing out a valid thing
<whitequark>
i just misread
<ggole>
Righto.
antkong has joined #ocaml
Haudegen has quit [Ping timeout: 240 seconds]
<whitequark>
ggole: well, actually, no allocation required.
<whitequark>
# (Obj.magic (Foo (1,2)) : int * int);;
<whitequark>
- : int * int = (1, 2)
<whitequark>
the tag is not 0
<whitequark>
but it doesn't matter
<whitequark>
it's still a tuple
<whitequark>
and you could even do away with allocating a new Foo in Foo x where x is an ex-Foo itself
<ggole>
When you store it somewhere and the GC tries to relocate it you're gonna have a fun time
<whitequark>
why?
<ggole>
Because relocation writes over the tag word (iirc)
<whitequark>
well, that would break variants too :]
<whitequark>
I mean--this is a type-level trick, really
<ggole>
Wouldn't polymorphic equality/hashing also want to look at the tag?
<whitequark>
good point. let me see
<whitequark>
equality, no
<whitequark>
or rather it treats all non-special tags the same
<ggole>
type t = Bar of int * int | Foo of int * int;; (Obj.magic (Bar (1,2)) : int * int) = (Obj.magic (Foo (1,2)) : int * int) => false
<ggole>
It shouldn't look at the tags, so that's a problem.
<whitequark>
hrm.
jcdyer has left #ocaml [#ocaml]
<whitequark>
ohhhh
<whitequark>
first variant has tag 0
<whitequark>
not 1
<whitequark>
right.
<ggole>
You really have to allocate, I think
<ggole>
But that should work (identity thing notwithstanding), unless I'm missing something
<whitequark>
I could change compare.
<whitequark>
but changing hash will not do.
<whitequark>
I've seen discussions and this will not be accepted
Haudegen has joined #ocaml
<ggole>
Wait, how would you change compare?
<ggole>
You can't treat tuples specially unless there's some information that they are tuples
stux|RC-only has joined #ocaml
stux has left #ocaml ["Leaving"]
<ggole>
You'd have to do pointer-tagging or some crap like that (so that the heap layout is identical, but there is still some discriminatory info)
<whitequark>
oh
<whitequark>
yeah I can't
<whitequark>
allocation it is, so
<ggole>
tagless GC would do it
<ggole>
All you have to do is redesign the entire runtime and do a bit of research to figure out how to make it work
* ggole
so helpful
<Drup>
:D
c74d has joined #ocaml
ontologiae has joined #ocaml
antkong has quit [Ping timeout: 255 seconds]
matason has quit [Ping timeout: 252 seconds]
mlen has quit [Ping timeout: 255 seconds]
lightstep has joined #ocaml
mlen has joined #ocaml
SomeDamnBody has joined #ocaml
moei has quit [Quit: Leaving...]
moei has joined #ocaml
manu3000 has joined #ocaml
SomeDamnBody has quit [Ping timeout: 240 seconds]
enitiz has joined #ocaml
<whitequark>
ggole: actually that's not that hard
<whitequark>
i've been thinking of designing a similar runtime for my language
<ggole>
You run into a bit of trouble with polymorphism and generational GC
SomeDamnBody has joined #ocaml
<ggole>
It might be doable though
petrus has quit [Quit: WeeChat 1.1.1]
<Anarchos>
ggole ocaml did it, didn't it ?
<ggole>
Tagless GC? No.
<ggole>
OCaml heap blocks have the usual tag-word.
<nicoo>
whitequark, Drup : Regarding the evil parenthesis/memory representation issue, my suggestion should improve performance on 64 bits. I need to runs lots of code on 32 bits with memory profiling to know what the impact would be on those platforms (basically, I would need to bump alignment to 256 bits, which is costly, but it would possibly remove many allocations and indirections)
mcclurmc has joined #ocaml
<ggole>
That would hurt a fair bit for int32, float, etc
<mrvn>
32 byte per box? That would double the memory for small blocks on 64bit.
zpe has joined #ocaml
wwilly has quit [Quit: Leaving]
mcclurmc has quit [Ping timeout: 245 seconds]
<flux>
my gawd, sounds like PHP ;-)
zpe has quit [Remote host closed the connection]
<flux>
apparently an integer variable on PHP on a 64-bit platform takes.. 188 bytes :-o. and 72 bytes for 32-bit. that information must be wrong..
<mrvn>
whitequark: 'Foo of int * int' and 'Foo of (int * int)' can not have the same representation because of: type t = Foo of (int * int) | Bar of (int * int) let t = (1, 1) let foo = Foo t let bar = Bar t
<flux>
ah, 96 bytes comes from the fact it's put to a new bucket in a hash table, so that's a probabilistic cost. still, 48 bytes remains..
<mrvn>
type m = { mutable x : int; } let t = ({x = 1}, {x = 2}) let foo = Foo t let bar = Bar t let (x, y) = t let () = x.x <- 2 (foo, bar)
<mrvn>
flux: allocate 1000 of them and average
ggole has quit []
enitiz has quit [Ping timeout: 240 seconds]
<whitequark>
mrvn: I never suggested giving them same representation
<mrvn>
did I get the nick wrong?
lightstep has quit [Ping timeout: 250 seconds]
<flux>
mrvn, I think I can safely let the opportunity of looking into PHP memory consumption pass.
<whitequark>
mrvn: I think you've misunderstood me, rather
<whitequark>
I meant giving Foo of int * int and int * int same representation
<mrvn>
flux: past experience showed me ocaml needs 1x memory, perl 2x, python 4x.
<whitequark>
or rather, that they only differ by tag
enitiz has joined #ocaml
matason has joined #ocaml
<mrvn>
whitequark: which means Foo t and Bar t would both just set the tag and Bar would overwrite Foos tag. Or Foo and Bar copy the tuple destroying that it was shared before.
<mrvn>
whitequark: or would you still have Foo of int * int and Foo of (int * int)?
antkong has joined #ocaml
vanila has quit [Quit: Leaving]
antkong has quit [Ping timeout: 250 seconds]
mcclurmc has joined #ocaml
<whitequark>
the latter
<mrvn>
then what you want is already the case.
<whitequark>
what i wait is: type t = Foo of int * int; match Foo (1,2) with Foo x -> x
<whitequark>
note the distinct lack of parentheses
<mrvn>
which already has the same memory representation
<mrvn>
Note that "Foo x -> x" needs an allocation to keep polymorphic comparisons working.
<Drup>
whitequark: if you don't change the memory representation and do a copy during the pattern match, the argument is going to be that the copying is not syntactically visible in the program, you need to go and look how Foo is defined
<Drup>
and it's a rather valid point
<Drup>
(the argument against inclusion)
<mrvn>
Drup: the memory representation is already the same
pyon has quit [Quit: fix]
<mrvn>
and the copying is hapening.
<Drup>
between Foo of int * int and Foo of (int * int) ?
larhat has quit [Quit: Leaving.]
<mrvn>
Drup: so what exactly would change?
<whitequark>
mrvn: yes, you are right, and that's what we figured out already
<mrvn>
Drup: no, those two are different in memory and behaviour
<whitequark>
Drup: you can't generally predict allocations based on source alone
<whitequark>
Drup: Int64 plus inlining, for example.
Guest52968 has joined #ocaml
<Drup>
hum, that's true
<Drup>
(you can guess pretty well, though)
<whitequark>
and I think there was some similar case with a hidden allocation
<whitequark>
but I can't recall
<Drup>
well, if there is another case, maybe it's worth trying
reem has joined #ocaml
<whitequark>
I really do think that Foo x -> x should work regardless of Foo's arity
<whitequark>
it's just consistency
Guest52968 has quit [Changing host]
Guest52968 has joined #ocaml
Kakadu has quit [Read error: Connection reset by peer]
<mrvn>
like Foo _
Guest52968 is now known as pyon
pyon has quit [Client Quit]
<whitequark>
kinda
<Drup>
I agree with you, but my argument is more about intuitivity and accessibility for beginners
<Drup>
(well, it's more or less the same argument)
pyon has joined #ocaml
swgillespie has joined #ocaml
reem has quit [Ping timeout: 250 seconds]
swgillespie has quit [Max SendQ exceeded]
swgillespie has joined #ocaml
badon has quit [Disconnected by services]
badon_ has joined #ocaml
badon_ is now known as badon
enitiz has quit [Ping timeout: 245 seconds]
<mrvn>
how about 0.0 releases?
struktured has quit [Ping timeout: 265 seconds]
mcc has quit [Quit: This computer has gone to sleep]
enitiz has joined #ocaml
<nicoo>
mrvn: You only pay the alignment constraint on 32 bits. 64 bits pointers have enough unused bits to store the tag in there
lordkryss has quit [Quit: Connection closed for inactivity]
dmbaturin_ is now known as dmbaturin
<mrvn>
nicoo: uhoh, storing data in the top bits? That's gonna slow you down and bite you in the future.
<mrvn>
nicoo: you need more than 5 bits?
<mrvn>
more than 3?
matason has quit [Ping timeout: 264 seconds]
zpe has joined #ocaml
<Drup>
nicoo: isn't that the same sort of technique that ocp-memprof is using ?
<nicoo>
Drup: I don't know what memprof does
<Drup>
exactly that, store things in this unused space
<whitequark>
ARM64 dedicates 8 top bits for tags explicitly
<nicoo>
mrvn: The mask operation are fairly inexpensive (the runtime even does something similar for ints). And you need enough bits to recognize any (non-constant) constructor. I don't remember how many
raphaelss has quit [Quit: leaving]
<nicoo>
whitequark: In practice, amd64 only uses 56 bits of adress space max. (As in "the MMU cannot do more than that")
<nicoo>
(IIRC, for the 56 value)
<whitequark>
yes, I know
<nicoo>
Drup: How do they make it work on 32 bits systems, then ? (Or do they only need very few bits?)
<whitequark>
iirc it is 48, but not sure
<whitequark>
but you still need masking
<whitequark>
because any of these bits set means a fault
zpe has quit [Ping timeout: 246 seconds]
<nicoo>
Yup
<Drup>
nicoo: they don't.
<nicoo>
Drup: Ok. Because the trick would work out-of-the-box on 64 bits, but I would need some stats about allocation patterns on 32 bits to guess whether it makes sense or not (on 32 bits)
MooseAndCaml has quit [Ping timeout: 246 seconds]
tani has joined #ocaml
tane has quit [Killed (sinisalo.freenode.net (Nickname regained by services))]
tani is now known as tane
rgrinberg has quit [Quit: Leaving.]
mcclurmc has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
reem has joined #ocaml
SomeDamnBody has quit [Ping timeout: 245 seconds]
mcclurmc has joined #ocaml
SomeDamnBody has joined #ocaml
mcclurmc has quit [Ping timeout: 265 seconds]
lightstep has joined #ocaml
tane has quit [Quit: Verlassend]
rkowalick has joined #ocaml
rand000 has quit [Quit: leaving]
myyst has joined #ocaml
<lightstep>
is it possible to ask the compiler to forgo the monomorphism restriction for a single definition?
<Drup>
considering how unsafe it is, no
myst has quit [Ping timeout: 250 seconds]
<Drup>
the better question is : what are you trying to do ?
<lightstep>
i have a type 'a t = Phantom | Other 'a ... and a module M with M.f : 'a -> 'a M.t, and i'd like to define phantom = M.f Phantom, as a value and not as a function
mcclurmc has joined #ocaml
<Drup>
can you show the whole definition ?
<lightstep>
(this is not strictly necessary but would structure my program nicely)
<Drup>
change the definition of Lz.t with "type +'a t"
<Drup>
and tell me if it works
<Drup>
(you can put the + on the definition of status and t too, just to force the compiler to check that everything is going well, but it should infer it)
<lightstep>
in the module implementation: Error: In this definition, expected parameter variances are not satisfied. The 1st type parameter was expected to be covariant, but it is invariant
<lightstep>
i don't know ocaml very well... is there a formal definition for the rules of subtyping? does ref constrain the variance?
<Drup>
so then, the answer is definitely no
<Drup>
make never a function :)
<lightstep>
in this particular case, the implementation is completely safe: the reference contains a Value and is never assigned to
<Drup>
yes, but the compiler doesn't know that
<Drup>
especially since the type is opaque, but even without that, it couldn't prove it
<Drup>
(btw, I'm not sure why you are not using Lazy)
gargaml has quit [Quit: WeeChat 1.1.1]
<Drup>
(it wouldn't help, but still)
<lightstep>
yeah, for sure. that's why i was asking for a compiler trick to skip checking for one definition :)
<Drup>
playing that game doesn't usually end well, especially if "[you] don't know ocaml very well" ;)
<Drup>
so, no, sorry, resign yourself and make a function
<lightstep>
i'm using lazyness to implement infinite streams, some of whose contents are not known in advance (to base an implementation of FRP over). they are cyclically dependent. and i use Lazy.Undefined, or Lz.Loop, to detect when a stream depends on itself, to ignore this case. (i'm using mutithreading to decide which comes first if the next element depends on multiple streams)
nuki has joined #ocaml
reem has quit [Remote host closed the connection]
<lightstep>
but when using Lazy, some values cache the Undefined exception, and it's hard to control all of them and make them pass it through
<Drup>
yeah, using Lazy.Undefined for that sounds like a remarkably bad idea.
<Drup>
apparement, Lazy.t is declared covariant
<Drup>
so never can be a value with Lazy.t
Thooms has quit [Quit: WeeChat 1.0.1]
<Drup>
compiler cheating, I presume. Lot's of compiler cheating with lazy
<lightstep>
yeah, it actually worked with Lazy before
<lightstep>
thanks a lot anyhow
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
<Drup>
lightstep: not that if you role everything into one, you can have what you want
<Drup>
note*
<Drup>
roll* too =')
<lightstep>
you mean, if the types are defined in the same module?
<Drup>
and you inline Lz.t insinde status/t (you don't need the two then)
<Drup>
are you doing an frp library just for fun or another reason ?
zpe has joined #ocaml
<lightstep>
just for fun, i want to understand if there's a technical reason why the push-pull approach isn't popular any more