hausdorff has quit [Remote host closed the connection]
hausdorff has joined #ocaml
Pepe_ has quit [Remote host closed the connection]
hausdorff has quit [Remote host closed the connection]
Mercuria1Alchemi has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
hausdorff has joined #ocaml
Mercuria1Alchemi has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
manud has quit [Quit: manud]
Pepe_ has joined #ocaml
jao has quit [Ping timeout: 255 seconds]
manud has joined #ocaml
oscar_toro has joined #ocaml
hhugo1 has quit [Quit: Leaving.]
oscar_toro has quit [Ping timeout: 240 seconds]
mcclurmc has joined #ocaml
uggwar has left #ocaml [#ocaml]
<artagnon>
whitequark: I'm confused about what kind of interface we want in OCaml.
<artagnon>
We can pass a Llvm.llvalue and t from earlier calls to EE.create etc.
<artagnon>
What do we want to do with the function pointer we get back? Run it, right?
mcclurmc has quit [Ping timeout: 272 seconds]
<artagnon>
I realize that we shouldn't use llgenericvalue as the return type, because GenericValue is going away in favor of libffi.
<artagnon>
... but ctypes requires the types of the arguments and return type of the function to construct a valid type.
cago has joined #ocaml
manud has quit [Quit: manud]
oscar_toro has joined #ocaml
manud has joined #ocaml
manud has quit [Quit: manud]
zpe has joined #ocaml
kakadu has joined #ocaml
bezirg has joined #ocaml
keen_______ has joined #ocaml
keen______ has quit [Ping timeout: 272 seconds]
hausdorff has quit [Remote host closed the connection]
hausdorff has joined #ocaml
samrat has quit [Ping timeout: 250 seconds]
dsheets has joined #ocaml
hausdorff has quit [Ping timeout: 240 seconds]
samrat has joined #ocaml
Simn has joined #ocaml
samrat has quit [Quit: Computer has gone to sleep.]
samrat has joined #ocaml
samrat has quit [Client Quit]
ocp has joined #ocaml
samrat has joined #ocaml
samrat has quit [Client Quit]
oscar_toro has quit [Ping timeout: 244 seconds]
zpe has quit [Remote host closed the connection]
ocp has quit [Quit: Leaving.]
ocp has joined #ocaml
sgnb has joined #ocaml
taion809 has joined #ocaml
sinelaw has joined #ocaml
raichoo has joined #ocaml
<raichoo>
Hi, this might look like flame bait but I'm really interested what some of your reasons are why you use OCaml instead of Haskell. The module system seems utterly brilliant, any other reasons?
<johnelse>
raichoo: for me personally, one reason is that it doesn't force you away from imperative programming e.g. you can just write a for loop if you want
<johnelse>
but, the functional features are still there
<raichoo>
fair enough :)
<johnelse>
also, eagerness means less having to worry about hidden space leaks (although laziness does let you do some fun tricks)
<johnelse>
and this is more subjective, but OCaml libraries tend to be more straightforward to use - with Haskell I often had to wade through a sea of types before I could understand what was going on
<raichoo>
I don't have a problem with "subjective answers". I'm interested in them as well ^^
<emias>
In my book, strict evaluation is the really strong point. Haskell can be lots of fun, but the hidden space leak issue can be considered a show stopper for using Haskell for certain types of applications.
hausdorff has joined #ocaml
<ggole>
I like having mutation available without fuss when it fits a problem
<raichoo>
Yeah, there is really a lot of discussion going on between strict vs. non-strict. I like both. :)
hausdorff has quit [Ping timeout: 272 seconds]
<emias>
Me too.
<ggole>
Yeah, OCaml has some support for laziness but it isn't really leaned on
<flux>
I think it's not a small factor that the time it takes to ocamlc/ocamlopt is usually imperceptible, quite the opposite with ghc
<raichoo>
I know, I could help but skimming some resources. Learning OCaml is still on my list, I just never really had enough motivation to really dive into it.
<flux>
(well, unless it has sped up recently)
<flux>
raichoo, well, nowadays things are even nicer than they used to be ;-): installing stuff is (usually) a breeze with opam, and if you're into emacs/vi, merlin gives great type information and locating value definitions.
<raichoo>
I'm pretty excited that both languages seem to pick up a lot of momentum recently. I'm pretty much sold to Haskell at the moment but having OCaml in my toolbox as well is pretty tempting ^^
huza has joined #ocaml
oriba has joined #ocaml
siddharthv is now known as siddharthv_away
oriba has quit [Client Quit]
dzhulk has joined #ocaml
dsheets has quit [Ping timeout: 240 seconds]
oscar_toro has joined #ocaml
<reynir>
raichoo: ":" for types and "::" for lists ;)
<reynir>
also, hi ^^
bytbox has joined #ocaml
darkf_ has joined #ocaml
<raichoo>
hey reynir ^^
darkf has quit [Ping timeout: 265 seconds]
gdsfh has joined #ocaml
araujo has joined #ocaml
araujo has joined #ocaml
bytbox has quit [Remote host closed the connection]
darkf_ is now known as darkf
hausdorff has joined #ocaml
arj has joined #ocaml
<gdsfh>
hello. If any of lwt developers are here, please tell me will you accept trivial patch to Lwt_condition that adds "waiters_exist : 'a t -> bool", or not?
<gdsfh>
I need to know it to choose what should I do: fork + patch + PR, or implement workaround (like record with 'a Lwt_condition.t and "mutable nwaiters : int" and incr/decr on Lwt_condition.wait enter/exit).
hausdorff has quit [Ping timeout: 255 seconds]
<mfp>
gdsfh: I'll forward that to #ocsigen because I believe several ppl there have commit rights
<gdsfh>
mfp: thanks.
<mfp>
gdsfh: anyway, if you're using OPAM (and you really should), nothing stops you from patching and publishing your custom repos somewhere. The PITA that is rebuilding all reverse deps is automated, so all you'd have to do if the PR were not accepted quickly is merge against origin/master every once in a while.
<gdsfh>
mfp: yes, I can patch lwt and use custom version, but I prefer to not do it: 1. I'll need to update my fork manually, while opam updates lwt automatically, 2. I'll need to rebase my patch. Workaround with condvar + nwaiters is much easier in the long term.
<gdsfh>
(I'm about case when my PR isn't accepted, of course.)
<mfp>
indeed, managing a custom branch for such a trivial feature is not worth it in the long-term, but I'd be surprised if such a PR were not accepted
<flux>
which (lwt) reminds me, any news from the multicore folk?-o
serge has quit [Remote host closed the connection]
serge has joined #ocaml
<mfp>
flux: last I heard (from the talk video) was they had it working on bytecode and were making progress wrt. native code
<flux>
I guess native code is required for people to take it seriously.
hugomg has joined #ocaml
huza has quit [Quit: WeeChat 0.3.8]
<flux>
it'll be interesting to see how much code breaks with it :), not to mention benchmark results
serge has quit [Ping timeout: 260 seconds]
<mfp>
they had good gains on a IIRC 64-core box running bytecode fib :-P
<flux>
ah yes, my fib-running-needs should then be perfectly addressed
<hugomg>
quick question: I want to build a list of things by appending elements to its tail. Do I use prepends on a regular list and reverse it at the end of the algorithm or is there a more direct data structure in the standard library / Core.Std that I can use? Its ok if its mutable, being purely functional is not a requirement in my case.
<acieroid>
hugomg: prepending + reversing is the common idiom; I don't think there is something else in the stdlib (don't know about Core.Std though)
hausdorff has quit [Ping timeout: 255 seconds]
<companion_cube>
the simplest way is prepending
<companion_cube>
what do you want to use the list for, afterwards?
<hugomg>
basically, I print it to stdout. I need to keep a list though because there are separate lists for the header and the file body and they need to be printed in the right order.
<ggole>
DynArray, or whatever it is called
<flux>
I think prepend+reverse is the most common solution
<flux>
I guess a tree or a DynArray as ggole mentioned would be efficient alternatives
hsuh has quit [Ping timeout: 250 seconds]
<hugomg>
thanks then. as long as there isn't something "obviously better" I'm convinced that the idiomatic prepend+reverse is the way to go :)
hsuh has joined #ocaml
* ggole
mumbles something about tail recursion modulo cons
<gdsfh>
hugomg: Queue
bezirg has quit [Remote host closed the connection]
bezirg has joined #ocaml
eizodo has joined #ocaml
bezirg has quit [Client Quit]
bezirg has joined #ocaml
dsheets has joined #ocaml
<hugomg>
gdsfh: how didnt I think of that, hahaha
<gdsfh>
gdsfh: or, if you want to just print, you can use two Buffer.t
<gdsfh>
or even one: store "what to print second" in it, and just output "what to print first" to stdout.
darkf has quit [Quit: Leaving]
r0ok has quit [Quit: leaving]
BitPuffin has joined #ocaml
bezirg has quit [Ping timeout: 245 seconds]
Hannibal_Smith has joined #ocaml
jbalnit has left #ocaml [#ocaml]
jbalnit has joined #ocaml
<Drup>
gdsfh: if the feature is not easily accessible otherwise, I'm pretty sure the patch would be accepted
<Drup>
(but even if I have commit rights, I'm not an lwt maintainer :p)
hsuh has quit [Ping timeout: 272 seconds]
<nicoo>
hugomg: Also, for many of your list-like-stream needs, Sequence is nice
shinnya has joined #ocaml
hsuh has joined #ocaml
SethTIsue has joined #ocaml
<hugomg>
I thought Sequence was about abstracting over iterables though?
hsuh has quit [Ping timeout: 240 seconds]
<companion_cube>
it's also ok for some operations, like flat_map
<flux>
hmm, so if you had a recursive function of the form let foo = function 0 -> [] | _ -> 42::foo (n - 1), wouldn't it be possible to rewrite it into tail recursion by with let pseudo_foo result = function 0 -> result.fst <- nil | _ -> result.fst <- 42; foo' result.snd (n - 1) or something
Thooms has joined #ocaml
<Pepe_>
Drup: ! I finally got Core to build :)
<Pepe_>
(was a bit busy until now)
<companion_cube>
let rec foo i k = if i>0 then (k 42; foo (i-1) k);; Sequence.iter (printf "value: %d\n") (f 100);;
<companion_cube>
:>
<Pepe_>
I did it from a fresh switch install, and pinned it to the git repo
<bernardo1pc>
companion_cube: foo 100, right ;-)
<companion_cube>
oops
bezirg has joined #ocaml
hsuh has joined #ocaml
hugomg has quit [Read error: Connection reset by peer]
samrat has quit [Quit: Computer has gone to sleep.]
hausdorff has joined #ocaml
bytbox has joined #ocaml
arj has quit [Quit: Leaving.]
hausdorff has quit [Ping timeout: 272 seconds]
samrat has joined #ocaml
rand000 has joined #ocaml
zpe has joined #ocaml
<artagnon>
whitequark: Perfect; thanks :)
bezirg has quit [Ping timeout: 250 seconds]
<artagnon>
I don't have to touch my Makefile if I use OCAMLPATH.
<artagnon>
However, you haven't told me how to proceed with those two ctype wrappers.
<whitequark>
oh, right
<whitequark>
I'll get back to IRC in ten minutes or so and I will
bezirg has joined #ocaml
<artagnon>
Sure.
mcclurmc has joined #ocaml
serge has joined #ocaml
fraggle-boate has quit [Quit: Quitte]
arj has joined #ocaml
bytbox has quit [Remote host closed the connection]
samrat has quit [Quit: Computer has gone to sleep.]
bytbox has joined #ocaml
<whitequark>
back.
fraggle-boate has joined #ocaml
dsheets has quit [Ping timeout: 244 seconds]
<Drup>
whitequark: I took another look at the issue. Current situation is that both int and FP functions to get the value out of a Constant asserts if it don't fit *BUT* we have a way to know beforehand if it cannot fit for int
<Drup>
and we don't have one for FP
<artagnon>
whitequark: Quickly tell me what function type is necessary.
<whitequark>
I think similar machinery should be available for floats
<whitequark>
artagnon: ugh
<Drup>
I didn't saw anything except the looseInfo boolean from the conversion function
<whitequark>
don't put any ctypes code into llvm itself
<whitequark>
although
<whitequark>
hm
<artagnon>
Oh.
<whitequark>
well, actually, it might not be a bad idea after all.
<Drup>
whitequark: since we are on the not-bad-idea-after-all
freling has quit [Read error: Connection reset by peer]
freling has joined #ocaml
freling has quit [Client Quit]
<Drup>
do you think there is a non-insane way (also know as "go through strings") to plug Zarith for intergers and FP that are too big ?
freling has joined #ocaml
<artagnon>
Okay, why is that segment syntax failing, and what do I from_voidp to?
<artagnon>
(I don't think you need Obj.magic
<artagnon>
from_voidp fits the bill, I think.
<Drup>
artagnon: remove the "in"
<whitequark>
I don't know why it's failing, you didn't include the error
<whitequark>
I'm not telepathic.
<Drup>
I am. :D
<whitequark>
if something is broken, show me the fucking error
<artagnon>
Drup: Oops, but that doesn't fix it.
<artagnon>
Okay, one sec.
<Drup>
arg !
samrat has joined #ocaml
<Drup>
not telephatic after all, fu.
<artagnon>
Oh, it does.
<artagnon>
Different error now.
<Drup>
\O/
badkins has quit [Remote host closed the connection]
<Drup>
whitequark: I have an idea to make the binding typesafe, btw
<artagnon>
I opam install'ed ctypes but I have to modify the Makefile to pick it up I guess.
bytbox has quit [Remote host closed the connection]
<artagnon>
Why doesn't Makefile.ocaml use ocamlfind to simplify things?
<whitequark>
it's very old.
dzhulk has quit [Quit: Leaving.]
Thooms has quit [Quit: WeeChat 1.0.1]
eizodo has quit [Quit: Page closed]
<whitequark>
Drup: ok, let me explain how I see that API.
<whitequark>
oh
<whitequark>
"int64_of_const c returns the int64 value of the c constant integer. None is returned if this is not an integer constant, or bitwidth exceeds 64"
<whitequark>
ok, so, float_of_const c should definitely not assert on huge floats
<whitequark>
Drup: yes, I agree, expose the loseInfo flag.
<Drup>
/me likes to agree with the maintainer on how to implement things.
dzhulk has joined #ocaml
dsheets has joined #ocaml
seanmcl has joined #ocaml
hugomg has joined #ocaml
freling has left #ocaml [#ocaml]
<artagnon>
The Makefile is a colossal mess.
<artagnon>
I can't understand where half the variables come from.
<whitequark>
from LLVM's own makefiles. it's not separate.
<Drup>
oh and btw, whitequark, it's not a question of huge float, it's a question of representable floats.
<whitequark>
Drup: in principle, yes
<whitequark>
in practice, LLVM doesn't allow you to enter arbitrary floats
sinelaw has quit [Ping timeout: 255 seconds]
<whitequark>
(you can't represent them in the IR)
<Drup>
what do you mean ?
<artagnon>
Plane landing; I'll get some sleep and return in a while.
<whitequark>
so you only have fp128, x86_fp80 and ppc_fp128 as the floats that can't be converted to double
<whitequark>
which are incidentally all bigger than double.
<Drup>
oh, you can't have custom floating point semantics ?
<Drup>
the api seems to imply you can
slash^ has joined #ocaml
ivan\ has joined #ocaml
<gdsfh>
Drup: my patch can be non acceptable, because in C there is no way to know whether there are waiters for given pthread_cond_t or not. It's a bit philosophical question, that's why I'm asking here. Anyway I'll follow both paths: workaround + "todo: check for PR ... and remove this code" + PR itself.
larhat has quit [Quit: Leaving.]
gdsfh1 has joined #ocaml
gdsfh has quit [Ping timeout: 265 seconds]
hausdorff has joined #ocaml
badkins has joined #ocaml
hausdorff has quit [Ping timeout: 258 seconds]
raichoo has quit [Ping timeout: 265 seconds]
olauzon has joined #ocaml
badkins has quit [Ping timeout: 250 seconds]
badkins has joined #ocaml
dsheets has quit [Ping timeout: 258 seconds]
dsheets has joined #ocaml
morphles has joined #ocaml
<whitequark>
craaap
<whitequark>
Drup: no, you can't
<whitequark>
the lowest levels of API (APFloat & friends) allow that
<whitequark>
but higher ones don't really give you the freedom you need for that
<Drup>
ok
<whitequark>
the "craaap" remark referred to the following
<whitequark>
Llvm_executionengine is useless without ctypes.
<whitequark>
but I can't put a dependency on ctypes into llvm.
<whitequark>
it's not even in debian yet at all.
<Drup>
that's sad.
bezirg has quit [Ping timeout: 244 seconds]
badkins has quit [Ping timeout: 244 seconds]
hugomg has quit [Ping timeout: 256 seconds]
jwatzman|work has joined #ocaml
badkins has joined #ocaml
hausdorff has joined #ocaml
zz_adgtl is now known as adgtl
<whitequark>
siiiigh
<whitequark>
oh, ctypes is actually in debian
<whitequark>
ancient 0.2.3 in jessie
hugomg has joined #ocaml
cago has left #ocaml [#ocaml]
jbalnit has quit [Ping timeout: 265 seconds]
shinnya has quit [Ping timeout: 265 seconds]
jbalnit has joined #ocaml
bytbox has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
nico159_ has joined #ocaml
Hannibal_Smith has quit [Ping timeout: 265 seconds]
nico159_ has quit [Client Quit]
Hannibal_Smith has joined #ocaml
zpe has quit [Remote host closed the connection]
dotfelix has joined #ocaml
dotfelixb has joined #ocaml
serge has quit [Remote host closed the connection]
dotfelix has quit [Read error: Connection reset by peer]
serge has joined #ocaml
raichoo has joined #ocaml
serge has quit [Ping timeout: 258 seconds]
ygrek has joined #ocaml
dotfelixb has quit [Quit: Leaving]
arj has quit [Quit: Leaving.]
zpe has joined #ocaml
ygrek has quit [Remote host closed the connection]
pyon has quit [Ping timeout: 272 seconds]
ygrek has joined #ocaml
jzelinskie_ is now known as jzelinskie
bytbox has quit [Remote host closed the connection]
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
marynate has quit [Quit: Leaving]
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
jwatzman|work has joined #ocaml
adgtl is now known as zz_adgtl
zz_adgtl is now known as adgtl
adgtl is now known as anildigital
anildigital is now known as zz_anildigital
ikaros has joined #ocaml
hausdorff has quit [Remote host closed the connection]
hausdorff has joined #ocaml
* reynir
waits for 4.02.01 to hit the arch repos
<Drup>
reynir: don't wait, use opam! :]
kakadu has quit [Quit: Page closed]
<reynir>
it's easier to "migrate" the opam packages by waiting for the arch repos ^^
MercurialAlchemi has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
hausdorf_ has joined #ocaml
hausdorff has quit [Ping timeout: 258 seconds]
q66[lap] has quit [Changing host]
q66[lap] has joined #ocaml
jpdeplaix` is now known as jpdeplaix
Thooms has joined #ocaml
hausdorf_ has quit [Remote host closed the connection]
hausdorff has joined #ocaml
paddymahoney has joined #ocaml
hausdorff has quit [Ping timeout: 272 seconds]
dzhulk1 has joined #ocaml
samrat has quit [Ping timeout: 244 seconds]
ljs has joined #ocaml
dzhulk has quit [Ping timeout: 265 seconds]
ocp has quit [Ping timeout: 265 seconds]
_obad_ has quit [Ping timeout: 260 seconds]
samrat has joined #ocaml
srcerer has quit [Quit: ChatZilla 0.9.91 [Firefox 32.0.3/20140923175406]]
dsheets has quit [Ping timeout: 240 seconds]
serge has joined #ocaml
srcerer has joined #ocaml
serge has quit [Ping timeout: 250 seconds]
badon has quit [Ping timeout: 256 seconds]
slash^ has quit [Read error: Connection reset by peer]
claudiuc has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
claudiuc has quit [Remote host closed the connection]
claudiuc has joined #ocaml
_andre has quit [Quit: leaving]
claudiuc has quit [Read error: Connection reset by peer]
claudiuc has joined #ocaml
ygrek has quit [Remote host closed the connection]
samrat has quit [Quit: Computer has gone to sleep.]
thmslld has joined #ocaml
larhat has joined #ocaml
kakadu has joined #ocaml
WraithM has joined #ocaml
pyon has joined #ocaml
artagnon has quit [Ping timeout: 272 seconds]
strmpnk has quit [Ping timeout: 272 seconds]
nox has quit [Ping timeout: 272 seconds]
artagnon has joined #ocaml
ggherdov has quit [Ping timeout: 244 seconds]
dch has quit [Ping timeout: 272 seconds]
lopex has quit [Ping timeout: 272 seconds]
strmpnk has joined #ocaml
jcloud has quit [Ping timeout: 272 seconds]
dch has joined #ocaml
nox has joined #ocaml
jcloud has joined #ocaml
lopex has joined #ocaml
sinelaw has joined #ocaml
<sinelaw>
can ocaml infer anonymous record types?
<sinelaw>
I know this won't compile: let x = { v = [] } ;; but is there something like that code that will?
<companion_cube>
record types must be declared
<sinelaw>
ok
<ggole>
object types can be anonymous
<ggole>
let o = object method v = [] end
manud has joined #ocaml
ggherdov_ has joined #ocaml
SethTIsue_ has joined #ocaml
hausdorff has joined #ocaml
SethTIsue has quit [Ping timeout: 244 seconds]
SethTIsue_ is now known as SethTIsue
SethTIsue has quit [Client Quit]
Hannibal_Smith has quit [Quit: Sto andando via]
ggole has quit []
badkins has quit [Ping timeout: 272 seconds]
lordkryss has joined #ocaml
SethTIsue has joined #ocaml
ygrek has joined #ocaml
emmanueloga has quit [Ping timeout: 250 seconds]
WraithM has quit [Ping timeout: 265 seconds]
SethTIsue has quit [Ping timeout: 244 seconds]
SethTIsue has joined #ocaml
OnkV has quit [Ping timeout: 245 seconds]
Haudegen has joined #ocaml
emmanueloga has joined #ocaml
Haudegen is now known as Guest39355
Guest67269 has quit [Ping timeout: 260 seconds]
claudiuc has quit [Remote host closed the connection]
Guest67269 has joined #ocaml
claudiuc has joined #ocaml
SethTIsue has quit [Ping timeout: 244 seconds]
SethTIsue has joined #ocaml
<whitequark>
they're not really equivalent though
paddymahoney has quit [Ping timeout: 250 seconds]
<whitequark>
I would really hate to see some code using objects in place of records in order to avoid pre-declaring them
Simn has quit [Ping timeout: 260 seconds]
Simn has joined #ocaml
Sim_n has joined #ocaml
axiles has quit [Remote host closed the connection]
bezirg has joined #ocaml
Simn has quit [Ping timeout: 260 seconds]
morphles has quit [Ping timeout: 245 seconds]
mstr_ has joined #ocaml
paddymahoney has joined #ocaml
mstr_ is now known as mstrhh
serge has joined #ocaml
ljs has quit [Quit: Be back later ...]
<thmslld>
Hi folks, I'm new to OCaml and was wondering if anyone knows of an easy way to get version 4.02.1 on Ubuntu 14.10?
<thmslld>
Thanks whitequark, I've now got the latest version. What I've been thinking of doing after I finished up OCaml from the very beginning I will try my hand at writing a text adventure to improve my skills.
<thmslld>
The only major problem I foresee is saving the progress any advice there?
<whitequark>
thmslld: you could serialize it into JSON and save into a file
<thmslld>
Thanks I think I may just follow your advice. Hope you don't mind beginner questions as there may be a lot more to come. :)
<whitequark>
sure, that's what this channel is for
<companion_cube>
this channel is also to ask whitequark to implement things
<companion_cube>
:>
oscar_toro has quit [Read error: Connection reset by peer]
<whitequark>
I have this feeling I'm going to spend this week refactoring LLVM because ugh
<whitequark>
LLVM bindings
mstrhh has quit [Quit: mstrhh]
ygrek has quit [Ping timeout: 265 seconds]
dsheets has joined #ocaml
ljs has joined #ocaml
SethTIsue has quit [Quit: SethTIsue]
oscar_toro has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
avsm has joined #ocaml
hooplahoops has joined #ocaml
WraithM has joined #ocaml
<hooplahoops>
Hi, I have a module 'equal.ml' with a 'module type Equal = sig ... end', and I have a module 'myfunctor.ml' containing something like 'module Foo = Functor (Equal : Equal) -> struct ... end'
<hooplahoops>
I first compile Equal with ocamlc, and then I compile myfunctor, but I then always get the following: Error: Unbound module type Equal
<hooplahoops>
What am I doing wrong?
<whitequark>
Equal.Equal
<hooplahoops>
ooh
<hooplahoops>
whitequark: yeah that does it, thanks!
<hooplahoops>
Why do I get such a stupid error message, it sounds like it had trouble finding the module as opposed to a type error
<whitequark>
unbound module type Equal
<whitequark>
oh, I see your point
Nahra has joined #ocaml
<hooplahoops>
I now have another issue. If I have equal.ml and equal.mli, where equal.mli has 'module type Equal = sig ... end', and I have 'module Equal = struct ... end', I get: The field `Equal' is required but not provided
<hooplahoops>
Why is 'Equal' not provided by the 'module Equal = struct ... end'?
<whitequark>
module types are similar to regular types
<whitequark>
so you'd have "type a" in the .mli and "type a = int" in the .ml
<whitequark>
in other words you need to provide a module type in implementation for every module type in the interface
<whitequark>
hooplahoops: see, "module type" is the module language equivalent of "type", and "module" is the equivalent of "val" or "let"
<whitequark>
so essentially you wrote "type a" in .mli and "let a = whatever" in .ml
WraithM has quit [Ping timeout: 256 seconds]
<whitequark>
you need to put the module type into .ml exactly as you have it in .mli
<hooplahoops>
whitequark: oh, so I should say 'module EQUAL : EQUAL = struct ... end' ?
<whitequark>
no.
jwatzman|work has joined #ocaml
<whitequark>
you need to put the module type into .ml exactly as you have it in .mli.
<whitequark>
module type EQUAL = ... in both .ml and .mli.
<hooplahoops>
Oh, ok
<whitequark>
like you would do for "type a".
<hooplahoops>
Is there no say to avoid that?
<whitequark>
no
<whitequark>
well
<hooplahoops>
doesn't that mean we repeat interfaces all the time?
<whitequark>
yes, that's what generally happens with types in OCaml.
<whitequark>
you duplicate it in the interface and implementation
<hooplahoops>
Hmm, ok. Is that more useful than not repeating it in some sense?
<whitequark>
the reason being that you might want to constrain the type you export, but have full access to its internals in the implementation.
<whitequark>
yep!
<whitequark>
like you could have "type a = int" in implementation but just "type a" (abstract) in the interface.
<hooplahoops>
I thought the purpose of the .mli was to do the constraining automatically?
<hooplahoops>
I was guessing I'd always have access to the full implementation (type t = int) in the 'struct', but any module using it would be constrained by the equal.mli
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<hooplahoops>
So if I repeat the signature, am I getting something beyond the above?
<whitequark>
you explicitly say whether you want to expose the details of the type or not in the .mli
paddymahoney has quit [Ping timeout: 258 seconds]
WraithM has joined #ocaml
<whitequark>
you might want to make the type abstract in the interface, or you might not
<whitequark>
there is no way for the compiler to guess
<hooplahoops>
Yes, I understand the abstract types in the .mli, so I understand repeating the 'type t = int' part
<hooplahoops>
But you seem to be saying, "copy the entire 'module type Equal = sig ... end' into 'equal.ml', correct?
<whitequark>
well, you can have an abstract module type just as well
<hooplahoops>
That allows me to not repeat it, or it makes the entire implementation abstract?
<whitequark>
makes it abstract
dzhulk1 has quit [Quit: Leaving.]
<hooplahoops>
So no one can call any function?
<hooplahoops>
Or does it pertain only to all the types?
<whitequark>
it'd be entirely abstract
<whitequark>
I'm not saying this is useful in your case, I'm explaining the rationale for duplication
<whitequark>
duplication exists to give you a chance to make the interface more conservative
<hooplahoops>
It indeed seems to compile with the duplication
<hooplahoops>
But if I wanted to change the interface, I'd have to change the implementation, the .mli and the module type in the module?
<hooplahoops>
In that case, could I just omit the .mli entirely?
<whitequark>
in principle, yes, but that's bad practice.
<whitequark>
so you'd have just "module type EQUAL = [%import: (module Equal.EQUAL)];" in the implementation
dsheets has quit [Ping timeout: 265 seconds]
<hooplahoops>
I'm still a little hazy on the details. If I have a module Equal having two signatures, and a module A that uses Equal, which signature does it refer to?
<whitequark>
when you refer to a signature, you have to specify the full path.
<whitequark>
so in your case, that would be Equal.EQUAL.
<whitequark>
so, there can be no ambiguity.
<hooplahoops>
I guess what I mean is, if I use 'open Equal', do I get the stuff listed in the module type from equal.ml, or the stuff from equal.mli?
jwatzman|work has quit [Quit: jwatzman|work]
<whitequark>
oh. externally, you can only see that what is defined in the .mli
<hooplahoops>
Ah, I see, ok, thanks!
jwatzman|work has joined #ocaml
<hooplahoops>
Can I add more contents to the module type in equal.ml than in equal.mli, or vice versa?
zpe has quit [Remote host closed the connection]
<whitequark>
hm
<whitequark>
let me verify
<hooplahoops>
It seems to complain here ;)
zpe has joined #ocaml
<hooplahoops>
For either case
<hooplahoops>
Which suggests the signatures have to be identical?
<whitequark>
yes, they have to be identical.
<whitequark>
but you can make it abstract in the .mli.
<whitequark>
that's ... not very useful, I suppose.
<hooplahoops>
So you were saying that you can be more conservative with the module type in the .ml file, how can I do that if the signatures have ot be identical?
<whitequark>
well, I was wrong, sorry
WraithM has quit [Ping timeout: 244 seconds]
raichoo has quit [Ping timeout: 265 seconds]
<hooplahoops>
Ah ok, no worries
avsm has quit [Ping timeout: 260 seconds]
zpe has quit [Ping timeout: 255 seconds]
manud has joined #ocaml
ustunozgur has joined #ocaml
<whitequark>
hm, what to do
<whitequark>
I know, let's break utop
<companion_cube>
whitequark: you should add something about "how to compile" in your ppx_dreiving readme
<whitequark>
companion_cube: huh?
<whitequark>
For every plugin, you need to require the corresponding package, e.g. ppx_deriving.show for the show deriver. The package ppx_deriving.std depends on every standard deriver.
<companion_cube>
I mean to compile a binary (which option to give to oasis/ocamlbuild)
<whitequark>
I don't understand
<companion_cube>
I mean, how to tell ocamlbuild which ppx to use. -package surely isn't enough?
<whitequark>
it is
<companion_cube>
oh
<companion_cube>
impressive
<whitequark>
I spent two months screwing with ocamlfind and now you give me this :/
<companion_cube>
well, it seemed too easy :p
<hooplahoops>
I think the idea is that you typically don't write 'module Foo = struct ... end', instead you just write your definitions directly, and then write a '.mli'?
<hooplahoops>
then you don't need to repeat the whole signature
<hooplahoops>
so the module thing is useful in case you want multiple modules in one file, perhaps?
serge has joined #ocaml
<whitequark>
huh?
<companion_cube>
hooplahoops: it's useful for modules within modules, or to provide arguments to functors
<hooplahoops>
companion_cube: right, that's what I thought
<hooplahoops>
I must say the ocaml tooling feels a little retro :p
<companion_cube>
sadly, yes :/
<hooplahoops>
I just want to type 'ocaml foo.ml' and have it compile all dependencies. Almost any other language has automatic dependency resolution
<whitequark>
OCaml has this, of course
<companion_cube>
you can do something like ocamlbuild foo.native
<whitequark>
use ocamlbuild.
<hooplahoops>
yeah, that what you get told
<hooplahoops>
It's not easy for newcomers to learn about all these tools
<whitequark>
companion_cube: oooh. I just got an idea for an OCaml buildsystem
<hooplahoops>
it also complains about hygiene etc
<whitequark>
hooplahoops: well, it complains rightly
serge has quit [Ping timeout: 264 seconds]
<hooplahoops>
whitequark: why? It can't look at timestamps?
<hooplahoops>
Or use hashes?
<whitequark>
it uses hashes
lordkryss has quit [Quit: Connection closed for inactivity]
<whitequark>
you shouldn't have any build artifacts in your source tree anyway
larhat has quit [Ping timeout: 258 seconds]
<hooplahoops>
so why doesn't it build my project, rebuilding anything that's out of date?
<whitequark>
it does
<Drup>
whitequark: what's the idea ? :D
<hooplahoops>
ok I'll do the cleaning then and see :)
<whitequark>
Drup: two things actually
<whitequark>
1) get rid of forking *entirely*
<whitequark>
2) specify the dependencies inside [%%nodes], not _tags
BitPuffin has quit [Ping timeout: 255 seconds]
<companion_cube>
ppx_assemblage
<whitequark>
so it'd go like
jwatzman|work has quit [Read error: Connection reset by peer]