gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.1 http://bit.ly/nNVIVH
struktured has joined #ocaml
arubin has joined #ocaml
arubin has quit [Client Quit]
arubin has joined #ocaml
ski has joined #ocaml
arubin has quit [Client Quit]
arubin has joined #ocaml
dsheets has quit [Ping timeout: 255 seconds]
dsheets has joined #ocaml
dnolen has quit [Quit: dnolen]
<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?
<thelema> The biggest help was the users manual (which I still consult regularly): http://caml.inria.fr/pub/docs/manual-ocaml/index.html
<roha> as in "ordinateur" for computer etc.
<reynir> roha: I think most languages have their own word for "computer"
<reynir> but "computer" is often used anyway
<thelema> kon'pyuutaa
<reynir> datamat
<roha> rechner ;)
<reynir> thelema: is that finnish or something?
<thelema> reynir: no, japanese
<roha> hmm
<roha> kon'pyuutaa sounds very much like computer
<roha> does it mean something on its own?
<thelema> yes, that was my point.
<Kakadu> Hi all!
<thelema> it means computer
<thelema> hi Kakadu
<roha> yea i meant, if it's a borrowed word
<Kakadu> how to explain ocamlfind (via environment variables maybe) that it deals with very fresh, just installed OCaml without a lot of libraries
<Kakadu> ?
<roha> which it seems to be
<roha> it seems i just learned my first japanese word :)
<thelema> Kakadu: you've reinstalled ocaml; if you don't plan on having multiple ocaml installations, I recommend reinstalling findlib.
<Kakadu> thelema: I don't want to reinstall OCaml and libraries.
<Kakadu> thelema: I want to override default location of libraries
<thelema> ocamlfind printconf
<thelema> edit your ocamlfind config file
<Kakadu> it is ufnlexible(
<Kakadu> unflexible
<thelema> huh?
<thelema> ocamlfind has had every bit of flexibility I've wanted and much more
<Kakadu> I want a super button with title `OCamlfind, use ocamlfind.conf from ~ not from /etc`
<thelema> You can set a different location by changing the environment variable OCAMLFIND_CONF which must contain the absolute path of findlib.conf.
<thelema> (from `man findlib.conf`)
<Kakadu> O_O
<Kakadu> I'm stupid(
<Kakadu> thelema: thanks!
<beginner> a very noob question
<beginner> I was looking online and found this
<beginner> let double (x:int):int = 2 * x
<thelema> a bit odd use of the syntax, but ok.
<beginner> the syntax is kinda different from the book
<beginner> thelema, would you mind to explain?
<thelema> beginner: I recommend not annotating types as a beginner
<beginner> ok
<thelema> if you *really* want to do so, use the syntax "let double : int -> int = fun x -> 2 * x"
jamii has quit [Quit: Leaving]
<thelema> the (x:int) says that x is an int
<thelema> the :int outside the () says that the function returns a float.
_andre has quit [Quit: leaving]
<_habnabit> where does the float part come from?
<thelema> err, int
<thelema> sorry, I tested this by writing "let double (x:int):float = 2 * x;;"
<_habnabit> okay, good. just making sure ..
<thelema> so I was still thinking float
<beginner> I am trying to understand higher order functions from this page
<beginner> and new syntax like that confused me ^_^
<thelema> interesting that cornell's style is like that...
<thelema> I guess it avoids having to explain 'a on the first day
<beginner> what is 'a?
<thelema> a type variable.
<beginner> how does it work? I see f' in the book I am reading
<beginner> and nowhere does it explain that
<thelema> just like "x" stands for some value, "'a" stands for some type.
<beginner> which is the reason why I am looking at articles on the internet
<thelema> # let compose f g x = f (g x);;
<thelema> val compose : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b = <fun>
<thelema> this will be scary for a sec, so hold on.
<thelema> are you familiar with the idea of function composition?
<beginner> yup
<beginner> atleast in math
<thelema> ok, compose is an ocaml function that composes two other functions, [f] and [g]
<thelema> if you look at the type, [f] has type ['a -> 'b] and [g] has type ['c -> 'a]
<beginner> ok
<thelema> meaning that g's output ('a) must be the same type as f's input ('a)
<thelema> the result of composing them is ('c -> 'b), which is g's input to f's output
<thelema> in order to express this in a generic fashion, you need type variables.
<beginner> one sec, trying to chew it
<thelema> maybe I should have started with a simpler example...
<beginner> ok
sepp2k has quit [Ping timeout: 240 seconds]
<thelema> val tap : ('a -> unit) -> 'a -> 'a
<thelema> now we have only one type variable: 'a.
<thelema> this function takes two arguments: [tap f x]
<thelema> f must return [unit] (i.e. nothing)
<thelema> and f must take a value of type ('a)
<thelema> x must be a value of type ('a)
<thelema> i.e. a value of the same type as f's argument.
<beginner> can you paste the line before this: val tap : ('a -> unit) -> 'a -> 'a
<thelema> beginner: you want the definition of the tap function?
_andre has joined #ocaml
<thelema> I just copied that from the batteries documentation, so there's no relevant "line before this"
<beginner> ah ok
<thelema> the tap function is very easy to define: let tap f x = f x; x
<beginner> thought you were giving an example from the command line
_andre has quit [Read error: Connection reset by peer]
<thelema> back in 15 min
Boscop has joined #ocaml
Boscop has quit [Client Quit]
zmoazeni_ has quit [Ping timeout: 240 seconds]
<beginner> So in the example above
<beginner> f is a function that takes 'a as input and return a unit?
zmoazeni has joined #ocaml
<beginner> which will the be passed to x that takes 'a as input and output 'a?
<beginner> *then
spearalot has quit [Quit: Get MacIrssi - http://www.sysctl.co.uk/projects/macirssi/]
avsm has joined #ocaml
sepp2k has joined #ocaml
<reynir> beginner: no, x is of type 'a
<reynir> or what do you mean?
<beginner> yeah, it takes type 'a as input
sebz has joined #ocaml
<beginner> is a very simple example that I can play around to understand it?
<beginner> *there
<_habnabit> example of what?
<beginner> example that use the above type
<thelema> beg: let tap f x = f x; x
<beginner> the semicolon and x at the end?
<beginner> sorry for being noob, just started learning few hours ago
<thelema> yes
<beginner> I mean what do they mean?
<thelema> oh, semicolon separates expressions saying "evaluate the first expression, ignore its result, and then evaluate the second expression"
<thelema> x is just x - in this case, x is what's returned from tap.
<beginner> btw, what's the expression f space x here means
<_habnabit> a function call
<thelema> call f with argument x
<beginner> so let see what I can understand from here: tap is a function that takes 2 arguments - f and x
<beginner> and inside the body, it calls the function f with the argument x
<beginner> correct?
<_habnabit> yes
<beginner> so the return type of "f x" is 'a?
<_habnabit> yes
<_habnabit> because f is ('a -> 'a)
<_habnabit> er, ('a -> unit)
<_habnabit> wait, agh
<_habnabit> sorry, I was thinking about the wrong function
<beginner> yeah, from the explanation above
<beginner> unit
<_habnabit> the return type of `f x` is unit
<_habnabit> because f is ('a -> unit)
<reynir> beginner: here's an exercise for you: what is the type of this function? let not_tap (f : 'a -> unit) x = f x
<reynir> maybe it's not a good exercise
<beginner> no I was wondering why is it ('a -> unit)
<beginner> instead of ( int -> int)
<beginner> # let f x = f x;;
<beginner> val f : int -> int = <fun>
<beginner> # let tap f x = f x;;
<beginner> val tap : ('a -> 'b) -> 'a -> 'b = <fun>
<beginner> ah
<_habnabit> beginner, in the first example, the `f` is not a parameter; the `f` referred to in your function body is a function of type (int -> int)
<_habnabit> you defined some `f` previouxly
<beginner> just noticed that
<beginner> one sec
<beginner> # let f x = x;;
<beginner> val f : 'a -> 'a = <fun>
<beginner> so a much simpler example I guess
<_habnabit> yep.
<_habnabit> did you have a question?
<beginner> so 'a here means it can be any type?
<_habnabit> yes
<beginner> alright I am clear about it now
mcclurmc has quit [Excess Flood]
mcclurmc has joined #ocaml
<beginner> so when I do # let f x = x + x;;
<beginner> val f : int -> int = <fun>
<beginner> which mean that
<beginner> it's 'a because the function does nothing more than returning x
<_habnabit> what?
<beginner> which could be anything, while in the second one x + x
<beginner> so the compiler know it is integer
<beginner> did I get it right?
<_habnabit> right, because (+) is of type int -> int -> int
sebz has quit [Quit: Computer has gone to sleep.]
Anarchos has joined #ocaml
<beginner> reynir: in the exercise you pasted above.. What is the colon means? f : 'a
<beginner> the return type of f is 'a?
sebz has joined #ocaml
<_habnabit> no, it was (f : 'a -> unit)
<_habnabit> which means that f is of type 'a -> unit
<beginner> so in that example, f doesn't take an argument?
<_habnabit> ... no. because it's of type 'a -> unit, it takes one argument of type 'a
<beginner> alright
<beginner> thanks
<beginner> difficult to learn but fun lol
<_habnabit> no, it's just different from what you're used to
<_habnabit> if you've done other programming before
<beginner> yeah done C and python before
<beginner> first time touching a functional language
<hcarty> Has anyone here tried ocp-pack from ocamlpro?
<hcarty> http://www.ocamlpro.com/code/2011-08-10-ocaml-pack-functors.html -- a bit more than half way down the page
<adrien> not me but I'm quite interested in it
<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'
<roconnor> ah
reynir has quit [Ping timeout: 244 seconds]
<roconnor> thanks
jonludlam_home has joined #ocaml
musically_ut has quit [Ping timeout: 252 seconds]
edwin has quit [Remote host closed the connection]
<roconnor> oh dang
<roconnor> The function subst is called once for each matching substring, and receives s (the whole text) as argument.
<roconnor> I though it subst recieved the matching substring :(
<_habnabit> nope
ousado_ has joined #ocaml
<_habnabit> note also that matched_group takes the full string
<thelema> yup, it's a bit jooky in some ways.
<thelema> I've been meaning to write a replacement that uses proper Automaton technology, but I'd probably have to abandon backreferences.
<thelema> so it wouldn't be backwards compatible
<roconnor> fine by me :D
<thelema> I'll let you know when I'm done.
ousado_ is now known as ousado
ousado has quit [Changing host]
ousado has joined #ocaml
ikaros_ has quit [Quit: Ex-Chat]
roha has quit [Ping timeout: 252 seconds]
<_habnabit> is there a way for a user to specify a printf format string from some string input?
<_habnabit> i.e. not a literal
<thelema> _habnabit: ocaml needs to know the types of arguments allowed.
<thelema> statically, at compile time
<_habnabit> yeah, but there's no way to try to convert a string to a format-type and raise an exception if it can't be?
<thelema> Obj.magic
<_habnabit> ah.
<thelema> although what will happen at runtime could be strange.
<_habnabit> well, this is a one-off anyway..
<thelema> I think you'll find getting the right arguments to printf to be the hard part.
<thelema> by strange, I mean: "expect segfaults or worse if anything goes wrong"
<_habnabit> haha, okay
<_habnabit> well, so far so good
* thelema waits for the explosion
<_habnabit> haha
<_habnabit> is format6 more than just a string with a phantom type to indicate what can be done with it?
<thelema> no, I'm pretty sure its runtime representation is a plain string.
<thelema> external get : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> int -> char
<thelema> = "%string_safe_get";;
<_habnabit> ah.
<thelema> :)
<thelema> external unsafe_to_string : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> string
<thelema> = "%identity";;
roha has joined #ocaml
Morphous has quit [Read error: Operation timed out]
Morphous has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
ikaros has joined #ocaml
roha has quit [Ping timeout: 240 seconds]
gnuvince has left #ocaml []
dnolen has joined #ocaml
destrius has joined #ocaml
arubin has joined #ocaml
scrappy_doo_ has quit [Ping timeout: 240 seconds]
scrappy_doo_ has joined #ocaml
ikaros has quit [Quit: Ex-Chat]