<flux>
though maybe that kind of code generator might even break with wrong format :)
<flux>
except not to that direction?
govg has joined #ocaml
Haudegen has joined #ocaml
<kakadu>
Do you have any idea have somebody rebased modular-implicits onto 4.02.3 or something?
* kakadu
is still thinking how to implements generic printer...
<zozozo>
Kakadu: same as implicits but with explicit module argument ?
<kakadu>
I think that `only modules can be implicit` is more correct definition
FreeBirdLjj has quit [Remote host closed the connection]
<ggole>
There's a bunch of 4.03 releases, you could try the older ones if the bleeding edge is bleeding too much
<kakadu>
I commented -with-debug-runtime and it is fine nwo
<kakadu>
now*
lyxia has quit [Quit: leaving]
lyxia has joined #ocaml
octachron has quit [Quit: Leaving]
<pabs3>
flux: yeah, this is more from a Linux distro QA perspective, so it is about checking existing code rather than writing new code
agumonkey has quit [Ping timeout: 264 seconds]
agumonkey_ has joined #ocaml
zpe has quit [Remote host closed the connection]
agumonkey_ is now known as agumonkey
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
govg has quit [Ping timeout: 276 seconds]
lyxia has quit [Ping timeout: 264 seconds]
Anarchos has joined #ocaml
ely-se has quit [Quit: leaving]
ely-se has joined #ocaml
pyon has joined #ocaml
pyon has quit [Changing host]
pyon has joined #ocaml
pierpa has joined #ocaml
jrslepak has joined #ocaml
sbrouf has quit [Ping timeout: 250 seconds]
kakadu has quit [Quit: Page closed]
zpe has joined #ocaml
govg has joined #ocaml
<gasche>
I was just sent a patch by kakadu that uses a very bad idea
<gasche>
turning (with Failure "int_of_string" -> ...) into (with Failure msg when msg = "int_of_string" -> ...) to silence a new 4.03 warning
_gt has joined #ocaml
<gasche>
this is a very bad idea (and I half wonder whether it originated here); don't do that
<gasche>
to fix this warning, restrict the scope of the "try" block such that only (int_of_string) can throw, and then use (Failure _ -> ...)
<gasche>
(the warning was designed to make sure that changing the literal string used in this Failure message would not break code; the workaround defeats the purpose for bad reasons)
groovy2shoes has quit [Quit: Leaving]
groovy2shoes has joined #ocaml
<Drup>
def` (gasche) : Do you have a good method to handle indentation based languages with menhir ? I have some ideas, but I wonder if you know some methods
<Anarchos>
Drup you speak of python ?
<Drup>
No
<gasche>
Drup: the classic technique is to have your lexer emit INDENT, NEWLINE, DEDENT tokens
<gasche>
and then use those in the grammar
<Drup>
yes, that's what I heard
<gasche>
there is a more complicated technique developed by Michael Adams, but it requires changing the parser generator machinery and I don't like that
<groovy2shoes>
the key is that the lexer only emits INDENT tokens when the indentation increases, not for every indentation in the source
<gasche>
I've personally experimented with the token-based approach to implement "the whitespace thing" as a camlp4 extension, and that worked well
<Drup>
gasche: how do you support things like:
<gasche>
(but I was co-designing the parser and the whitespace-aware grammar, which is easier than following an existing specification to the letter)
<Drup>
I want to support the last case, the "INDENT" token is going to be in the middle of the value which is supposed to be delimited
<Drup>
is that something you supported ?
malc_ has joined #ocaml
hay207_ has joined #ocaml
<gasche>
I don't remember
<gasche>
the F# #light specification is rather sophisticated, in particular the token filter uses a context stack, similar to ocp-indent's implementation
hay207 has quit [Ping timeout: 260 seconds]
<gasche>
you should be able to distinguish this situation with a context stack
<Drup>
which means implementing half the parser in the lexer
<Drup>
it means some duplication, but it means the parser know about everything, so the menhir messages things will be very exhaustive
<gasche>
to some extent you can factorize this
<ggole>
Wouldn't that spuriously accept the blas at the same indentation as the Foo, since there would be no token?
<Drup>
ggole: there is always an INDENT token somewhere
hay207__ has joined #ocaml
<gasche>
eg. you could have a parametrized rule begin-or-indent(simple-bla, bla-block)
<Drup>
gasche: yes
hay207_ has quit [Ping timeout: 256 seconds]
<gasche>
(in the rule above "begin" "end" are rules, not tokens, in particular it is often natural to count "BEGIN INDENT" and "DEDENT END" as just 'begin' and 'end')
<ggole>
Drup: ah, so that's a problem with groovy2shoes's suggestion, but you're not using that?
<Drup>
gasche: one weird technique I had in mind, but it's probably not a good idea, is to use inspection magic to look at the lookahead token, if it's a begin, we expect indentation after the next new line :p
<Drup>
ggole: I don't understand
<ggole>
The suggestion was "the key is that the lexer only emits INDENT tokens when the indentation increases"
<Drup>
I haven't implemented anything indentation-sensitive yet, I was looking for options
<ggole>
But if you do that, and you then have Foo: bla\nbla bla and the second line is at the same level as the foo, it seems to me that it breaks pretty badly.
<Drup>
ggole: INDENT and DEDENT are emited only if it's more indented than the previous line
<Drup>
(and less indented)
<Drup>
it's for changes in indentation, not indentation itself
<gasche>
ggole: your example would be rejected by my rules, I believe
<gasche>
(as it should, right?)
<Drup>
yeah, it should
<Drup>
(in this example, at least)
<ggole>
Hmm, OK
psy has joined #ocaml
* ggole
makes a mental note to test the hell out of any whitespace-sensitive parser he should construct in future
<groovy2shoes>
ggole, better yet, just don't do it ;)
<gasche>
I think it's actually a good idea to have a indentation-sensitive grammar
<gasche>
(it's much better than "if do done" for example)
<gasche>
(although this could have been done cleanly if it was there from the start)
<Drup>
I disagree, but it's a matter of taste.
<ggole>
I dunno, I quite like having solid indentation support in my editor
<Drup>
exactly, it could have been done cleanly
<ggole>
C-x h TAB ftw
<Drup>
^ this.
<Drup>
(it infuriates me every time I write some haskell)
lyxia has joined #ocaml
Denommus has joined #ocaml
ely-se has quit [Quit: leaving]
<mrvn>
The idea of the lexer emiting INDENT/DEDENT when the indentation changes is so that the parser can have <block> = INDENT <commands> DEDENT
<mrvn>
you basically turn the indentation into { }
<ggole>
That's what I was suggesting was broken
<groovy2shoes>
why?
<mrvn>
hack to make it work with normal parser generators
<groovy2shoes>
if I were going with recursive descent, I'd probably still do it the same way
<mrvn>
you move the context sensitivity of the indentation into the lexer
<ggole>
Because if you had Foo: bla\nbla bla, and the second line of blas was at the same indentation, there would be no token and it would be accepted
<groovy2shoes>
I don't understand what you mean, ggole
<mrvn>
ggole: "Foo: bla" doesn't start a block
<mrvn>
ggole: "foo:\n\tbla" does
lyxia has quit [Quit: WeeChat 1.3]
<ggole>
Drup was asking that it should
<groovy2shoes>
ah
lyxia has joined #ocaml
<mrvn>
"Foo: bla\n\tblub" should warn about mixed indentation or fail
<groovy2shoes>
you can still push that into the lexer, I think
<mrvn>
imho
<ggole>
If you disallow that, then perhaps it works out nicely
<mrvn>
(going by python)
<groovy2shoes>
that's not really indentation so much as alignment, but I think you can still do it in the lexer (though the lexer has to be aware of which things are alignable)
<mrvn>
ggole: BEGIN/END is stupid there. makes no sense
<groovy2shoes>
is the problem statement supposed to work?
<groovy2shoes>
or is it supposed to be rejected and it's erroneously being accepted?
<ggole>
mrvn: eh? it's just an explicit alternative
<ggole>
(And it's not like I came up with this grammar...)
<mrvn>
ggole: make no sense. Then you also need a sequenze operator like ";" so you can put multiple commands on a line. Just makes everything more complex and unreadable.
<groovy2shoes>
mrvn: you don't actually need a sequence operator, depending on the grammar
<mrvn>
groovy2shoes: if you don't then you only have one command there terminated by newline. no need for begin/end
<Drup>
mrvn: it's just to show the scoping explicitely ...
<Drup>
seriously.
<groovy2shoes>
look at Lua for an example: it allows multiple statements one one line with no separator... do a = 2 + 2 print(a) end works fine
<mrvn>
Drup: which is useless since it's already clear from the indentation
<Drup>
mrvn: no it isn't, because I'm describing the grammar to you. Stop being uselessly pedant and thick.
<mrvn>
Drup: I'm saying the grammar is stupid
* ggole
reports Drup to the redundancy authorities
<Drup>
u_u'
<groovy2shoes>
Drup, should a ':' always introduce a block?
<ggole>
This was such a great conversation, thanks everybody! *runs away*
<mrvn>
groovy2shoes: that's scary
<Drup>
mrvn: that's completely beside the point, it's not my invention
<mrvn>
groovy2shoes: how would that be different from "if bla: a = 2 + 2 print(a)"?
<Drup>
(I also never said it was a programming language)
<groovy2shoes>
Drup, I mean, should a ':' always demand alignment on subsequent lines?
<Drup>
groovy2shoes: to be in the same block, yes
<mrvn>
groovy2shoes: in python it does unless followed by a command directly.
<Drup>
that's why I putted an example with a different grammar that has explicit markers
<groovy2shoes>
mrvn, I know about Python, this isn't Python
<mrvn>
groovy2shoes: as in you need either a command or a block following :
<mrvn>
only sane thing to do imho.
<groovy2shoes>
Drup, you can have the lexer set it's internal "indented-this-far" state to the first occupied column after a ':' and emit an INDENT even though it's not strictly-speaking an indent
<mrvn>
Drup: in your case a : needs either being/end or an indented block even if there is some command after the : already?
<Drup>
groovy2shoes: see backlog
<mrvn>
groovy2shoes: urgs, then subsequent lines would have to be indented up to after the : too
<groovy2shoes>
mrvn, I know, that's what alignment is
<mrvn>
groovy2shoes: I would hope the indent is a bit more loose.
<groovy2shoes>
well that's you
<mrvn>
groovy2shoes: emit an INDENT after : and set the "indented-this-far" on the next line if it is indented more than the last block
<mrvn>
otherwise emit a DEDENT
oskarth has quit [Quit: Updating details, brb]
<groovy2shoes>
that's up to Drup
<mrvn>
up to the language
<groovy2shoes>
or whatever spec they're following
oskarth has joined #ocaml
<groovy2shoes>
Drup, I dunno... my suggestion is to have the lexer emit an INDENT immediately after it sees a colon, then a dedent whenever something appears at the same level as the line that introduced the ':'
<groovy2shoes>
mrvn, afaict, that should be accepted according to Drup
<ggole>
groovy2shoes: I think you need a bit more state than that, if you are going to allow multiple subsequent lines that are deeper than the Foo: (but still need them to be the same depth)
<groovy2shoes>
even looks pretty with tabstops set to 4
<mrvn>
groovy2shoes: would have me searching for a : in the blub line
<groovy2shoes>
ggole, yeah, you're right, but only a flag of some sort
<mrvn>
Drup: is " " the same as "\t" for indents?
<mrvn>
groovy2shoes: you need an indented-so-far stack
<groovy2shoes>
mrvn, yeah, in my head the lexer was recursive so I forgot about the stack -_-
<groovy2shoes>
but you also need a flag to remember you just saw a colon and already emitted an INDENT, and that you need to "reset" the top of the indented-so-far stack on the next line without emitting another INDENT
<mrvn>
groovy2shoes: me? No, I don't allow extra indent after "Foo: bla", only after "Foo:"
<groovy2shoes>
I mean "you" in the general sense
<mrvn>
yeah, as described above. horrible to code.
<groovy2shoes>
not really
NingaLeaf has joined #ocaml
<mrvn>
And if you have BEGIN/END does that allow "\t\t\tBEGIN foo\nbla\nblub END\n\t\t\tblubber"?
NingaLeaf has quit [Client Quit]
NingaLeaf has joined #ocaml
<mrvn>
One thing I noticed with indentation based languages (python :) is that it's hard to break lines at 80 chars.
ely-se has joined #ocaml
<groovy2shoes>
usually if I need to break a line in Python, it's in the middle of an argument list, so Python doesn't care
jyc has quit [Ping timeout: 240 seconds]
<srax>
2
Korhoset has quit [Read error: Connection reset by peer]
<ggole>
"Filipino priest suspended for riding hoverboard during Christmas Eve mass" what a time to be alive
<companion_cube>
couldn't wait to play with his toy :D
<ggole>
(It's a shame they're just on wheels.)
govg has quit [Ping timeout: 265 seconds]
NingaLeaf has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
govg has joined #ocaml
Denommus` is now known as Denommus
hay207_ has joined #ocaml
hay207 has quit [Ping timeout: 250 seconds]
jrslepak has quit [Quit: This computer has gone to sleep]
Haudegen has joined #ocaml
lobo has quit [Ping timeout: 260 seconds]
lobo has joined #ocaml
m___ has quit [Ping timeout: 252 seconds]
lobo has quit [Ping timeout: 260 seconds]
lobo has joined #ocaml
avsm has quit [Quit: Leaving.]
dario1 has joined #ocaml
dario1 has quit [Client Quit]
palomer has joined #ocaml
malc_ has quit [Quit: leaving]
avsm has joined #ocaml
MercurialAlchemi has joined #ocaml
larhat1 has joined #ocaml
ygrek has joined #ocaml
<mrvn>
any way to access a C variable from ocaml?
ggole has quit []
<mrvn>
without getter and setter function. I just want to pass it back to a C functions as argument.
larhat1 has quit [Quit: Leaving.]
<Anarchos>
mrvn did you look at the external C interface ?
<mrvn>
yes
larhat1 has joined #ocaml
<mrvn>
# external foo : int = "foo";;
<mrvn>
Error: External identifiers must be functions
larhat1 has quit [Read error: Connection reset by peer]
larhat1 has joined #ocaml
rpg has quit [Quit: rpg]
ryanartecona has joined #ocaml
mcc has joined #ocaml
riceandbeans has left #ocaml [#ocaml]
Algebr has joined #ocaml
<Algebr>
Say you use Lwt_list.iter_p and in the callback you are mutating some ref []. Should that mutation be done with a Lwt_mutex wrapping it?
<mrvn>
when I was 13 I played with a C16
hcarty has joined #ocaml
<hcarty>
Algebr: Only if you call a blocking ('a Lwt.t returning) function as part of the mutation
<Algebr>
I see, because it will have a chance to yield, right
<Algebr>
hcarty: will Lwt seg fault or will I just get inconsistent data structures if i don't use the mutex when I should have been using it
<mrvn>
the later
darkf has quit [Quit: Leaving]
hcarty has quit [Read error: Connection reset by peer]
hcarty has joined #ocaml
larhat1 has quit [Quit: Leaving.]
avsm has quit [Quit: Leaving.]
kakadu has joined #ocaml
nullcatxxx_ has joined #ocaml
larhat1 has joined #ocaml
larhat1 has quit [Quit: Leaving.]
larhat1 has joined #ocaml
larhat1 has quit [Client Quit]
ygrek has quit [Ping timeout: 240 seconds]
larhat1 has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 246 seconds]
yomimono has joined #ocaml
madroach has joined #ocaml
MercurialAlchemi has joined #ocaml
hcarty has quit [Quit: WeeChat 1.3]
inr has quit [Quit: bye]
<Maelan_>
just a quick question about encodings
Maelan_ is now known as Maelan
<Maelan>
when i write « "é" » in a source code
<Maelan>
does the compiler takes the source bytes literally, or does it translate it from a given source encoding to a given target encoding?
<flux>
it takes them literally. there is no transcoding.
<flux>
in particular, ocaml source code itself is basically latin1
<flux>
..but apparently it's deprecated according to my 4.02.1
<flux>
good riddance, ASCII it is :)
yomimono has quit [Quit: Leaving]
<Maelan>
nope
freehck has quit [Remote host closed the connection]
<Maelan>
utf-8 it is
<Maelan>
thanks flux
<flux>
maelan, but for identifiers you need to use ascii
<Maelan>
yes
<flux>
but I guess deprecating latin1 identifiers might mean maybe some day ocaml will learn utf8 identifiers ;-)
<Anarchos>
flux or go back plain ascii ?
<Maelan>
but i dare using utf-8 in string literals
<flux>
maelan, sure, everyone does it ;)
<Maelan>
and in comments
<Maelan>
some people from the last century seem to believe it is evil, if even possible
<flux>
I guess UTF-8 is the solution for character sets for the foreseeable future
larhat1 has quit [Ping timeout: 260 seconds]
<Anarchos>
flux they should have use 16 bits char from beginning
<flux>
anarchos, from the what beginning?
<Maelan>
16 bits is not enough
<flux>
I think UTF16 might even be dangerous, because it might lead you into thinking 16 bit is all you need to handle
<Maelan>
n’en déplaise à Microsoft
<Anarchos>
flux say the 80's ?
<flux>
but with UTF8 you always hit the case where 7 bits is not enough
<flux>
anarchos, well, how wasteful would that have been when you have 4 kilobytes of memory?
<flux>
well, always, except in the US.. :)
<Maelan>
another question, does a syntax extension like u'é' and u"é" exists somewhere?
<flux>
not sure. I guess it would create some kind of unicode object with that contents then?
<flux>
I don't recall offhand if that's possible with ppx, with a succinct syntax..
<Maelan>
i do not have a precise semantics in mind, but i mean yes, something like that
<Maelan>
u'é' might be a value of type uchar (abstract type implemented by an int?)
<flux>
it would be of value if it would also check, at compile time, that the argument is a valid utf8 sequence
<Maelan>
which would store the code point of the Unicode character (thus transliteration at compile-time)
<Maelan>
i do not seek to reproduce it for now, i am just wondering if some existing library provides something like this
inr has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
ely-se has joined #ocaml
lobo has quit [Quit: leaving]
<mrvn>
I once had to work with C code with japanese comments. Please no UTF-8.
<mrvn>
That was just comments but that was bad enough-
<flux>
actually I have a colleague that's in a project that is written partially in finnish
<Maelan>
i said utf-8 comments, not non-english comments :p
<mrvn>
if the comments are english then you don't need anything but ascii
<flux>
he was of the view that it's actually a good match for the project, because there is so many obscure domain-specific words that are difficult to translate into english, and nobody would know them anyway
<Maelan>
(but i think non-english is fine for personal use)
<Maelan>
mrvn, punctuation
<mrvn>
part of ascii
<Maelan>
’ “” ‘’ …
<Maelan>
↑ not those right ones
<mrvn>
stick with (){}[]""''´´``
<Maelan>
why?
<Maelan>
unicode is meant precisely for that
<mrvn>
because tzhey suffice
<mrvn>
if you allow utf-8 then people will use chineese variable names with japanese comments.
<Maelan>
i occasionnaly use things like ↑ → ∀ too
<mrvn>
? -> ? ?
<Maelan>
i thought we were speaking about comments only here
<Maelan>
but in fact i see no problem allowing unicode in identifiers
<flux>
unicode has the nice box drawing symbols as well ;)
<Maelan>
people already write programs in their own language
<Maelan>
and because they are limited to ascii, this is not always readable even for them
<flux>
I think it's rare to professionally write code in a language not English
<flux>
well, there are probably exceptions, like China
jrslepak has joined #ocaml
<flux>
though maybe they as well need to succumb to the power of ascii.. :)
<Maelan>
yes flux, and if they don’t care about being inaccessible by other-language-speaking people, this is their problem
<Maelan>
and allowing unicode won’t change it
<mrvn>
Maelan: you are an enabler
<Maelan>
I Am An Enabler
<mrvn>
EXTERMINATE!
<Maelan>
(solemn voice here)
dmbaturin has quit [Ping timeout: 276 seconds]
MercurialAlchemi has quit [Remote host closed the connection]
<Anarchos>
embrace, extend, exterminate :)
<mrvn>
DO NOT BLASPHEME!
palomer has quit [Quit: palomer]
jgjl has joined #ocaml
apache2 has quit [Read error: Connection reset by peer]
jgjl_ has joined #ocaml
apache2 has joined #ocaml
jwatzman|work has joined #ocaml
jwatzman|work has quit [Client Quit]
jgjl has quit [Ping timeout: 240 seconds]
jwatzman|work has joined #ocaml
jwatzman|work has quit [Client Quit]
ely-se has quit [Quit: Leaving...]
_whitelogger has quit [Ping timeout: 240 seconds]
_whitelogger has joined #ocaml
_whitelogger has joined #ocaml
<exm>
Here's a question I've been having trouble googling. I have a type like A of int | B of int, and I want to get the int out in both cases. I could just do match r with | A x -> x | B x -> x;;, but is there a better way?
orbitz has joined #ocaml
micro___ has joined #ocaml
DanielRichman has joined #ocaml
<smondet>
exm: let f x = match x with A y | B y -> y is slightly more compact and still works :)
<exm>
smondet: Thanks!
zpe has quit [Remote host closed the connection]
hay207__ has joined #ocaml
jgjl_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hay207_ has quit [Ping timeout: 264 seconds]
apache2_ has joined #ocaml
jlouis has joined #ocaml
apache2 has quit [Ping timeout: 255 seconds]
jlouis has quit [Ping timeout: 255 seconds]
DanielRichman has quit [Ping timeout: 264 seconds]
ahf has quit [Ping timeout: 255 seconds]
micro___ has quit [Ping timeout: 250 seconds]
orbitz has quit [Ping timeout: 265 seconds]
ahf has joined #ocaml
_whitelogger has joined #ocaml
larhat1 has quit [Client Quit]
DanielRichman has joined #ocaml
micro___1 has joined #ocaml
tmtwd has quit [Ping timeout: 272 seconds]
_gt has quit [Quit: leaving]
hay207 has joined #ocaml
hay207__ has quit [Ping timeout: 276 seconds]
hay207_ has joined #ocaml
hay207 has quit [Ping timeout: 260 seconds]
sbrouf has quit [Quit: Quitte]
Denommus has quit [Quit: going home]
hay207__ has joined #ocaml
hay207_ has quit [Ping timeout: 246 seconds]
Anarchos has quit [Read error: Connection reset by peer]