<Drup>
(someone is screaming GADT in my mind right now)
yacks has joined #ocaml
<Algebr>
you mean to parameterize the type?
<Drup>
yes, but it's not necessarily the good solution, just the prettiest one.
<Drup>
Algebr: you realize why it doesn't work, do you ?
<Algebr>
Not really
philtor_ has joined #ocaml
<Drup>
let b = Binop(LiteralInt 3, Add, LiteralInt 5)
dorei has joined #ocaml
<Drup>
you agree that "expr_check b" is true ?
<Algebr>
yes
<Drup>
let b' = Binop(b, Add, LiteralString "bla")
<Algebr>
poop.
<Drup>
let's apply expr_check
<Algebr>
yerp, I see now.
<Drup>
right :)
<Drup>
what you want here is to typecheck your tree, so let's typecheck it
<Drup>
in this case, since it's simple, everything is inferable
<Drup>
so you can write a function "infer_type : expr -> type"
<Drup>
(with type as defined in the answer)
<Algebr>
Sorry, I don't follow on that.
<Drup>
which part ?
<Algebr>
so I can typecheck the tree with type 'a expr = LiteralInt of a | LiteralString of a?
<Algebr>
err, type the tree
<Drup>
non, remove the 'a
<Drup>
no*
<Algebr>
parameterize the type?
<Algebr>
but then how will I *
<Drup>
don't parametrize it
<Drup>
oh, I think you got it wrong
<Algebr>
most likely.
<Drup>
when I say "you want to type check the tree", I mean that you will write an algorithm typechecking the tree
<Drup>
not using ocaml's typechecker to do the work for you
<Algebr>
so I can leave my type expr = LiteralInt of int | LiteralString of string | Binop of expr * op * expr alone, but I have to write another function, smarter function?
<Drup>
yes
<Algebr>
Why can't I offload this work to the type system
<Drup>
oh, you can
<Drup>
if you want
<Drup>
but it's not the same kind of interesting
<Drup>
:)
<Algebr>
lol, I'm more in mind of solutions rather than shiny things.
<Drup>
so I advise you to do the work yourself :)
__cody__ has quit [Quit: Leaving]
ontologiae has quit [Ping timeout: 255 seconds]
<Algebr>
okay, so then the work is with the let rec expr_check = function | Binop ...
<Algebr>
Or should I write a small helper function that gets called on the right side of a -> in the original expr_check
<Drup>
you shouldn't need an helper function for something that simple
<Drup>
in this case, the trick is, as I said before, to make the checking function return the type of the checked expression
<Algebr>
but there isn't a typeof type() in ocaml
<Algebr>
or*
<Drup>
not the type according to caml, the type according to you !
<Drup>
LiteralInt is of type MyIntType
<Algebr>
oh gosh
<Drup>
hey, you are the one wanting to typecheck your tree
<Algebr>
so I could do something like: type myTypes = MyInt | MyString and type expr = LiteralInt of MyInt | LiteralString of LiteralString?
<whitequark>
try raise Not_found; let y = input_line stdin in "none" with _ -> y
<whitequark>
what should it do?
<Algebr>
just return string "none"
<whitequark>
how so?
<whitequark>
that doesn't make any sense at all
<Drup>
Algebr: I don't know what mental model of programming language you have in your head, but it's a weird one :D
<Algebr>
I'm mostly just tired..
<Algebr>
I was thinking because the _ catches everything, which gives back y, which is self is just scoped in the "none"?
<Algebr>
but I guess it should be just executing the input_line stdin
<Drup>
err, it's a really weird one x)
<Algebr>
lol, so what's the right answer?
<Drup>
that's this code is wrong and the compiler is going to throw it away
yomimono has quit [Ping timeout: 240 seconds]
yomimono has joined #ocaml
<Algebr>
Why is y unbounded?
<Algebr>
because its never executed?
<whitequark>
because the scope of y is just in the "none" expression
<Drup>
Algebr: would you be a pythonist, by chance ?
<whitequark>
if you have "let <patt> = <expr1> in <expr2>", then whatever is bound by <patt> is only bound within <expr2>
<Algebr>
Drup: Its my primary language, yes.
<Drup>
ah, yes
<Drup>
so
<Drup>
python's scopes rules are broken
<Algebr>
lol, wat?
<whitequark>
indeed
<Drup>
so, in ocaml
<Drup>
and in most languages with sane scoping rules
<Drup>
you can't access identifiers created inside a scope from outside of it
<Drup>
typical example
<Drup>
let x = begin let a = 3 in 4 end in a ;;
<Drup>
that doesn't work.
<Drup>
That's because a is inside the scope, you don't have the right to access it outside the scope created by begin ... end
omqal has quit [Quit: omqal]
<Drup>
I know it's different in python, and I'm sure some people trying to do static analysis on python must bang their heads against some walls collectively about it. :D
<pjdelport>
>>> (lambda x=(lambda a=3: 4)(): a)()
<pjdelport>
NameError: name 'a' is not defined
<whitequark>
Drup: yay variable hoisting
<Drup>
pjdelport: you can do in a for loop
<pjdelport>
Drup: Yes, but for loops don't establish a scope.
<Drup>
well, they should.
<Algebr>
yes, that's annoying.
<whitequark>
Drup: it's even funnier in Ruby
<whitequark>
where a variable in a closure shadows an outer variable only if one exists
<Drup>
ah yes
<Drup>
late binding
<whitequark>
not really, not late
<whitequark>
it's determined at parsing time
<Drup>
ah, not like in js ?
<Drup>
ahah xD
<Drup>
fabulous :D
<whitequark>
in ruby 1.8 it was much worse
<whitequark>
a closure *argument* would *change* a variable in outer scope with same name
<whitequark>
i.e. i = 0; 5.times { |i| }; p i # => 4
<Algebr>
oh shit it just clicked.
<Drup>
whitequark: that's so insane, on so many level
<Drup>
why do people keep using insane languages ?
<whitequark>
Drup: indeed
<whitequark>
well, 1.8 is long deprecated
* Drup
don't understand people
<whitequark>
Drup: the bonus: the interpreter was a naive ast-walking one
<whitequark>
so it wasn't even a dumb way of bytecode rewriting. just ... insanity
<Drup>
one part of me thing "yay, static typing for everyone"
claudiuc has quit [Remote host closed the connection]
<Algebr>
So in my code example, http://lpaste.net/109412 , I can move the with | Parsing.Parse_error before the final expression and hence I should still have a handle on the lexbuf?
<Drup>
the other part await with great delight the broken stuff they are going to produce :D
<whitequark>
Drup: indeed
<Drup>
think
<Drup>
*
travisbrady has quit [Quit: travisbrady]
<Drup>
Algebr: no, what you should do is move the definition of lexbug outside the scope defined by try ... with
<whitequark>
how is it related to source maps though?
<Drup>
well, the to point to the original file when there is an error in the generated ones
<whitequark>
no, I'm talking about javascript source maps
<Drup>
Oh.
<whitequark>
... I don't think camlp4 can do that
<Drup>
well, camlp4 has a feature that would be called sourcemap, where the output file is annotated in a way the compiler understand, to redirect the error location
<whitequark>
" I think having these implemented correctly could be compelling enough to make the web the primary development platform for OCaml. The Chrome debugging tools are that good!"
<def`>
NoNNaN: what would be the benefit ? losing the GC :P ?
<Drup>
on top of that
samrat has quit [Ping timeout: 240 seconds]
samrat has joined #ocaml
<Drup>
you will go through all the llvm machinery and, even if llvm is a very good compiler, I'm not sure it's going to offer much gain, considering the loss of information
avsm1 has joined #ocaml
<whitequark>
Drup: I believe I can make LLVM aggressively inline AND lift allocations to stack
<NoNNaN>
Drup: js_of_ocaml already use different layout and base types, not the ocaml one
avsm1 has quit [Client Quit]
<whitequark>
which may or may not offer a significant benefit over what ocamlopt does
<whitequark>
and use the above to vectorize code, which will offer one for a certain narrow spot
<Drup>
whitequark: I didn't mean compared to ocamlopt
<whitequark>
oh, you mean for emscripten
<Drup>
whitequark: I meant between js_of_ocaml and emscripten
<whitequark>
no, that's dumb. js_of_ocaml is the best solution you can have.
<Drup>
NoNNaN: I know
<NoNNaN>
Drup: could you show me where is the super ocaml gc in js_of_ocaml ?
<Drup>
nowhere, since js come with one ?
<whitequark>
NoNNaN: there is no JS GC in asm.js. you will need to provide your own.
avsm has quit [Ping timeout: 260 seconds]
<Drup>
(embedding a whole gc in every generated js is going to be super good for the size =')
<whitequark>
Drup: (encoding what is essentially machine code in a faux-JS already does *wonders* for it)
<Drup>
(js_of_ocaml is pretty good on the code size aspect of the question too, btw)
<whitequark>
especially if you gzip it
<whitequark>
I want to gzip it, gzip it ~
<Drup>
even before gziping
<NoNNaN>
whitequark: and how good is the browser js implementation gc for functional code? compared the native code ?
BitPuffin has joined #ocaml
<whitequark>
NoNNaN: good enough you can't easily beat it with a roundabout GC impl that has zero access to underlying machine or even any knowledge of its architecture
<NoNNaN>
fortunately there are lot's of competition in browser js performance, we may see surprising improvements
<whitequark>
write an asm.js-based GC that outperforms JS's GC
<whitequark>
then I'll be interested in your claims
bezirg has joined #ocaml
<whitequark>
even if you have a GC that is equally fast as JS's GC, it will still translate to slower asm.js code (in the browsers that are dumb enough to rely on asm.js, i.e. firefox)
<whitequark>
because asm.js doesn't, for example, inline code, or use dynamic range information for optimization
<whitequark>
asm.js is basically an implementation detail of the Firefox JS engine that somehow became a technological fetish
<NoNNaN>
just like nacl and pnacl in chrome
<whitequark>
nope
<whitequark>
PNaCl isn't even strictly restricted to web, it's a generic machine code sandboxing technology
<def`>
(what's the point of starting with one of the worst software stack, complaining it's slow, sacrificing hundred of monkeys to optimize it to hopefully reach decent performance in ten years?)
<Drup>
def`: "software engineering"
dsheets has joined #ocaml
<Drup>
apparently, it's a thing
<adrien>
come on, we're not fri... oh, right, we are, go on
<MercurialAlchemi>
def`: less monkeys?
<adrien>
would be better if you replaced monkeys with paris pigeons
<def`>
_o/ yeah friday friday yeah
<MercurialAlchemi>
I'd replace monkeys with French politicians, personally...
<adrien>
:)
<whitequark>
no one loves the politicians of their country т_т
<def`>
yet, I guess on this topic you have an edge
<MercurialAlchemi>
oh, they're good for entertainment: a new investigation every month, you don't get bored
<MercurialAlchemi>
(well, considering I'm not living in France anymore I guess they're not so much "my" politicians anymore, but still, ugh)
<MercurialAlchemi>
maybe I have it wrong
<MercurialAlchemi>
replace the politicians with the monkeys: bonobos for presidents
studybot has joined #ocaml
<whitequark>
we have a joke here. "everything in Russia is awful, so a group of citizens decides to resurrect Stalin. they promptly do and ask him what to do. "Execute all the politicians and paint Kremlin blue" "But, but, why blue?" "I see there are no objections to the first part"
<MercurialAlchemi>
I like that one
<adrien>
:)
<Drup>
=')
<MercurialAlchemi>
(admittedly, politicians here in DK are not that bad)
hhugo has joined #ocaml
<def`>
I knew it with "Execute all $PUT_SOME_GROUP_HERE and 1 engineer." "Why an engineer?" hehehe
<whitequark>
def`: I see it transcends borders
koderok has joined #ocaml
iorivur has joined #ocaml
darkf_ has joined #ocaml
darkf has quit [Ping timeout: 272 seconds]
iorivur has quit [Remote host closed the connection]
koderok has quit [Quit: koderok]
hhugo has quit [Ping timeout: 244 seconds]
BitPuffin has quit [Ping timeout: 240 seconds]
hhugo has joined #ocaml
rand000 has quit [Quit: leaving]
ontologiae has joined #ocaml
yacks has quit [Quit: Leaving]
Simn has joined #ocaml
_andre has joined #ocaml
hhugo has quit [Quit: Leaving.]
badon has joined #ocaml
hhugo has joined #ocaml
Haudegen has quit [Remote host closed the connection]
Haudegen has joined #ocaml
Haudegen is now known as Guest74955
Guest74955 is now known as Haudegen
hhugo has quit [Quit: Leaving.]
chris2 has quit [Ping timeout: 260 seconds]
seanmcl has joined #ocaml
sepp2k has joined #ocaml
darkf_ is now known as darkf
fold has joined #ocaml
coder has joined #ocaml
chris2 has joined #ocaml
englishm has joined #ocaml
ggole has joined #ocaml
axiles has quit [Ping timeout: 260 seconds]
BitPuffin has joined #ocaml
coder has quit [Ping timeout: 245 seconds]
englishm has quit [Remote host closed the connection]
englishm has joined #ocaml
shinnya has joined #ocaml
axiles has joined #ocaml
_whitelogger has joined #ocaml
gperetin has joined #ocaml
_5kg has joined #ocaml
hexo has joined #ocaml
pyon has joined #ocaml
pyon is now known as Guest25215
Guest25215 has quit [Changing host]
Guest25215 has joined #ocaml
Guest25215 has quit [Client Quit]
ontologiae has quit [Ping timeout: 244 seconds]
esden has joined #ocaml
yroeht has joined #ocaml
pyon has joined #ocaml
BitPuffin has quit [Ping timeout: 264 seconds]
yacks has joined #ocaml
Submarine has quit [Remote host closed the connection]
hhugo has joined #ocaml
bytbox has joined #ocaml
boogie has quit [Remote host closed the connection]
lordkryss has joined #ocaml
jprakash has joined #ocaml
bytbox has quit [Ping timeout: 240 seconds]
boogie has joined #ocaml
boogie has quit [Remote host closed the connection]
avsm has joined #ocaml
_0xAX has quit [Remote host closed the connection]
parcs has quit [Remote host closed the connection]
travisbrady has joined #ocaml
parcs has joined #ocaml
Submarine has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
ebzzry has joined #ocaml
S11001001 has joined #ocaml
S11001001 has quit [Changing host]
S11001001 has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
avsm has joined #ocaml
avsm1 has joined #ocaml
BitPuffin has joined #ocaml
englishm has quit [Remote host closed the connection]
englishm has joined #ocaml
bytbox has joined #ocaml
avsm has quit [Ping timeout: 264 seconds]
Algebr has joined #ocaml
bytbox has quit [Ping timeout: 240 seconds]
hhugo has quit [Quit: Leaving.]
englishm has quit [Remote host closed the connection]
englishm has joined #ocaml
bytbox has joined #ocaml
<Algebr>
trying to emulate python's commenting rules,
<Algebr>
Wouldn't the regex be something like: '#'[^ '\n']* { <myRule> lexbuf }
<ggole>
You'd probably want to eat the newline too
<ggole>
(If any.)
<whitequark>
don't forget to handle the comment right before EOF case
MercurialAlchemi has quit [Ping timeout: 250 seconds]
<Algebr>
Would it be cleaner to do like '#'[^]* { <commentRule> lexbuf }
boogie has joined #ocaml
<Algebr>
and then a separate commentRule?
boogie has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
jbrown has quit [Remote host closed the connection]
jjwatt has joined #ocaml
fold has quit [Ping timeout: 246 seconds]
<ggole>
(eof | '\n'), I would think
<ggole>
Hmm, not sure if that would do the right thing with line counts.
<def`>
hmm, not sure either :'
<whitequark>
you don't need to consume \n in the comment rule
<whitequark>
just leave it to your regular handler
<def`>
correct
Algebr has quit [Remote host closed the connection]
Algebr has joined #ocaml
<Algebr>
whitequark: ocamllex doesnt like .*, cause I Was trying '#'.* { }
avsm1 has quit [Quit: Leaving.]
avsm has joined #ocaml
pminten has joined #ocaml
nojb has joined #ocaml
axiles has quit [Ping timeout: 246 seconds]
avsm has quit [Quit: Leaving.]
ontologiae has joined #ocaml
koderok has joined #ocaml
koderok has quit [Client Quit]
ontologiae has quit [Ping timeout: 255 seconds]
MercurialAlchemi has quit [Ping timeout: 250 seconds]
MercurialAlchemi has joined #ocaml
axiles has joined #ocaml
pyon has quit [Quit: Fiat justitia ruat caelum.]
coder has quit [Quit: Lost terminal]
pyon has joined #ocaml
axiles has quit [Ping timeout: 272 seconds]
pyon has quit [Read error: Connection reset by peer]
axiles has joined #ocaml
pyon has joined #ocaml
Kakadu has quit [Quit: Page closed]
<whitequark>
ocamllex doesn't have .
philtor has joined #ocaml
Algebr has quit [Remote host closed the connection]
yacks has quit [Read error: Connection reset by peer]
Submarine has quit [Ping timeout: 250 seconds]
olasd has quit [Quit: WeeChat 0.4.3]
olasd has joined #ocaml
Submarine has joined #ocaml
fold has joined #ocaml
philtor_ has joined #ocaml
dadda has joined #ocaml
badon has quit [Ping timeout: 244 seconds]
ontologiae has joined #ocaml
MercurialAlchemi has joined #ocaml
seanmcl has quit [Read error: Connection reset by peer]
sepp2k has quit [Quit: Konversation terminated!]
BitPuffin has quit [Ping timeout: 272 seconds]
_0xAX has quit [Remote host closed the connection]
fraggle_laptop has joined #ocaml
troutwine is now known as troutwine_away
yomimono has joined #ocaml
seanmcl has joined #ocaml
samrat has quit [Quit: Computer has gone to sleep.]
toroidalcode is now known as toroidalcode_
WraithM has quit [Ping timeout: 255 seconds]
Submarine has quit [Ping timeout: 240 seconds]
Submarine has joined #ocaml
toroidalcode_ is now known as toroidalcode
boogie has quit [Quit: Leaving...]
dadda has quit []
ontologiae has quit [Ping timeout: 272 seconds]
fraggle_laptop has quit [Ping timeout: 246 seconds]
so has quit [Ping timeout: 245 seconds]
ollehar has joined #ocaml
ggole has quit []
so has joined #ocaml
_andre has quit [Quit: leaving]
hhugo has quit [Quit: Leaving.]
hhugo has joined #ocaml
troutwine_away is now known as troutwine
rand000 has joined #ocaml
_cody_ has joined #ocaml
<xavierm02>
Hi. I can't find a way to force optional arguments to have a more generic type than the one of the default value. Is it even possible? let id : ?arg:'a -> 'a = fun ?(arg = 0) -> arg;;
<def`>
No, it's not
<xavierm02>
Okay. Thanks :(
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
oriba has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
seanmcl has joined #ocaml
Simn has quit [Read error: Connection reset by peer]
WraithM has joined #ocaml
rand000 has quit [Ping timeout: 250 seconds]
jprakash has quit [Ping timeout: 272 seconds]
hhugo has quit [Quit: Leaving.]
bytbox has quit [Remote host closed the connection]
<MercurialAlchemi>
any way of getting readline-like functionalities ina program?
WraithM has quit [Ping timeout: 240 seconds]
<MercurialAlchemi>
doesn't seem to be any libeadline binding