<artagnon>
In ctypes, how do I check if a pointer is null?
<artagnon>
"null" seems to be of the wrong type.
travisbrady has joined #ocaml
<artagnon>
Found it: ptr_opt
BitPuffin has quit [Ping timeout: 264 seconds]
samrat has quit [Quit: Computer has gone to sleep.]
samrat has joined #ocaml
travisbrady has quit [Quit: travisbrady]
mcc has joined #ocaml
<mcc>
Hi... I saw ocaml's type inferer do something REALLY weird today, and I'm trying to understand if this was really right and how I could prevent this in future.
<mcc>
So here's two versions of a file. Wrong: http://pastie.org/9796893 Right: http://pastie.org/9796889 . The difference is the replacement of the function "identity" (1 curried argument) in the wrong file with "kancel" (2 curried arguments) in the right file.
<mcc>
I am interpreting this error, etc, to mean that the appearance of "identity", and this being passed to "makeLet" early in the let rec = and and and block, caused the inferer to believe that makeLet's first argument was of type 'a->'a
<mcc>
and continued believing this *even when* i gave it *explicit* type instructions saying 'no, this is of type value->value->value'.
<struktured>
mcc: no syntax highlighting? :( github gists has it if you specify the file exxtension in the combo box
<mcc>
i.e. it was like "well i inferred this type, so the type you specified must be wrong". it seems like if i specify something exact then that should take precedence
<mcc>
struktured: i don't think i know how to use github gists? that would require me to be using git surely?
<mcc>
struktured: yes, that makes sense. i'll see what i can do.
<struktured>
mcc: not claiming I'll understand this code but..what is the type of Value.t ?
<arcanine69>
whitequark: because C gives you much more control over the hardware
<struktured>
mcc: er I mean Value.value I think
<mcc>
Value.value is a big tagged union with like eight things in it
<arcanine69>
what is ocaml good for?
<arcanine69>
why do people use it.
<struktured>
mcc: well for starters, it doesnt seem to have anything to do with the polymorphism. its because the number of args isnt right, or your missing a parentice
<mcc>
struktured: that sounds right
<mcc>
struktured: comparable situations on stack overflow, someone had a small mysterious syntax error somewhere else
<mcc>
arcanine: complex operations on structured data with high reliability
<mcc>
arcanine: particularly good for language compilers and interpreters
<struktured>
mcc: in first case, it is a three arg thingy, value->value->value. in the other case its ('a->'b) -> 'a -> 'b, which is basically 4 args, although two are a closed in parens
<mcc>
the problem i am perceiving is that i had a bug, i was passing identify in as an argument where that is not appropriate. but i had a lot of trouble finding the bug because rather than giving me the error at the correct point (passing in identity) it gave it to me at an unhelpful point (defining the types of the arguments to makeLet)
<arcanine69>
why is ocaml good? can anyone tell me w hat its used for?
<struktured>
mcc: yeah I hear ya. sometimes the line it reports isn't the line you need to fix. I find that annotating a bunch of stuff with types helps to debug those issues.
<struktured>
arcanine69: but if you're interested in ocaml at all, I suggest trying to use it a bit
<arcanine69>
why is it better than c thoguh
<arcanine69>
like whats the difference
<mcc>
struktured: What's confusing me-- "decorate with types until you see the problem" is exactly what i was trying to do. But then it just placed an error on my type decorations.
<mcc>
struktured: how would i go about understanding, when program #2 fails, *why* it thinks "a" should be something other than what it is?
<struktured>
mcc: I spotted your error just by noting that makeLet was the cause and finding references to it. you need to remember that invocations of a function "coerce" that function's signature to some degree, and thus may be root cause the type error
<struktured>
arcanine69: writing code faster is a big one for me. easier to maintain, higher level of abstraction, blah blah
<mcc>
struktured: ok. but there is not some way to just flat out insist "no, really, this function has this type"?
<mcc>
struktured: like if i'd put the type on the function rather than the arguments, would you expect a different outcome?
<mcc>
ooo
<struktured>
struktured: I think if you rationalize from the interpreters point of view. it starts with first observatoin of makeLet, which coerces the type right there. then it sees your actual definition, but its "too late" then
<struktured>
*mcc
<mcc>
also something i guess i just noticed is if i reorder makeLet before tableBlank, it suddenly trusts the types in the makeLet body more than the ones in the tableBlank body...
<mcc>
ok
<mcc>
so putting makeLet first would be a sensible way to get the type checker to do what i want?
<mcc>
struktured: ok, this is all very helpful. if i was going to submit it to the list, who would i contact about that?
<struktured>
mcc: hmm I saw this elsewhere like reddit or something, but can't find it now
samrat has quit [Quit: Computer has gone to sleep.]
<mcc>
ok. i'll work it out later. headed to dinner, thank you for the help!
mcc has quit [Quit: This computer has gone to sleep]
artagnon has left #ocaml [#ocaml]
shinnya has quit [Ping timeout: 244 seconds]
funtik_ has quit [Remote host closed the connection]
bytbox has joined #ocaml
bytbox has quit [Remote host closed the connection]
samrat has joined #ocaml
alkoma has joined #ocaml
<struktured>
ah sweet victory. TIL that Deferred.all is not iterative but actually parallel, or maybe just interuptable. either way, not good when you are sharing resources between deferreds. I used fold + bind instead
samrat has quit [Quit: Computer has gone to sleep.]
mcc has joined #ocaml
ygrek has quit [Ping timeout: 258 seconds]
Bluddy has quit [Quit: Connection closed for inactivity]
samrat has joined #ocaml
psy_ has quit [Quit: Leaving]
AltGr has left #ocaml [#ocaml]
pdewacht has quit [Ping timeout: 256 seconds]
manud_ has joined #ocaml
rgrinberg has joined #ocaml
kakadu has joined #ocaml
psy_ has joined #ocaml
arcanine69 has quit [Ping timeout: 258 seconds]
rgrinberg has quit [Quit: Leaving.]
ygrek has joined #ocaml
mcc has quit [Quit: This computer has gone to sleep]
psy__ has joined #ocaml
psy__ has quit [Read error: Connection reset by peer]
ebzzry has joined #ocaml
rgrinberg has joined #ocaml
shinnya has joined #ocaml
davine has joined #ocaml
davine has left #ocaml [#ocaml]
keen__________11 has joined #ocaml
keen__________10 has quit [Ping timeout: 245 seconds]
axiles has joined #ocaml
chinglish has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
ineol has joined #ocaml
milosn has joined #ocaml
ggole has joined #ocaml
shinnya has quit [Ping timeout: 244 seconds]
IbnFirnas has quit [Ping timeout: 244 seconds]
Simn has joined #ocaml
alkoma has quit [Ping timeout: 245 seconds]
Intensity has quit [Remote host closed the connection]
robink has quit [Ping timeout: 244 seconds]
robink has joined #ocaml
robink has quit [Changing host]
robink has joined #ocaml
Arsenik has joined #ocaml
marynate has joined #ocaml
tharugrim has quit [Ping timeout: 244 seconds]
tharugrim has joined #ocaml
larhat has joined #ocaml
chinglish has quit [Quit: Nettalk6 - www.ntalk.de]
chinglish has joined #ocaml
ontologiae has joined #ocaml
chinglish has quit [Ping timeout: 245 seconds]
chinglish has joined #ocaml
alkoma has joined #ocaml
ebzzry has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
alkoma has quit [Ping timeout: 240 seconds]
Haudegen has quit [Ping timeout: 256 seconds]
Haudegen has joined #ocaml
pdewacht has joined #ocaml
manud_ has quit [Quit: Be back later ...]
manud_ has joined #ocaml
manud_ has quit [Ping timeout: 250 seconds]
ygrek has quit [Ping timeout: 244 seconds]
ontologiae has quit [Ping timeout: 256 seconds]
liweijian has joined #ocaml
AlexRussia has joined #ocaml
alkoma has joined #ocaml
bernardofpc has quit [Ping timeout: 256 seconds]
alkoma has quit [Ping timeout: 258 seconds]
milosn has quit [Ping timeout: 255 seconds]
MercurialAlchemi has quit [Ping timeout: 272 seconds]
samrat has quit [Quit: Computer has gone to sleep.]
badon_ has joined #ocaml
badon has quit [Disconnected by services]
badon_ is now known as badon
ygrek has joined #ocaml
fraggle-boate has joined #ocaml
BitPuffin has joined #ocaml
fraggle-boate has quit [Ping timeout: 244 seconds]
alkoma has quit [Remote host closed the connection]
alkoma has joined #ocaml
<hugomg>
what version of core_kernel are you talking about? I have 112.01.00 installed just fine.
<artagnon>
112.06.00
<artagnon>
I suspect it has something to do with caml4p and the system compiler.
diethyl has quit [Ping timeout: 240 seconds]
diethyl has joined #ocaml
<hugomg>
that might have something to do with it. anyway, whats the commadnd to create a fresh opam switch again? Id liike to test this without clobbering my current 4.02 switch
<artagnon>
opam switch system, I think.
<artagnon>
Just opam switch -- it'll list options.
<hugomg>
I mean, is there a way to create a separate switch for a project, similar to how you make a sandbox in cabal?
<artagnon>
Oh, I have no idea. Wait, let me switch 4.02.1 and try again.
ineol has quit [Quit: ineol]
ingsoc has quit [Quit: Leaving.]
<Leonidas>
no, I don't think opam does sandboxes
Anarchos has joined #ocaml
<hugomg>
is there a way to do sandboxes at all then :/
<artagnon>
Same issue.
<artagnon>
The package seems to be broken > whitequark
Arsenik has quit [Remote host closed the connection]
<whitequark>
jpdeplaix maintains the package
<whitequark>
if you're talking about llvm
Thooms has quit [Quit: WeeChat 1.0.1]
milosn has quit [Ping timeout: 264 seconds]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
<artagnon>
I'm talking about the core_kernel package.
<artagnon>
I
<artagnon>
I'll raise an issue on gh for now.
<whitequark>
um
<whitequark>
why are you talking to *me* about core_kernel
<whitequark>
I avoid it like plague
<artagnon>
Oh :\
<artagnon>
I thought you'd be in the loop about maintaining it.
<artagnon>
Do you use JaneStreet's library then?
marynate has quit [Quit: Leaving]
<whitequark>
no
<Leonidas>
All time Core saves is spent getting it to even build at all :-(
<artagnon>
whitequark: I sent you a diff.
<artagnon>
After much thought, that's what I came up with.
<artagnon>
ErlangGC.cpp calls GCRegistry::Add<>, but I'm afraid it's not getting linked in.
<artagnon>
Which is why set_gc(Some "erlang") f complains.
Anarchos has joined #ocaml
<whitequark>
no, why are you touching GC at all?
<whitequark>
I told you not to.
<whitequark>
it's currently not very useful and it will change radically in near future
<whitequark>
if you want to do something with it, please write Philip
<whitequark>
regarding not being linked in, yes, that's very likely
struktured has quit [Ping timeout: 258 seconds]
ontologiae has joined #ocaml
bytbox has joined #ocaml
<artagnon>
:(
<artagnon>
Is Philip taking care of OCaml bindings as well?
<whitequark>
no
<artagnon>
Then what's the problem with this change?
<whitequark>
what exactly do you want to do with GC?
<artagnon>
I want to see what it can do :)
<whitequark>
use llc to emit bitcode, put gc "xxx" manually where you want it in the LLVM assembly
<whitequark>
that's the *fast* way to do it
<artagnon>
I have to emit lots of it if I want to plug in my own gc, no?
<artagnon>
I do emit gc "xxx" from my program successfully
<whitequark>
um, what?
<whitequark>
you can only implement a GC plugin in C++
<artagnon>
Yes, I know.
<artagnon>
I currently have something.
<artagnon>
I want to see an existing one work first, so I can fix mine.
<whitequark>
so, see which library is shadow stack linked into, and link that.
<artagnon>
codegen, iiuc.
<artagnon>
Hence that patch.
<artagnon>
I'm pushing the LLVM lib "codegen" into the OCaml lib "llvm".
Anarchos has quit [Quit: Nedeleg laouenn !!!]
<artagnon>
How do I make sure that it's actually linked? Do I have to force a rebuild
<whitequark>
no, why are you putting codegen there? it's a library wrapping the LLVM core
<Leonidas>
hugomg: that's interesting. Didn't know you can alias compilers. Does that work?
<artagnon>
Because it has the function set_gc.
<whitequark>
if you link in anything that depends on codegen, e.g. native, or jit, it will already get linked in
<whitequark>
huh?
<whitequark>
set_gc works on IR.
<hugomg>
i think it should. still compiling the compiler though
<artagnon>
Yeah, I know. But for it to set an existing gc, it needs to be linked to codegen.
<artagnon>
Okay, so native or jit.
* artagnon
tries that
<Leonidas>
hugomg: oh, it it compiles a new compiler, that sounds very much like it is working
<Leonidas>
gotta remember that trick
<whitequark>
artagnon: basically linking in any backend will work.
<artagnon>
What are the valid packages I can give to ocamlfind?
<Leonidas>
ocamlfind list?
<hugomg>
artagnon: core_kernel 112.06.00 installed just fine on a fresh switch here. weird that you had problems with it
<artagnon>
Leonidas: Ah, thanks.
<artagnon>
hugomg: Hm.
<artagnon>
Linux?
<hugomg>
yes, debian
<Leonidas>
probably different system, that explains it
milosn has joined #ocaml
<artagnon>
whitequark: That didn't fix the problem.
<artagnon>
Shall I atleast write tests for c/cpp?
<Leonidas>
core_kernel 112.06.00 works on arch amd64 as well
<artagnon>
That' strange. Let me try again.
<whitequark>
artagnon: not really, no, the problem is in your code
<whitequark>
(most likely)
<artagnon>
What problem? I set_gc(...) and jit it as usual.
<whitequark>
you'll have to check whether the initialization function is linked in and called. objdump and gdb are your friends
ggole has quit []
larhat has quit [Quit: Leaving.]
ineol has joined #ocaml
Submarine has quit [Remote host closed the connection]
<artagnon>
whitequark: Thanks for the tip! I found out what happened:
<artagnon>
lli and llc both do #include "llvm/CodeGen/LinkAllCodegenComponents.h" explicitly.
<artagnon>
That's the only way to get access to the GCs.
<artagnon>
How do I expose it via OCaml now?
Snark has joined #ocaml
<artagnon>
A new llvm.codegen module?
<dch>
hi, new ocamler here. I work on FreeBSD mainly and looks like I need https://github.com/janestreet/core/pull/21/ to get bin_prot (as a dep for core_extended) installed. I have *no* idea how to tell opam to use this, and blindly cloning the repo and running gmake fails.
struktured has joined #ocaml
<Leonidas>
dch: you can probably pin it in opam
<Leonidas>
but are you sure it is not already merged? That PR was more than a year ago and many new Core releases were made
rgrinberg has quit [Quit: Leaving.]
<dch>
Leonidas: oops yes that is merged, but I still have issues. let me get a log
<Leonidas>
dch: oh, then you can pin it to tell OPAM to use a different repo
<Leonidas>
(namely, the repo where it is fixed already)
<dch>
ok, I will read up on pinning & see how I get on — thanks!
<whitequark>
artagnon: hm
<whitequark>
yes, I think so
<Leonidas>
or as a quick fix, you could probably just put a gcc symlink that points to your desired compiler in the path
<dch>
FWIW I get a bit further now, git cloned repo with patch, gmake fails with missing deps, so I opam install those, then run gmake again and get https://dpaste.de/SOM4 which looks maybe sensible
<dch>
clang != gcc, not sure how that would work on FreeBSD. But as a fallback I can always install a gcc I suppose.
<dch>
thanks for the tips Leonidas, bbl with hopefully good news
<Leonidas>
dch: yes, but mkdir foo && ln -s $(which clang) foo/gcc && export PATH=$(pwd)/foo:$PATH could do the trick
lopex has quit [Quit: Connection closed for inactivity]
<Leonidas>
quite hackish and will break on the next update, though.
manud_ has joined #ocaml
AlexRussia has quit [Changing host]
AlexRussia has joined #ocaml
Simn has quit [Quit: Leaving]
samrat has quit [Quit: Computer has gone to sleep.]
hilquias has quit [Ping timeout: 240 seconds]
<artagnon>
whitequark: I'm struggling to structure it properly.
<artagnon>
codegen_ocaml.c needs to somehow include a C++ header, right?
AlexRussia has quit [Ping timeout: 256 seconds]
AlexRussia has joined #ocaml
Procian has quit [Ping timeout: 265 seconds]
AlexRussia has quit [Changing host]
AlexRussia has joined #ocaml
<whitequark>
I'm not really sure if we want to do this in upstream.
<artagnon>
I'm adding something to llvm-c
<artagnon>
Oh.
<whitequark>
can you add this stub locally in your project?
<whitequark>
the default GCs are not exactly useful
<artagnon>
shadow-stack can certainly be useful, I think.
<whitequark>
it's too slow
<artagnon>
It's exposed via the C++ bindings; why should OCaml suffer?
<artagnon>
I agree that it's slow.
<artagnon>
... but one big usecase of LLVM is to build toy compilers like mine.
<artagnon>
Life would be much easier if this were an initialization function instead of a global variable in a header.
<whitequark>
but there *is* an initialization function
badon has quit [Quit: Leaving]
<whitequark>
include/llvm/CodeGen/GCs.h
<artagnon>
There are many initialization functions.
AlexRussia has quit [Ping timeout: 240 seconds]
<artagnon>
In the future, I see better default GCs.
<whitequark>
ok, I agree
<artagnon>
Thanks, I should have something good in a bit.
AlexRussia has joined #ocaml
keen__________12 has quit [Read error: Connection reset by peer]
keen__________12 has joined #ocaml
MrScout has joined #ocaml
MrScout has quit [Remote host closed the connection]
MrScout has joined #ocaml
tane has joined #ocaml
struktured has quit [Quit: Konversation terminated!]
badon has joined #ocaml
MrScout has quit [Ping timeout: 240 seconds]
axiles has quit [Remote host closed the connection]
hugomg has quit [Ping timeout: 244 seconds]
MrScout has joined #ocaml
manud_ has quit [Quit: Be back later ...]
manud_ has joined #ocaml
ontologiae has quit [Ping timeout: 272 seconds]
Tekk_ has joined #ocaml
manud_ has quit [Ping timeout: 252 seconds]
<Tekk_>
Is there some sort of magic you need done in order to use opam modules from the repl? if I load a module from the repl then unless it's a core module I get that it's unbound but if I compile then it's fine.
<Tekk_>
I do use ocamlfind for compilation, but there doesn't seem to be an argument to use ocamlfind with a repl
<Tekk_>
I've run the init.sh and opam config env
deavid has quit [Ping timeout: 250 seconds]
<whitequark>
enter #use "topfind";; in the REPL
<whitequark>
then, #require "package";;
<Tekk_>
ah, alright
<Tekk_>
thanks whitequark
deavid has joined #ocaml
ontologiae has joined #ocaml
rgrinberg has joined #ocaml
Tekk_ has left #ocaml ["ERC Version 5.3 (IRC client for Emacs)"]
mcc has joined #ocaml
ontologiae has quit [Ping timeout: 264 seconds]
mcc has quit [Quit: This computer has gone to sleep]
milosn has quit [Ping timeout: 240 seconds]
myyst has quit [Quit: Leaving]
myyst has joined #ocaml
kakadu has quit [Remote host closed the connection]
MrScout has quit [Ping timeout: 240 seconds]
manud_ has joined #ocaml
manud_ has quit [Ping timeout: 258 seconds]
enitiz has quit [Ping timeout: 258 seconds]
artagnon has left #ocaml [#ocaml]
rgrinberg has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
bernardofpc has joined #ocaml
ontologiae has joined #ocaml
uris77 has quit [Quit: leaving]
cdidd has quit [Ping timeout: 240 seconds]
MercurialAlchemi has joined #ocaml
tani has joined #ocaml
tane has quit [Read error: Connection reset by peer]
Haudegen has quit [Ping timeout: 258 seconds]
ta`e has joined #ocaml
pyon is now known as Guest35532
tani has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
Guest35532 has quit [Ping timeout: 250 seconds]
hugomg has joined #ocaml
enitiz has joined #ocaml
ontologiae has quit [Ping timeout: 250 seconds]
seangrove has joined #ocaml
<seangrove>
Is Opam down right now? I'm getting a 403 on opam.ocaml.org/1.1
<Leonidas>
maybe its way of saying "spend time with your family" ;-)
<whitequark>
that's a cruel suggestion.
MercurialAlchemi has quit [Ping timeout: 240 seconds]
* Leonidas
spent his time with watching movies, writing caml and eating fastfood.