<whitequark>
rather to make an ad-hoc lexer state machine
<ggole>
(Unless it is something very repetitive like a big LUT.)
<companion_cube>
whitequark: ah, much more fun :D
<whitequark>
‘fun’
<michipili>
bonus points for parse.y if there is less than fourteen functions :)
<WhatElse>
if you don’t know what is inside a variable how can you debug your code? Please help me just to get this, otherwise I don’t know how to proceed :D
<WhatElse>
I mean how do you do?
hausdorff has joined #ocaml
<companion_cube>
WhatElse: I tend to debug with printf
<companion_cube>
whitequark: btw didn't you have a debugger project?
<whitequark>
companion_cube: yes
<WhatElse>
it is what I’m doing right now, but if I don’t know the type of something how can I print if with printf?
<michipili>
You can get the type of an expression by purposedly introducing a type error in the program. But while you are at recompiling, you can *eprintf*.
<michipili>
It is best to define a custom printer, because you can reuse this work.
<michipili>
Usually, you delete debug-printf statements.
<companion_cube>
WhatElse: oh, you should know the types of expressions :3
<companion_cube>
assuming it compiles of course
<michipili>
So you basically throw-away your work.
<companion_cube>
you can use merlin to help
hausdorff has quit [Ping timeout: 244 seconds]
<companion_cube>
michipili: or you comment them
jpdeplaix has quit [Ping timeout: 244 seconds]
<WhatElse>
can you give me a link? I expect something like: if typeof xxx = yyy then printf …
ebzzry has quit [Remote host closed the connection]
<michipili>
Dead code in comments goes out of sync and after a while nobody can use it nor fix it, and it remains here standing as a Greek ruin. Do not do that! ☺
<WhatElse>
but I really don’t know how to implement something like this
<whitequark>
WhatElse: there is nothing like typeof.
<whitequark>
you need to know the type of the expression.
<michipili>
Does typerex helps for the type problem?
<whitequark>
if you want to learn the type, the simplest method is to introduce a type error, so that the compiler will tell you what it wants.
gnzh has joined #ocaml
<michipili>
whitequark: ditto
<whitequark>
e.g. print_int expr;;
<whitequark>
Error: This expression has type bytes but an expression was expected of type int
<whitequark>
also you could use an editor plugin like ocamlmerlin, if you use vim, emacs or sublimetext
<whitequark>
they all can tell you the type of an expression under cursor.
larhat has joined #ocaml
gnzh has quit [Client Quit]
govg has quit [Quit: leaving]
<WhatElse>
whitequark: ok I’ll try merlin thank you
<WhatElse>
introducing a type error I had: This expression has type string but an expression was expected of type ((string * string) * 'a) list
<WhatElse>
so the type is ((string * string) * ‘a)
<whitequark>
list
<WhatElse>
it is a list of ((string * string) * 'a)
<whitequark>
yep
<WhatElse>
now I have to define a recursive function (for example) that with pattern matching prints that values
<WhatElse>
there isn’t anything already written to print it, right?
jpdeplaix has joined #ocaml
<whitequark>
does this library use camlp4? do you use OCaml >=4.02? if the answers are "no" and "yes", there is something that can write the function for you
<whitequark>
otherwise you'll have to do it yourself
<WhatElse>
the answer is: idk and yes
<whitequark>
grep it for camlp4 :)
<WhatElse>
I have it in makefile
<whitequark>
then you'll have to write the printer yourself
<WhatElse>
bad news :(
<WhatElse>
but what I had to do if I didn’t use camlp4?
<whitequark>
opam install ppx_deriving; -package ppx_deriving.std in the buildsystem; [%show: ((string * string) * _) list] would give you the function you want
<WhatElse>
ok thank you :)
Thooms has quit [Quit: WeeChat 1.0.1]
nicoo has joined #ocaml
<WhatElse>
I’ve written this printer: http://pastebin.com/Mu4qZzJr but it doesn’t print anything.. what could be the reason?
<flux>
depending on where you use it, you might want to flush the print at the end by adding %! after "\nempty list"
<WhatElse>
I’ve added ‘ %!’ in both and it still doesn’t print anything
<WhatElse>
yes
<whitequark>
is it actually called?
_whitelogger has quit [Ping timeout: 256 seconds]
_whitelogger has joined #ocaml
<ggole>
How are you calling it?
<WhatElse>
print_list tabCstr;
<ggole>
Looks fine.
<WhatElse>
://
<whitequark>
fairly sure it's not called.
<whitequark>
put failwith "die" inside
<WhatElse>
?
<ggole>
Try it in the toplevel, it works fine (odd printing, but it type checks and produces output).
<whitequark>
WhatElse: it raises an exception
<whitequark>
so if it's called, you'll see the program exit
<WhatElse>
it’s strange because just the line before I print another string that is actually printed
<whitequark>
replace begin..end with Ocamlbuild_cppo.dispatcher
<whitequark>
done
<companion_cube>
does this define useful variables in cppo?
<whitequark>
or let me set this up for you
<companion_cube>
I want to #if depending on whether ocaml>=4.02
<whitequark>
frankly, I'd rather just send a PR than listen to you complain about myocamlbuild
<whitequark>
what's the project?
<companion_cube>
(and the plugin looks like it only works for >= 4.01)
<companion_cube>
containers :p
<whitequark>
you need to support pre-4.01?
<companion_cube>
I'd like to support 4.0, es
<companion_cube>
yes
<companion_cube>
before 4.0 is prehistory
<whitequark>
ok, that doesn't have -plugin-tag
dsheets has joined #ocaml
michipili has quit [Ping timeout: 244 seconds]
triskiii has joined #ocaml
michipili has joined #ocaml
<whitequark>
wow, the output of your ./configure is annoying.
<companion_cube>
it's oasis' configure
<companion_cube>
at least I don't have to write it
<whitequark>
talking about this
<whitequark>
Build the misc library, containing everything from the rotating kitchen sink to automatic banana distributors: ... false
<whitequark>
Build modules related to FastCGI, depending on CamlGI: ........................................................... false
<companion_cube>
oh, line is too long?
<whitequark>
yes
<companion_cube>
ok, I'll change it ^^
nojb has joined #ocaml
<troydm>
any ocamlyacc experts here?
<whitequark>
maybe
hausdorff has joined #ocaml
larhat1 has joined #ocaml
<troydm>
well I have some expression list seperated by comma and i want parser to evaluate first expression and only after it evalutes it evalute second
<troydm>
for example i have f(a+1,b+3)
<Drup>
whitequark: speaking of ocamlyacc, do you started working on the llvm tutorial ?
<whitequark>
troydm: don't evaluate expressions in the parser
<whitequark>
Drup: not yet
<flux>
I think trusting the parser to work in a certain - undocumented - order could be a recipe for unexpected and fragile results ;)
<Drup>
whitequark: where is the repository for this tutorial
darkf has quit [Quit: Leaving]
<whitequark>
it's the LLVM repository
<Drup>
ok
<whitequark>
docs/tutorial/OCamlLangImpl*
hausdorff has quit [Ping timeout: 265 seconds]
<troydm>
whitequark: are you going to rewrite the llvm tutorial into ocamllex and menhir?
<whitequark>
and examples/OCaml-Kaleidoscope
<whitequark>
troydm: Drup and sedlex, but yes
larhat has quit [Ping timeout: 244 seconds]
<whitequark>
and make it use MCJIT as well
<Drup>
whitequark: I'm not sure if an AST is a good idea in the end
<companion_cube>
whitequark: do I need to tag files with "cppo" to use your PR? (thansk btw)
<Drup>
yes you do
<Drup>
the plugin is documented
<whitequark>
nope
<whitequark>
companion_cube: the idea is that you rename files to .cppo.ml
<Drup>
(well, didn't saw the plugin)
<companion_cube>
oh, right.
<Drup>
the PR*
<Drup>
grrr
<Drup>
ok, I'll stop multitasking and saying bs >_>
<whitequark>
Drup: what about AST?
<Drup>
whitequark: it's duplicated work to do an AST *and* a well typed interface
<companion_cube>
ok, awesome
<companion_cube>
whitequark: many thanks, you really are awesome
<Drup>
companion_cube: the plugin is still well documented, though
<whitequark>
Drup: oh.
<companion_cube>
well I don't exactly use the plugin, but yes, indeed
<whitequark>
Drup: yes, but there are several concerns
<whitequark>
hm
<Drup>
I know, hence why I'm asking your opinion on it
<whitequark>
I don't have a strong opinion, but this is what I'd consider:
<whitequark>
1) manipulating pure OCaml values is very fast. going through the C bindings, not even marked with noalloc... not that much
<whitequark>
and I know that, say, P/Invoke did become a bottleneck, though it's quite slower than OCaml stubs
<Drup>
speed is not the main concern
<whitequark>
2) having an AST would allow to serialize the IR and send it somewhere else without ever linking to LLVM itself
<whitequark>
such as when aborting the current process is not an option at all
<Drup>
like llvm-general-pure, yes
<Drup>
I agree
<whitequark>
3) you can pattern-match over the AST
<whitequark>
which would make writing passes in OCaml *massively* easier
badkins has joined #ocaml
<Drup>
indeed
<Drup>
but I also want to be able to keep the "user" feature of llvm
<flux>
implementing useful passes can be slow even in C++
<flux>
I have no doubt that if similar ocaml code would need to go via noalloc calls, it could be annoyingly slow
<troydm>
okey say I have rule: expr comma expr { action }
<whitequark>
flux: actually most of the LLVM stubs can be marked noalloc, it's just not done
<troydm>
how can I defer the evaluation of second expression only after action has been executed
<whitequark>
troydm: build an AST in the parser, then evaluate it however you like
<Drup>
troydm: don't, build a datastructure and iter on it
<Drup>
whitequark: I'm not sure how to keep the user feature, except by using a graph
<Drup>
(which I think is a good idea anyway)
<whitequark>
Drup: I think that's ok
<whitequark>
RAUW is a cornerstone of SSA, it must stay
<whitequark>
so, just make it mutable I guess
<Drup>
RAUW ?
<whitequark>
replace all uses with
<Drup>
ah, yes
<Drup>
oh yes clearly, the graph should be mutable
<whitequark>
you do need smart constructors and mutators in this case, but it's a small cost to pay
<Drup>
yes
<whitequark>
companion_cube: you don't need ocamlbuild_more_args I think
<Drup>
it would be quite easier with inline records, I think
<whitequark>
Drup: use them.
<Drup>
ahah
<Drup>
so edgy, very bleeding
<whitequark>
I'm serious, I have no objections to that, considering that gives a nice benefit
<Drup>
well, all that wouldn't help for reverse use, it would only help with one way
<whitequark>
by the time 3.6 is released, 4.03 will be halfway there
<whitequark>
or maybe just there
<companion_cube>
whitequark: right, I can remove it
<companion_cube>
I want to deal with bytes properly, and also with |>
rossberg has quit [Ping timeout: 265 seconds]
<Drup>
whitequark: I have to go, but we need to think of a nice way to implement the bi-directional uses in OCaml
<whitequark>
it's a clone of LLVM IR structures, basically
<whitequark>
adapted to OCaml
<Drup>
ok
<Drup>
(the other solution being to fit everything in ocamlgraph and use it like that :D)
<whitequark>
uhhh, I'm not sure I like this
<Drup>
it would probably not be very different in the end
<whitequark>
hm
<Drup>
you would have a "user" directed graph
<Drup>
which is a strict subgraph of the basicblock graph
<Drup>
not sub, bigger*
<whitequark>
super?
<Drup>
yes, super, thanks
<Drup>
yeah, I have to try some various interfaces
rossberg has joined #ocaml
<companion_cube>
ugh, I get 'Error: Unbound module MyOCamlbuildBase' now
<whitequark>
huh?
<whitequark>
oasis/ocaml versions?
<companion_cube>
might be an old oasis, it's on my jenkins
sheijk has joined #ocaml
<companion_cube>
ok, the pb is that at some place I call ocamlbuild by hand
<MercurialAlchemi>
ugh
<MercurialAlchemi>
I was unfortunately looking at calendar in the hope of experimenting with timezones
<MercurialAlchemi>
and then I see it offers you a way to change the timezone for your entire program by side-effect
thomasga has joined #ocaml
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
nlucaroni has joined #ocaml
hausdorff has joined #ocaml
boogie has joined #ocaml
jgjl has joined #ocaml
ebzzry has joined #ocaml
hausdorff has quit [Ping timeout: 258 seconds]
samrat has quit [Quit: Computer has gone to sleep.]
thomasga has quit [Quit: Leaving.]
samrat has joined #ocaml
Thooms has joined #ocaml
vfoley has joined #ocaml
Thooms has quit [Client Quit]
<vfoley>
Hey, I remember reading about an easier syntax to manipulate number types such as floats and int32. Something like let y = Float.(x + 4.0) in ... Anyone know where I could find more information on that topic?
<nlucaroni>
that's locally opening a module
<nlucaroni>
7.10 in the manual.
<flux>
actually it's not
<flux>
hmm, actually that is :-)
<flux>
but I think pa_do did other things as well
<flux>
triskiii is a spammer
<Drup>
vfoley: just this example, it's possible without a syntax extension, however I remember something done by ocamlpro about that.
<Drup>
MercurialAlchemi: yeah, I think it's the pain point of calendar, that and the heavyness of the interface :/
<Drup>
MercurialAlchemi: there is odate too, but I never really took a look at it
<whitequark>
somehow all ocaml libraries that indicate their ocamlness by a single leading 'o' are terrible
<vfoley>
Drup: I think the example I have in mind requires Core
<whitequark>
wait, obuild
<whitequark>
is that *another* cabal clone
<vfoley>
Int64.(x + y / 2L), something like that
<whitequark>
holy crap, so OCaml has *nine* buildsystems and not eight as previously thought
<Drup>
vfoley: ok, that's really only local open
<companion_cube>
whitequark: please write a tenth one that works well
<Drup>
please don't.
<Drup>
x)
<companion_cube>
why not? :)
<Drup>
vfoley: I don't have Core installed, I suppose it will work with Int64's Core module, but it also works with Batteries' BatInt64
<whitequark>
companion_cube: I guess I'm not annoyed by ocamlbuild enough
<nlucaroni>
could this 10th build system setup any of those 9. :)
<companion_cube>
let's just write something that makes configuring oasis easier!!
<whitequark>
companion_cube: NO
<companion_cube>
just kidding
<whitequark>
don't even joke like that.
<Drup>
:D
araujo has quit [Read error: Connection reset by peer]
araujo has joined #ocaml
thomasga has joined #ocaml
ontologiae has joined #ocaml
sh1ken has quit [Remote host closed the connection]
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jgjl has joined #ocaml
larhat1 has quit [Quit: Leaving.]
zpe has quit [Remote host closed the connection]
jgjl has quit [Client Quit]
oscar_toro has quit [Ping timeout: 245 seconds]
jgjl has joined #ocaml
ontologiae has quit [Ping timeout: 244 seconds]
Thooms has joined #ocaml
<MercurialAlchemi>
Drup: I'll have to look at it
hausdorff has joined #ocaml
boogie has quit [Remote host closed the connection]
zpe has joined #ocaml
roelof has joined #ocaml
<roelof>
Are there more exercises I can make then the 99 ocaml problems ?
<vfoley>
ProjectEuler.net maybe?
lordkryss has quit [Quit: Connection closed for inactivity]
<jbalnit>
have you completed the 99???
<whitequark>
I'd be very bored after solving 99 exercise-type problems
<jbalnit>
yes, i skipped to real work quickly, but they didnt seem doable in a reasonable amount of time. several weeks I guess
<jbalnit>
unless you are really dedicated
jgjl has quit [Ping timeout: 240 seconds]
<roelof>
whitequark: and how did you deal after solving all ???
<whitequark>
I didn't solve them
<whitequark>
in fact, I don't think I solved any programming exercises in my life
jwatzman2 has joined #ocaml
<roelof>
oke, how did you ckeck if you understand the theory. The biggest problem for me is using the theory into real problems
jwatzman2 has quit [Client Quit]
MrScout has joined #ocaml
jwatzman|work has joined #ocaml
Hannibal_Smith has joined #ocaml
jonludlam has quit [Quit: Coyote finally caught me]
larhat has joined #ocaml
<whitequark>
I never really cared whether I did, I just tried to solve some actual problem I had
<roelof>
whitequark: oke,that can also be a way
<roelof>
another question : Does anyone know a good book for a beginner to learn Ocaml prefferly with some exercises ?
boogie has joined #ocaml
slash^ has joined #ocaml
pyon has quit [Ping timeout: 265 seconds]
<Denommus>
oh, an update for workgroups2! Finally!
<Denommus>
wait, I'm on the wrong channel
yomimono has quit [Ping timeout: 255 seconds]
tane has quit [Quit: Verlassend]
<roelof>
No one who has a better idea then reading this book (real ocaml book) and doing the 99 problems ??
samrat has quit [Quit: Computer has gone to sleep.]
<nojb>
roelof: IMHO it would be much better to forget about all that and just find a problem/project that would like to do using OCaml and try to do it.
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
<roelof>
nojb: then I have a problem. I have at this moment not a project in mind
<ggole>
There are tons of exercise/problem sites if that's what floats your boat
<dsheets>
roelof, maybe browse packages in opam which all have source code available and note anything that looks interesting and follow up with that project
<nojb>
roelof: then your poroblem has nothing to do with ocaml :)
<roelof>
dsheets: I can do that but I think I first have to learn the basics
nojb has quit [Quit: nojb]
zpe has quit [Ping timeout: 240 seconds]
govg has joined #ocaml
xaimus has quit [Ping timeout: 245 seconds]
<roelof>
last questions : I come from Rails . Does Ocaml have such a tool like rspec ?
xaimus has joined #ocaml
<whitequark>
ounit
vogler has quit [Ping timeout: 240 seconds]
<roelof>
whitequark: can Ounit do acceptance testing. I thought it was a unit testing tool
<whitequark>
what exactly do you mean by "acceptance testing"?
zpe has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
<flux>
ounit cannot emulate user interaction with the software
<Drup>
roelof: how is that different than unit testing ?
<whitequark>
rspec cannot
<flux>
well, that thing is just a list of assertions written in a different way
<whitequark>
other libraries that you can use with rspec can
Thooms has quit [Quit: WeeChat 1.0.1]
<roelof>
oke, then I use the wrong name
govg has quit [Ping timeout: 245 seconds]
<roelof>
but can I do something like that in Ocaml ?
<Drup>
yes, ounit
<roelof>
oke, thanks all for the info
roelof has quit [Quit: Page closed]
hausdorff has quit [Remote host closed the connection]
samrat has joined #ocaml
q66 has joined #ocaml
govg has joined #ocaml
dsheets has quit [Ping timeout: 245 seconds]
ggole has quit []
hausdorff has joined #ocaml
claudiuc has joined #ocaml
michipili has left #ocaml [#ocaml]
thomasga has quit [Quit: Leaving.]
rossberg has quit [Ping timeout: 265 seconds]
lordkryss has joined #ocaml
thomasga has joined #ocaml
WhatElse has quit [Quit: WhatElse]
keen__________ has joined #ocaml
keen_________ has quit [Ping timeout: 245 seconds]
elfring has joined #ocaml
dch has left #ocaml [#ocaml]
<reynir>
hm, can't find the cohttp documentation right now
dsheets has joined #ocaml
axiles has quit [Ping timeout: 258 seconds]
<companion_cube>
can't wait for opam-doc
<dsheets>
companion_cube, tell me your wishes
<dsheets>
other than "it exists and doesn't suck"
<companion_cube>
1/ works for all opam packages (with little config within opam files) 2/ cross references between packages 3/ global doc somewhere on the web for every package 4/ possibility to build doc locally and access it without a server
<companion_cube>
basically, I want to find in the same place on the web, the doc for zarith, re, react, ocamlnet and lwt (say)
manud has joined #ocaml
<companion_cube>
and if I have my own package on my computer, I'd like to be able to generate its doc and access it without launching a webserver first
<dsheets>
companion_cube, yes, this is coming
<companion_cube>
\o/
<dsheets>
but it will probably be close to year-end
samrat has quit [Quit: Computer has gone to sleep.]
<whitequark>
it does?
<whitequark>
zero commits in opam-doc for months
<dsheets>
whitequark, the repository has scattered
<dsheets>
check out opam-doc-base and doc-ock-lib and ocamlary
<MercurialAlchemi>
companion_cube: a bit like Hackage?
<companion_cube>
MercurialAlchemi: I guess so
<companion_cube>
dsheets: will there be a possibility of using opam-doc locally too?
<dsheets>
companion_cube, yes, this is the next milestone that has an alpha set for friday
<MercurialAlchemi>
hm, global variables in ocaml-doc?