<watermind>
are local exceptions available in OCaml these days?
introom has joined #ocaml
travisbrady has quit [Quit: travisbrady]
gautamc has quit [Read error: Connection reset by peer]
ygrek has joined #ocaml
introom has quit [Remote host closed the connection]
darkf has joined #ocaml
introom has joined #ocaml
Drup has quit [Quit: Leaving.]
<flux>
watermind, there are local modules which can define exceptions (and the types of the exceptions can depend on the function parameter types)
ygrek has quit [Ping timeout: 264 seconds]
<watermind>
flux: oh I see
ygrek has joined #ocaml
<watermind>
flux: the philosophy seems to be "use modules, whenever you want to limit the scope of something"... I've seen them used for instance to localy open other modules
ygrek has quit [Ping timeout: 245 seconds]
Dodo has joined #ocaml
Dodo has quit [Remote host closed the connection]
ygrek has joined #ocaml
<flux>
I think it's more like 'hey, we already have this syntax, so if we do it this way we need to introduce the minimal amount of new syntax'
<flux>
which I can agree with. it keeps the language small(er).
introom has quit [Remote host closed the connection]
LimitSupremum has joined #ocaml
watermind has quit [Quit: Konversation terminated!]
Kakadu has joined #ocaml
ben_zen has joined #ocaml
introom has joined #ocaml
introom has quit [Ping timeout: 245 seconds]
LimitSupremum has quit [Quit: Leaving.]
<ygrek>
gasche, please use "$@" instead of $* in opam-compiler-conf.sh
ygrek has quit [Remote host closed the connection]
weie_ has joined #ocaml
ygrek has joined #ocaml
weie has quit [Ping timeout: 260 seconds]
<adrien>
I can't remember: what's the different between $@ and $* btw?
ben_zen has quit [Ping timeout: 245 seconds]
ben_zen has joined #ocaml
ben_zen_ has joined #ocaml
ben_zen_ has quit [Client Quit]
Simn has joined #ocaml
ben_zen has quit [Ping timeout: 276 seconds]
shinnya has quit [Ping timeout: 264 seconds]
ollehar has joined #ocaml
Kakadu has quit [Ping timeout: 240 seconds]
<ygrek>
"$@" and $*
<ygrek>
in short: the first one preserves quoted arguments, the second one doesn't
introom has joined #ocaml
introom has quit [Remote host closed the connection]
fmardini has joined #ocaml
introom has joined #ocaml
yezariaely has joined #ocaml
ulfdoz has joined #ocaml
* whitequark
sighs
<whitequark>
so it seems there is actually no way to write a menhir parser with internal state
<whitequark>
what I essentially want is to add a field to _menhir_env
Kakadu_ has joined #ocaml
ggole has joined #ocaml
ggole has quit [Client Quit]
Kakadu_ has quit [Remote host closed the connection]
tane has joined #ocaml
Kakadu has joined #ocaml
ggole has joined #ocaml
<flux>
hmm
<flux>
I haven't used it for a while, but can't you just pass it around?
<whitequark>
I solved (fsvo solved) my problem by building a closure in each reduction rule, and then expanding it all in the topmost one
<whitequark>
so like: a=expr PLUS b=expr { fun env -> (a env) + (b env) }
<whitequark>
I'm not very delighted by this solution
<flux>
I was probably thinking of the lexer generator then
<ggole>
That looks pretty strange
<ggole>
What's the goal, to pass an argument in?
<whitequark>
ggole: yes
<ggole>
Ugh :/
<flux>
I don't think it looks -that- bad, though :)
<whitequark>
flux: this leads to 80% of code in my parser being boilerplate.
<whitequark>
not very good.
<whitequark>
what I want is to parse a description of a huge data structure (basically, interpreter heap), which can be thought of as one giant letrec definition
<whitequark>
so I need state
<whitequark>
in order to resolve references
<whitequark>
and I want to do all this in single pass from within a parser, without a separate AST, because it (still) seems to me as a simpler, easier to maintain solution
<whitequark>
I wanted to use a separate IrParserState module with a bit of global state, but the fun env -> thingy is cleane.r
<whitequark>
it really is a pity that you cannot write stateful parsers in menhir.
<flux>
ocamldoc seems to use ugh global state
<flux>
so there clearly is a need for that feature :)
<whitequark>
I imagine it'd be easy to do something like "type _menhir_env = { ...; state : '_a }"
<flux>
hmm, is it that easy? what if it needs to do backtracking?
<flux>
or is _menhir_env already in some stack
<whitequark>
LR(1) doesn't
<flux>
ah, ok
<whitequark>
well, there are lookahead actions
<whitequark>
but it's a really obscure and rarely needed feature
<whitequark>
so if you just know about it, you probably know how to not shoot yourself :)
<whitequark>
(and it seems that I indeed need this feature...)
<whitequark>
ah, no, lazy evaluation works just as well.
<flux>
so how does your solution finally look like?
<whitequark>
wait a bit, I'll finish and verify it
introom has quit [Remote host closed the connection]
Kakadu has quit []
* whitequark
wonders if it's possible to construct a closure environment which refers to itself
<adrien>
you mean, an object?
<whitequark>
hm?
<whitequark>
I'm worrying about weird circular definitions
<whitequark>
oh. yes, it is entirely possible to construct what I'm worrying about
<whitequark>
not necessarily with closures. any two mutually recursive entities suffice.
* whitequark
sighs
introom has joined #ocaml
q66 has joined #ocaml
ygrek has quit [Ping timeout: 264 seconds]
contempt has quit [Ping timeout: 245 seconds]
ulfdoz has quit [Ping timeout: 264 seconds]
ollehar has quit [Ping timeout: 240 seconds]
<whitequark>
hm, ocaml doesn't have apply ?
<whitequark>
though. I don't know what type would it have.
<mrvn>
let apply f x = f x?
<mrvn>
whitequark: you need rectypes to have closures that refer to themself or you need to declare a recursive type in wrap them in that.
<whitequark>
(let apply) that would be a partial application for functions with more than one argument
<whitequark>
what I wanted is an apply function which accepts a tuple
<whitequark>
but it's somewhat superfluous anyway.
Patchou has quit [Read error: Connection reset by peer]
osa1 has quit [Remote host closed the connection]
osa1 has joined #ocaml
mcclurmc has quit [Ping timeout: 245 seconds]
dsheets has quit [Ping timeout: 240 seconds]
mcclurmc has joined #ocaml
Drup has joined #ocaml
<gasche>
hum
<gasche>
is someone here Goswin that just submitted a PR for "is mixed here with labels of type unit"?
<adrien>
mrvn iirc
<gasche>
ok
<adrien>
gasche: ça met une minute au lieu de deux mais il bosse encore
<adrien>
j'essaie sans mes modifs
<adrien>
wrong chan :-)
weie has joined #ocaml
weie_ has quit [Ping timeout: 245 seconds]
shinnya has joined #ocaml
dsheets has joined #ocaml
<whitequark>
ugh. I realized I hate ocaml's half-assed capitalization really bad
<whitequark>
tempted to just start all my filenames with an uppercase letter
<whitequark>
mainly because irEnvironment -> IrEnvironment = bad, and iREnvironment -> IREnvironment = also bad, and some files being capitalized and some not being capitalized is even worse.
fmardini has quit [Ping timeout: 268 seconds]
<adrien>
well, you're free to do as you wish and mix as you wish
<pippijn>
whitequark: yes, I have considered that, too
<pippijn>
the advantage is that with ascii-compare, Makefile and stuff are on top
<pippijn>
that's the main reason I haven't done it, yet
testcocoon has joined #ocaml
<ggole>
Yeah, that took a bit of getting used to
<ggole>
I still name files like-this.ml every now and then by accident and then get bitch slapped by the compiler
<whitequark>
ha
<whitequark>
Rails does the underscore/camelcase transformation, i.e. under_score -> Under
<whitequark>
UnderScore and vice-versa
ben_zen has joined #ocaml
<whitequark>
but it's only good if you want autoloading, since it transforms IRFoo -> ir_foo, ie, destructs info.
<whitequark>
I'm honestly not sure how would I solve this problem except plain out naming stuff with their final names.
<whitequark>
pippijn: _tags is on top either way :)
<whitequark>
and I'm pretty sure this was the reason
<pippijn>
yes, I think so
Kakadu has quit []
dsheets has quit [Ping timeout: 240 seconds]
dsheets has joined #ocaml
dsheets has quit [Ping timeout: 268 seconds]
dsheets has joined #ocaml
introom has joined #ocaml
<introom>
would you give an example of let pattern = expression?
<pippijn>
let [a; b; c] = [1; 2; 3]
<adrien>
let (a, b, c) = (1, 2, 3)
<adrien>
for one that won't throw a warning :-)
<introom>
and let identifier pattern..pattern = expression?
<bernardofpc>
why does it throw a warning ?
<pippijn>
bernardofpc: the compiler emits a warning
<pippijn>
because the pattern is refutable
<bernardofpc>
I've seen it
<bernardofpc>
but I don't get why
<pippijn>
because let [a] = [] fails, for example
<bernardofpc>
oh
<bernardofpc>
right
<bernardofpc>
it's a type stuff
<bernardofpc>
[a] and [a;b;c] and [] have the same type
<bernardofpc>
whereas (a,b,c) and (a) don't
<introom>
bernardofpc: yeah.
<bernardofpc>
let a,b,c = 1,2,3 ;; works
<bernardofpc>
magic how OCalm gets rid of ()
<pippijn>
that's not magic
<pippijn>
that's just a parser thing
dsheets has quit [Ping timeout: 264 seconds]
<introom>
what should a pattern match, the invoke args or the expression?
<introom>
say, let identifier pattern..pattern = expression?
dsheets has joined #ocaml
<ggole>
"Invoke args"?
<introom>
let pattern = expression, seems the pattern matches the evaluation result of the expression
<introom>
but what about let identifier pattern ..pattern = expression?
<pippijn>
that's a function definition
<ggole>
That's sugar for let ident = (fun ... -> ...)
<pippijn>
let ident = fun pattern -> ... -> fun pattern -> expression
<ggole>
And fun has basically the same matching as let
<introom>
yeah. so the patten matches the invoking arguments
contempt has quit [Remote host closed the connection]
<introom>
why does this fail? (fun (1 | 2) as i -> i + 1) 2
<Drup>
fun don't do pattern matching, only "function" does
<flux>
(fun ((1 | 2) as i) -> i + 1) 2
<flux>
funs do pattern matching, but they don't do it for multiple distinct patterns with guard clauses
ygrek has joined #ocaml
ulfdoz has joined #ocaml
<introom>
flux: what's guard clauses ?
<flux>
match 42 with x when x = y -> ..
<introom>
why the OCaml designers left out function matching?
<flux>
function matching?
<ggole>
You can't really inspect functions for structure
<ggole>
(If that's what you meant.)
<introom>
function has signature, like int -> int -> int = func
<ggole>
That's not matching
<ggole>
If you mean ascription, ocaml has that
<introom>
can we match the function signatures?
<pippijn>
introom: in what context?
<pippijn>
you want to do type level pattern matching?
<ggole>
No
<introom>
yes.
<pippijn>
no, you can't do that
<pippijn>
because that would either need rtti (which ocaml doesn't have) or the function definition to be known at the call site
<pippijn>
(which is most often not the case)
<introom>
rtti?
<pippijn>
runtime type information
dsheets has quit [Ping timeout: 240 seconds]
dsheets has joined #ocaml
<ousado>
pippijn: thanks for the link, very interesting
ygrek has quit [Ping timeout: 245 seconds]
dsheets has quit [Ping timeout: 264 seconds]
dsheets has joined #ocaml
introom has quit [Remote host closed the connection]
dsheets has quit [Ping timeout: 264 seconds]
dsheets has joined #ocaml
mako has joined #ocaml
mako has quit [Read error: Connection reset by peer]
darkf has quit [Quit: Leaving]
dsheets has quit [Ping timeout: 264 seconds]
dsheets has joined #ocaml
ygrek has joined #ocaml
Nahra has quit [Ping timeout: 264 seconds]
ygrek has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
<dsheets>
grrr -classic-display
Kakadu has joined #ocaml
<dsheets>
I am using Printexc.print_backtrace with a native code executable but nothing is printed. Suggestions on how to debug backtrace debugging? Everything is built with -g...
<rks`>
are you running with OCAMLRUNPARAM=b ?
hto has joined #ocaml
<dsheets>
rks`, i've tried both and it doesn't appear to have an effect. Also, I thought Printexc.print_backtrace works regardless?
MarcWebe1 is now known as MarcWeber
<dsheets>
rks`, aha, you were right... a combination of using sudo and not passing OCAMLRUNPARAM
<adrien>
you have to enable them first if not b
<dsheets>
adrien, how's that?
<adrien>
val record_backtrace : bool -> unit
<dsheets>
gotcha... thanks
<adrien>
Initially, backtraces are not recorded, unless the b flag is given to the program through the OCAML‐ RUNPARAM variable.
<dsheets>
my stupid, it hurts
tane has quit [Quit: Verlassend]
ggole has quit [Ping timeout: 245 seconds]
<chris2>
what do i need to take care of when using ocamlbuild with opam and ocaml core? i can "open Core.Std" everywhere except in a menhir header
<gasche>
what's your OCaml version? there is a menhir-related bug that was fixed in trunk a few months ago
<chris2>
The OCaml toplevel, version 4.00.1
<gasche>
the workaround is to add the name of your menhir module in a "foo.mlypack" and build foo.cmo instead
<gasche>
I think it works even if your file is foo.mly (that is, there should be no name conflict)
<gasche>
(the workaround works because this bug was fixed a long time ago, but only partially, when compiling from a .mlypack and not from a .mly)