<thelema>
beginner: if there's no toplevel, there's no types to use for printing values automatically
arubin has quit [Quit: arubin]
yroeht has quit [Ping timeout: 244 seconds]
yroeht has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
sebz has joined #ocaml
emmanuelux has quit [Ping timeout: 268 seconds]
ulfdoz has joined #ocaml
scrappy_doo_ has joined #ocaml
Drakken has quit [Ping timeout: 240 seconds]
clog has joined #ocaml
bitbckt has quit [Quit: out]
bitbckt has joined #ocaml
ankit9 has quit [Quit: Leaving]
destrius has quit [Quit: Leaving.]
ikaros has quit [Ping timeout: 252 seconds]
musically_ut has quit [Ping timeout: 240 seconds]
ocamlnoob has joined #ocaml
<ocamlnoob>
Hello. I have a file "some_module.ml". How can I create a module named "SomeModule" instead of "Some_module"?
sebz has joined #ocaml
<mfp>
ocamlnoob: name the file "someModule.ml" or "SomeModule.ml"
larhat has joined #ocaml
ikaros has joined #ocaml
Kakadu_ has joined #ocaml
<beginner>
morning
<beginner>
a question how do I specify a function argument to be a type float?
<beginner>
let increment = fun i -> i + 1.0;;
Kakadu has quit [Ping timeout: 265 seconds]
<beginner>
i:float?
<ocamlnoob>
Use "+." instead of "+"
<beginner>
ohya, gosh.. I keep making silly mistakes
<beginner>
thanks!
<adrien>
ocamlnoob: "some_module.ml" will _always_ define a module named "Some_module"
<ocamlnoob>
adrien: okay, but why do we need "module SomeModule =" declaration if we can't use it to create module with specified name?
<adrien>
no, it's not that way
<adrien>
if in file A.ml you write:
<adrien>
module B = struct
<adrien>
...
<adrien>
end
<adrien>
then you create the module A which has a module "B" inside
<adrien>
have you done Java or C# recently?
<ocamlnoob>
Erlang.
<adrien>
ok, nevermind the question then =)
<adrien>
but the file creates one module and inside the module, you can create other modules and so on
<ocamlnoob>
Thank you. I used to define module names explicitly, didn't expect nested modules.
<adrien>
=)
<ocamlnoob>
What about encapsulation? Is there any way to Not export some functions? Is there a way to list exported functions?
<adrien>
yes, you can do .mli files (they apply to the whole file and have to be compiled beforehand (producing .cmi files)) or use the "sig ... end" construct when defining a module with struct ... end
<ocamlnoob>
Thank you again. Finally I am able to use ocaml :)
<adrien>
=)
<adrien>
and if you want to list exported functions, I think you cannot do that programmaticaly but a tool like cmigrep will show what is in .cmi files (therefore giving the same information)
<beginner>
Would anyone like to explain to me how parentheses work for function arguments?
<beginner>
let sum = fun i j -> i + j;;
<beginner>
sum (1 2)
<beginner>
that will not work
<beginner>
but sum 1 2
<beginner>
works
<beginner>
are parentheses just optional or they must not be used?
<adrien>
instead of using parentheses and commas, you use spaces in ocaml
<adrien>
"f a b" is C's "f(a, b)"
<beginner>
but the book I am reading says something like this "Parentheses are required only for arguments that are not simple expressions."
<beginner>
which made me think that parentheses are optional
<beginner>
but I thought might be a good idea to have it anyway
<adrien>
I think it meant: "f (g a) b"
<adrien>
so you need them to group for precedence
<beginner>
ah, that's interesting.. thank you again =)
sepp2k has joined #ocaml
<adrien>
np
cago has quit [Quit: WeeChat 0.3.6]
avsm has quit [Quit: Leaving.]
cago has joined #ocaml
avsm has joined #ocaml
<beginner>
I am trying to understand how currying work
<beginner>
so if I understand correctly
<beginner>
let sum = (fun i -> (fun j -> i + j));;
<beginner>
if I do: sum 1
<Kakadu_>
yep
<Kakadu_>
нуз
<beginner>
the value of i is returned
<beginner>
but if I do: sum 1 2
<beginner>
it will pass the second argument to the nested function?
<beginner>
which will then return the result to be used by the toplevel function(which is 'i' in this case)
<beginner>
I am right?
<beginner>
am I right?
<Kakadu_>
I don't understand what you mean in `the value of i is returned` ...
<ocamlnoob>
s/currying/partial application/g
<ocamlnoob>
sum 1 returns (fun j -> 1 + j)
<beginner>
ermm, I think it's 'i' instead of '1'
<ocamlnoob>
sum 1 applies 1 to sum, so 'i' is replaced with '1'
<beginner>
that's what confused me, how it replaced that with 1 instead of complaining i is unbound
musically_ut has joined #ocaml
<ocamlnoob>
fun i -> (fun j -> i + j) returns (fun j -> i + j) with i replaced with applied argument, nothing confusing I see.
<beginner>
Iok
<beginner>
*ok
<beginner>
but how about the value of the variable j?
<beginner>
if it's 1 + j (after replacing i with 1)
<beginner>
what is 'j' in this case?
<ocamlnoob>
"fun j -> 1 + j" is the unary function, j is argument.
ftrvxmtrx has quit [Quit: This computer has gone to sleep]
<beginner>
oh right, I think I confused this anonymous function
<beginner>
with a named function l
<beginner>
been thinking j is the name of the function
<beginner>
*mixed up
king-of-spain has quit [Ping timeout: 255 seconds]
avsm has quit [Quit: Leaving.]
king-of-spain has joined #ocaml
avsm has joined #ocaml
ygrek has joined #ocaml
ocamlnoob has quit [Quit: Page closed]
avsm has quit [Quit: Leaving.]
EmmanuelOga has quit [Ping timeout: 244 seconds]
jamii has joined #ocaml
EmmanuelOga has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
emmanuelux has joined #ocaml
avsm has joined #ocaml
bwright has quit [Ping timeout: 240 seconds]
bwright has joined #ocaml
ygrek has quit [Ping timeout: 248 seconds]
bwright has quit [*.net *.split]
caligula_ has quit [*.net *.split]
bwright has joined #ocaml
caligula_ has joined #ocaml
bwright has quit [Max SendQ exceeded]
bwright has joined #ocaml
Kakadu_ has quit [Quit: Page closed]
mcclurmc has quit [Excess Flood]
mcclurmc has joined #ocaml
EmmanuelOga has quit [Ping timeout: 244 seconds]
The_third_bug has joined #ocaml
The_third_man has quit [Disconnected by services]
The_third_bug has quit [Read error: Connection reset by peer]
The_third_man has joined #ocaml
EmmanuelOga has joined #ocaml
Kakadu has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
oriba has joined #ocaml
reynir has joined #ocaml
roha has joined #ocaml
ftrvxmtrx_ has quit [Quit: Leaving]
<roha>
newbie question: does somebody know how to make OcaIDE's autocomplete work with batteries? List.<ctrl-space> shows the possible standard library functions instead of the ones from Batteries.
<roha>
Or: What's the closest thing you can get for Ocaml like VS2010 for F#?
<roha>
Ocaml + Batteries that is
ikaros has joined #ocaml
<thelema>
roha: what do you get with "BatList.<ctrl-space>"?
<thelema>
roha: i.e. does ocaide work at all with non-stdlib libraries?
Cyanure has quit [Remote host closed the connection]
<thelema>
Batteries is just a normal library, very very little black magic
<roha>
well it compiles fine with them if I include a "-package batteries" at the compiler command
<roha>
BatList.<ctrlspace> also doesn't work
<thelema>
yes, that's important for findlib to tell the compiler about batteries
<roha>
do I have to include the doc for batteries somehow?
<thelema>
your question isn't "how to make ocaide work with batteries", your question is "how to make ocaide's autocomplete work with any external library"
<thelema>
I don't know the answer to either.
<thelema>
I imagine a little browsing in ocaide's docs will find the answer
<roha>
hmm, true.
<thelema>
"OCamldoc-compatible documentation is parsed correctly and displayed whenever possible"
<thelema>
yes, you'll probably have to do 'make doc' in batteries
<roha>
I suppose ill search around a little longer.
<roha>
like cd into the batteries source dir?
<roha>
and execute make doc?
<thelema>
although I don't know how to point it at the batteries documentation
<thelema>
roha: yes
<roha>
there is a option for "ocamldoc" under the "paths" menu in ocaide, it currently points to: /opt/godi/bin/ocamldoc.opt
<thelema>
roha: nope, that's just the ocamldoc executable
<roha>
there is a doc folder in the batteries folder, but its just html files
<thelema>
yes, that's what 'make doc' creates. I imagine that's what ocaide will parse
<roha>
if i autocomplete on List. it shows me the popup box with all the functions from List. Underneath theres written: /usr/lib/ocaml/list.mli
<roha>
do i maybe have to get all the mli files from batteries into that folder?
<thelema>
oh, it parses the .mli files to extract ocamldoc, not the html files.
<thelema>
I guess that makes sense.
<thelema>
I wouldn't copy all the mli files there
<thelema>
it ought to have some search path for mli files somewhere, no?
<roha>
theres also no batteries folder in /usr/lib/ocaml/
<roha>
sec
<thelema>
yes, batteries is (most likely) in /usr/lib/ocaml/site-lib/batteries
<roha>
hmm it seems there is no batteries folder anywhere in /usr/lib/ocaml
<thelema>
/usr/local/lib/ocaml/site-lib/?
<thelema>
`ocamlfind printconf`
<roha>
/usr/local/lib/ocaml/3.12.0/batteries/ there it is
<roha>
search path is: /usr/local/lib/ocaml/3.12.0 /usr/lib/ocaml /usr/lib/ocaml/METAS
<thelema>
that's where batteries is. Now how to tell ocaide about its mli files
<roha>
in the paths menu in ocaide, theres a field "Ocaml lib path", which is set to "/usr/lib/ocaml"
<thelema>
yup, that shouldn't be changed.
<roha>
do you think it just searches that directory for the mli files? and not the one where batteries is?
<thelema>
try copying all the batteries .mli files to /usr/lib/ocaml/batteries
<roha>
k sec
<thelema>
maybe it only searches subdirs of the lib path
<thelema>
I hope it searches subdirs - it'd be a horrible mess to put all the batteries .mli files straight into /usr/lib/ocaml
<thelema>
maybe a symlink from /usr/lib/ocaml/site-lib to /usr/local/lib/ocaml/3.12.0
larhat has quit [Quit: Leaving.]
<roha>
hmm the copying didn't seem to do the trick, ill try the symlink now
<thelema>
I assume you're restarting ocaide or something to make sure it finds the new files?
<roha>
yes, just trying now, after creating the symlink
<roha>
hmm still nothing, i try to put one mli file from batteries directly in the folder for testing purposes
spearalot has joined #ocaml
<thelema>
yes, that's my next suggestion, to see if we're triggering its autocomplete rebuilder
cago has quit [Quit: Leaving]
ttamttam has quit [Remote host closed the connection]
<roha>
yea it now recognizes BatList with all its functions
<roha>
I can write List.last for example, altough last isn't in the std library as far as i know, without having ocaide complain about it
<roha>
but List.<autocomplete> still shows only functions from std
<roha>
But BatList gets recognized. Very nice
<thelema>
yes, when you do "open batteries" (_uni), a set of modules are brought into the current namespace that replace List, Array, etc.
<thelema>
these modules are the composition of stdlib List and BatList
<thelema>
I guess that the best solution so far is to just copy all the batFoo.mli files to /usr/lib/ocaml
<thelema>
That's not a very nice solution, but it'll get you one step along the way.
<thelema>
It won't quite get you autocomplete where List.<C-spc> fills in batteries functions
<thelema>
because what you really want to autocomplete is Batteries.List.*, the merge of BatList and stdlib List
<roha>
yeah. But at least this will be much more pleasant to work with!
<roha>
Thanks so much
<thelema>
you're welcome.
<thelema>
if you find the real solution, try to put it on the internet somewhere findable
<reynir>
hi thelema
<roha>
I'll do that!
<thelema>
hi reynir
<reynir>
you helped me with some integer truncation :)
<reynir>
thanks
<thelema>
reynir: you're welcome. I'm glad things are working out
sgnb has joined #ocaml
<reynir>
Me and two friends spent some time trying to figure out how to do it
thomasga has quit [Quit: Leaving.]
<beginner>
so far I am only on the 2nd chapters
<beginner>
*chapter
<beginner>
but gosh, algorithms in Ocaml are much easier to implement!!
<beginner>
soo much better than in python
<beginner>
more natural
<roha>
2nd chapter where?
<roha>
which book?
<beginner>
actually 3rd chapter not 2nd lol
<beginner>
Introduction to Objective Caml
<beginner>
but I have been cross referencing with other books and articles online
<roha>
yea, i'm reading that one as well atm.
<beginner>
moving slowly and trying to understand things really well and letting my creativity flow
<roha>
me too. i was also looking at f#, but .net puts me off somehow
<roha>
even though i like the fact that the syntax is almost 1:1 ocaml. so learning ocaml seems to be great for both languages.
<beginner>
but I really hope they have more resources on ocaml
<beginner>
I wonder why there is not data struc book on ocaml
<beginner>
*no
<beginner>
I saw some good books using Haskell like
<beginner>
The Haskell Road to Logic Math
<roha>
yea and the haskell school of expression is supposed to be great as well
<thelema>
a lot of those kind of books for ocaml are in french
<roha>
but somehow haskell seems to be a little too much focused on purity for my taste
<roha>
yea, noticed that as well.
oriba has quit [Quit: oriba]
avsm has quit [Ping timeout: 255 seconds]
<reynir>
I was taught french in school
<reynir>
I wonder if I would be able to understand such a book
<reynir>
most likely not :)
ftrvxmtrx has joined #ocaml
<thelema>
reynir: I'm in the same situation, and the french textbooks weren't useful for me.
<roha>
did they invent new french words for general english computer science terms?
<adrien>
patch to the compiler, right? I'd like to have an easy way to integrate that to godi
<adrien>
which means a corresponding SVN
<hcarty>
adrien: Me too. It seems like a potentially nice holdover until namespaces are implemented.
<hcarty>
adrien: Nope, this one isn't a patch. The packed functors part is available as a patch.
<adrien>
wasn't there a namespace patch somewhere?
<hcarty>
But as I understand from the page, ocp-pack takes a list of source files and builds a big .ml out of them
<hcarty>
adrien: There is a branch in SVN and on github
<adrien>
svn on inria.fr?
<hcarty>
Incomplete, but getting closer
<hcarty>
Yes
<adrien>
that would make it much easier to try for me
<adrien>
but then the main issue is to make some code that depends on the patch
<adrien>
good luck redistributing it =/
<hcarty>
Yes, I don't think I'm going to try ocamlpro's additions than ocp-pack (if I go that far) until they are supported/integrated somewhere
<adrien>
that's my main issue because I could benefit from it right now I think
<hcarty>
Namespace support like ocamlpro's branch provides will be Really Quite Nice to have.
<adrien>
at least it's on inria.fr which is a good sign
<adrien>
you said it was getting closer to being complete: do you know what is still wrong?
<hcarty>
adrien: I don't remember, but there is/was a README in the SVN branch that outlined what was not complete
<hcarty>
A recent mailing list post re-affirmed that completing the feature is on ocamlpro's TODO list
<adrien>
ok, let's hope it's kept up-to-date ;-)
<hcarty>
I'll do my part hoping :-)
<adrien>
hmmm, Ctrl-Alt-Backspace doesn't remove the whole text from the address bar in firefox; it usually kills the X server =)
<reynir>
lol
<adrien>
any idea what the "attributes" branch is?
<adrien>
oh, a contracts branch
<adrien>
hcarty: last commits are quite old
<beginner>
is this correct
<beginner>
# let twice f x = f (f(x));;
<beginner>
# twice double 4;;
<beginner>
- : int = 16
<beginner>
I mean I am trying to understand higher order function
<adrien>
looks good but I'd write: let twice f x = f (f x)
<beginner>
ops missing this from above:# let double x = 2 * x;;
<adrien>
(less parens)
<beginner>
yeah, I am trying to understand this example: let twice ((f : int -> int), (x : int)) : int = f (f x)
<beginner>
but their syntax is confusing
<beginner>
so I just read about what it supposed to do
<zorun>
you can forget the type annotations
<beginner>
and craft it my own way
<adrien>
well, they're putting the type annotation, and using a tuple instead of different arguments
<beginner>
based on my understandin
<beginner>
yeah
<zorun>
good catch adrien
<beginner>
I don't understand why the books and many of the articles out there, use all the things that they won't explain what in early chapters
<zorun>
it's not very elegant to use so much type annotations, though
<zorun>
*so many
<adrien>
I definitely prefer copying the output of the toplevel right after the code
<adrien>
beginner: it's quite hard to start with only one thing
<beginner>
true, but atleast they could give a more straight forward example that is clean and easy to understand. The example in "Introduction to Objective Caml" is even harder to understand
<adrien>
I've liked the "school" intro to ocaml, probably because it was using ocaml as a way to do maths and left many many things aside
<beginner>
is that a book?
<adrien>
I think quite a lot of unis have their own introductions and some are probably quite good but we don't necessarily get to see them and there isn't a place which lists them all (or almost)
<adrien>
nope, unfortunately
<reynir>
My university teaches java :(
<beginner>
good for you guys
<reynir>
We did get to write in ocaml for the compiler course, though.
<beginner>
I am too dumb to go to uni
<beginner>
so been learning stuff on my own
<reynir>
... a java compiler (or, subset of java9
<reynir>
I don't really believe going to university is so much about being clever, actually.
<thelema>
reynir: agreed - it's mostly about being able to endure
<beginner>
alrighty, I am done for today - learn a few things, very happy!!
<beginner>
need to go to sleep now =)
<beginner>
thank you guys! Really helpful - will bug you guys more tomorrow =)
ulfdoz has joined #ocaml
Kakadu has quit [Quit: Konversation terminated!]
ikaros_ has joined #ocaml
oriba has joined #ocaml
pcjoby has joined #ocaml
Snark has quit [Quit: Quitte]
rwmjones has quit [Ping timeout: 252 seconds]
roconnor has joined #ocaml
rwmjones has joined #ocaml
rgrinberg has quit [Ping timeout: 240 seconds]
<roconnor>
is Str.global_substitute recursive? I.e. if I replace "s" with "ss" in "rst" do i get "rsst" or does it run forever?
<thelema>
roconnor: I expect it'll do the right thing and continue the search from after the replacement.
<thelema>
but the right way to test is to try it out.
sepp2k has quit [Remote host closed the connection]
ulfdoz has quit [Read error: Operation timed out]
rwmjones has quit [Ping timeout: 252 seconds]
milosn has quit [Read error: Connection reset by peer]
ousado_ has quit [Ping timeout: 244 seconds]
emmanuelux has quit [Remote host closed the connection]
emmanuelux has joined #ocaml
jonludla_ has quit [Remote host closed the connection]
milosn has joined #ocaml
rwmjones has joined #ocaml
<roconnor>
thelema: um, where do I find the Str module; I've been looking for a while now and haven't found it.
<thelema>
roconnor: it's in the str library
<roconnor>
let re = Str.regexp "[+*]";;
<roconnor>
Error: Reference to undefined global `Str'