ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.1 announcement at http://ocaml.org/releases/4.02.html | Public channel logs at http://irclog.whitequark.org/ocaml
yomimono has quit [Ping timeout: 252 seconds]
mcclurmc has joined #ocaml
tmtwd has joined #ocaml
obadz- has joined #ocaml
obadz has quit [Ping timeout: 246 seconds]
jabesed has joined #ocaml
ollehar has quit [Ping timeout: 265 seconds]
ygrek has quit [Ping timeout: 264 seconds]
rand000 has quit [Quit: leaving]
waneck has quit [Ping timeout: 246 seconds]
hey_guys has joined #ocaml
<hey_guys> Hey all, quick question: is there a way to refer to a signature defined in an .mli file the same way you might refer to code in code.ml using the module name Code?
hey_guys has quit [Ping timeout: 246 seconds]
mcclurmc has quit [Ping timeout: 272 seconds]
sh0t has quit [Ping timeout: 265 seconds]
hey_guys has joined #ocaml
hey_guys has quit [Client Quit]
waneck has joined #ocaml
emanuelz has joined #ocaml
emanuelz has quit [Quit: emanuelz]
hey_guys has joined #ocaml
struktured has joined #ocaml
hey_guys has quit [Client Quit]
mcclurmc has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
tjscanlon has quit [Quit: Textual IRC Client: www.textualapp.com]
mcclurmc has joined #ocaml
darkf has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
idegen has quit [Quit: Leaving.]
tamago_ has joined #ocaml
mcclurmc has joined #ocaml
<tamago_> Can someone help me with OCaml idioms?
obadz- has quit [Ping timeout: 252 seconds]
<tamago_> I've learned that I can avoid using the object system in favor of modules.
<tamago_> Let's say I'm trying to do something basic that I would do with objects.
mcclurmc has quit [Ping timeout: 276 seconds]
<tamago_> Maybe I should just completely refactor my design, but imagine I have something like this:
<tamago_> module M = struct let x = ref 5 let set_x new_x = x := new_x let get_x = x end;;
<tamago_> Then elsewhere I want to create multiple instances of that object.
<tamago_> Or module rather.
<tamago_> Is there an idiomatic way of doing this? Should I be using a functor? It seems rather elaborate.
mcclurmc has joined #ocaml
obadz has joined #ocaml
<dmbaturin> tamago_: You don't store anything (mutable or not) within modules.
<dmbaturin> You define a type and a bunch of functions that work with that type, possibly including a function that creates values of that type (analogous to constructor in OO).
<dmbaturin> If you want to protect some invariants, you make the type abstract (don't specify its implementation in the signature) so only functions from your module and nothing else can work with that type.
jabesed has quit [Ping timeout: 246 seconds]
<tamago_> I can do that in the .mli I believe.
Axle has joined #ocaml
Axle has quit [Client Quit]
<tamago_> I feel this is a lot like making everything a static function in Java, which makes me uncomfortable...
<tamago_> But maybe I'm just a bit confused.
<tamago_> Thanks!
<dmbaturin> * forgot the exception in the signature, but you see the point
<tamago_> yea thanks!
<tamago_> Oh, but assuming you are only making one module with the PERSON sig, would it be better to have a person.ml file and a person.mli (and thus never use the word module explicitly)?
<dmbaturin> If it's not nested, in real programs .ml/.mli pair is usually a better choice indeed.
<tamago_> cool.
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<dmbaturin> Static methods in Java do feel odd, methods are supposed to be about changing object state rather than doing things to values from outside world and returning them back.
<tamago_> Yea, but modules seem to be designed to do exactly that.
<tamago_> Note: this feels more natural in a functional context than in Java.
<dmbaturin> But there is nothing in Java that you can use as a container for functions, so class misuse is the only thing to do if a collection of functions is what you want.
<tamago_> I see, using static methods pays the overhead for objects and then doesn't use it.
<tamago_> Thanks for the help. It's easy to write OCaml but hard to write it well coming from Java since there are so many choices.
<tamago_> Java always has just one choice, even if it isn't really appropriate.
mcclurmc has quit [Ping timeout: 255 seconds]
darkf_ has joined #ocaml
darkf has quit [Ping timeout: 248 seconds]
BitPuffin|osx has quit [Ping timeout: 246 seconds]
ggole has joined #ocaml
darkf_ is now known as darkf
obadz has quit [Ping timeout: 252 seconds]
obadz has joined #ocaml
<dmbaturin> tamago_: By the way, what's going on with Swing? Are they seriously going to kill it off in favor of JavaFX? How's it confirmed to the Swing API?
<tamago_> I'm not sure, I haven't worked with Swing.
<dmbaturin> * compared
<tamago_> My Java development has all been with Google App Engine.
<dmbaturin> Ah, ok. I haven't written any Java in a long time so I'm wondering what's going on there.
<tamago_> (mostly)
<tamago_> Java 8 introduces a ton of new features.
<tamago_> But I haven't used it yet.
<tamago_> Java adding more functional features.
<tamago_> Sort of redundant as long as Scala exists though.
<dmbaturin> Yeah, I've heard. Without good support for handling immutable values it's not very functional though. As far as I understand there're still no actual higher-order functions either.
milosn has quit [Ping timeout: 256 seconds]
milosn has joined #ocaml
struktured has quit [Ping timeout: 246 seconds]
keen___________4 has joined #ocaml
keen___________3 has quit [Ping timeout: 252 seconds]
moei has quit [Quit: Leaving...]
obadz has quit [Ping timeout: 256 seconds]
obadz has joined #ocaml
mcclurmc has joined #ocaml
Algebr has joined #ocaml
mcclurmc has quit [Ping timeout: 250 seconds]
swgillespie has joined #ocaml
Simn has joined #ocaml
tamago_ has quit [Quit: Page closed]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
johnf_ has joined #ocaml
johnf__ has quit [Read error: Connection reset by peer]
Sim_n has joined #ocaml
fantasticsid has joined #ocaml
Simn has quit [Ping timeout: 252 seconds]
johnf_ has quit [Read error: Connection timed out]
johnf_ has joined #ocaml
fantasticsid has quit [Read error: Connection reset by peer]
fantasticsid has joined #ocaml
badon has joined #ocaml
tmtwd has quit [Read error: Connection reset by peer]
slash^ has joined #ocaml
tmtwd has joined #ocaml
mcclurmc has joined #ocaml
jeffmo has joined #ocaml
mcclurmc has quit [Ping timeout: 264 seconds]
moei has joined #ocaml
badon has quit [Ping timeout: 248 seconds]
tamago has joined #ocaml
<tamago> Gah, programming in OCaml is like writing with my left hand. Why didn't I start with OCaml and learn things right from the start?
tamago has quit [Client Quit]
<adrien> that's actually a fairly nice analogy :p
<Algebr> Is ocamlnet's netstring still the best game in town for parsing html?
<Algebr> okay apparently cow also has a HTML module with a of_string function
mcclurmc has joined #ocaml
amnn has joined #ocaml
amnn has quit [Client Quit]
<flux> cow?
mcclurmc has quit [Ping timeout: 246 seconds]
<flux> oh, there's a library called cow :)
<flux> thought it was an acronym
<flux> algebr, does it work?-)
slash^ has quit [Quit: Leaving.]
<Algebr> I'm getting to it
dmiles_akf has quit []
dmiles_afk has joined #ocaml
<Algebr> well, it crapped out already. It crapped out on <!DOCTYPE html>, the very first line.
<Algebr> I suspect its built on top of ocamlnet's netstring, the api is similar..
IMM has joined #ocaml
IMM has quit [Client Quit]
Onemorenickname has joined #ocaml
<Onemorenickname> Hi guys
<Onemorenickname> Do you know an online IDE for ocaml ?
<Algebr> To explore the language or to actually do work?
<flux> algebr, well, it doesn't depend on netstring. I suppose it's possible the code base is just copied from there, but I wonder why would someone have bothered :)
Haudegen has quit [Ping timeout: 272 seconds]
<Onemorenickname> Algebr, to explore the language
<Onemorenickname> I just want to try some inversion counting stuff
<Onemorenickname> In fact, I will have exams like really soon
<Onemorenickname> And it's in ocaml
<Onemorenickname> (It's very basic stuff)
<Onemorenickname> But I'd like to train a lil' bit
<Algebr> flux: its really painful that an HTML parser craps out on <!DOCTYPE html>, something that hmm, every single page has
Kakadu has joined #ocaml
<flux> well, http://try.ocamlpro.com/ is a very basic toplevel
<Onemorenickname> I saw it, but it's only an interpreter
<Onemorenickname> I'd like to have a compiler
<Algebr> yea
<flux> it seems there's also a more ide-like thing here, I hadn't seen it before: https://dbgr.cc/l/ocaml
<Algebr> it is compiling it anyway
<Onemorenickname> I used to use coding ground, but it's fucked up
milosn has quit [Ping timeout: 252 seconds]
<Algebr> if you want a compiler, then install ocamlc/ocamlopt.
<Onemorenickname> flux, it's perfect
<Onemorenickname> Thanks
<Onemorenickname> Algebr, and an IDE ~
<flux> onemorenickname, does it work?-)
<Onemorenickname> But I found what I wanted
<adrien> where's there ocaml ipython notebook btw?
<flux> well, I doubt that has any 'ide' features other than editor with syntax highlighting
<Algebr> Onemorenickname: an IDE would be something you that sort of set up...
milosn has joined #ocaml
<flux> onemorenickname, I know that local editors have cool features like querying the type of an expression
<Onemorenickname> I'll be back
<flux> or like Merlin does error checking on save
<Algebr> emacs + merlin + tuareg, pretty much all you need
<adrien> ah
<adrien> which one is "better"?
<adrien> Drup: ^
Haudegen has joined #ocaml
<Algebr> I can't seem to find a robust solution to parsing html from the wild.
slash^ has joined #ocaml
creichert has quit [Ping timeout: 265 seconds]
<flux> algebr, so I guess you tried netstring's and it didn't work?
<Algebr> had to fall back on netstring, trying to use it now.
<flux> I've succesfully picked the title tag from pages with netstring
tmtwd has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
mcclurmc has quit [Ping timeout: 265 seconds]
fantasticsid has quit [Read error: Connection reset by peer]
<Algebr> I'm just trying to get all the string caught in the Data constructor
mengu has joined #ocaml
amnn has joined #ocaml
<Algebr> okay, got it working.
mengu has quit [Ping timeout: 256 seconds]
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.2 announced http://ocaml.org/releases/4.02.html | Public channel logs at http://irclog.whitequark.org/ocaml
tane has joined #ocaml
<Onemorenickname> I'm back
<Onemorenickname> ocaml is so cool though
milosn has quit [Ping timeout: 252 seconds]
amnn has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
milosn has joined #ocaml
<Onemorenickname> I should've gone into functional programming way earlier
Algebr has quit [Remote host closed the connection]
jave has quit [Read error: Connection reset by peer]
mcclurmc has joined #ocaml
<Onemorenickname> How can I retrieve an element of tuple in ocaml, without matching expressions ?
<Onemorenickname> for instance, I have a function like let f x = (x, x + 2) in
<Onemorenickname> And an other function g, which will take in parameter (f 2) for instance
<Onemorenickname> How can I access the first element ,and the second element of the tuple ?
<tane> Onemorenickname, functions fst and snd
<Onemorenickname> which are defined with matching expressions ?
<tane> you can either match the tuple, i.e destructure it, or use functions
<Onemorenickname> these functions use match ?
mcclurmc has quit [Ping timeout: 264 seconds]
<tane> i don't know their implementation
<def`> yes
<Onemorenickname> i see
<Onemorenickname> so i guess, the best i can do is creating an object instead of returning a tuple
<Onemorenickname> thanks guys
<tane> why?
darkf_ has joined #ocaml
<flux> onemorenickname, you can deconstruct tuples with let as well: let (first, second) = (5, 4) ..
<Onemorenickname> because a matching expression would look very ugly in the code i'm writing
<Onemorenickname> flux : oh, i didnt know
<Onemorenickname> then, it's way better than creating an object
<Onemorenickname> thanks
<Onemorenickname> well, i think it's the best solution
<Onemorenickname> ha ha ha :D
<def`> zomg
octachron has joined #ocaml
<Onemorenickname> def` ?
<ggole> If you only want the first/second element of a pair, matching is a bit heavy
<Onemorenickname> ggole : Yep, that's why it looked ugly
<Onemorenickname> I thought there were more appropriate ways to do that
darkf has quit [Ping timeout: 248 seconds]
<Onemorenickname> I was wondering, what made you dig into ocaml ?
<flux> can't recall really. it's not something that was covered at the uni. probably found it interesting per some writings on the internet.
<Onemorenickname> i see, how old are you flux ?
<flux> about 35
<Onemorenickname> ok, thanks for your answers :)
<Onemorenickname> what's the best way to apply two functions on two elements of a tuple ?
<Onemorenickname> like, i have (a, b)
<Onemorenickname> and i want to f a and g b
Algebr has joined #ocaml
<Algebr> et
<Onemorenickname> ou
jave has joined #ocaml
obadz has quit [Ping timeout: 272 seconds]
obadz has joined #ocaml
struktured has joined #ocaml
<fds> Onemorenickname: Is there are reason you don't want to just do: f (fst pair);; g (snd pair);; ?
rand000 has joined #ocaml
<Onemorenickname> fds : I learn nothing if I just do that, and I feel like there is a better way
<fds> Better in what way?
<Onemorenickname> aethetics
<Onemorenickname> aesthetics *
tani has joined #ocaml
<Onemorenickname> here, we have to use "pair" two times
<Onemorenickname> maybe there is a one-liner, which only uses pair one time
<flux> onemorenickname, well, if that's something you do often you could have a function to do the binding
<ggole> If pair is an application, just bind it to a name first. Otherwise, the code is fine.
<fds> Hmm, you could do something like: let pair_apply f g (a,b) = f a; g b;;
<fds> But, I don't really get what you want.
<Onemorenickname> fds : Maybe we just can't understand each other about this
<Onemorenickname> It happens sometimes
* fds nods.
<fds> I'm not particularly an OCaml expert either, I was just tryiing to say something helpful. :-)
<Onemorenickname> I see, thanks for the effort though, I appreciate that :)
tane has quit [Ping timeout: 256 seconds]
<Onemorenickname> In fact, I'd like something which takes a pair, apply two functions to it, and returns a pair
<Onemorenickname> something like let f p a b = let (c, d) = p in (a c, a d)
<ggole> let map_pair f g (a, b) = (f a, g b)
<Onemorenickname> (a c, b d) *
<Onemorenickname> ggole : we can destructure a tuple this way ?
<ggole> Yep
<Onemorenickname> that's the way i wanted
<Onemorenickname> thanks
<Onemorenickname> i knew there was something like that ha ha
<Onemorenickname> yeah
<Onemorenickname> I made sort and count in n log n
<Onemorenickname> ~
mengu has joined #ocaml
zpe has joined #ocaml
<Onemorenickname> is it possible to make ocaml read in the "other sens" when i apply several functions ?
mengu has quit [Ping timeout: 250 seconds]
<Onemorenickname> for instance, when i write "print_tab sort_tab tab", i always get an error
<Onemorenickname> and when i have many, parenthesis become a pain, is there a better way ?
<fds> f (g x) is equivalent to g x |> f if you like that better.
<Onemorenickname> g x |> f ?
<Onemorenickname> well, I'll stick with parenthesis ha ha :D
mengu has joined #ocaml
mengu has quit [Client Quit]
seanmcl has joined #ocaml
mcclurmc has joined #ocaml
Hannibal_Smith has joined #ocaml
mcclurmc has quit [Ping timeout: 255 seconds]
<ggole> f @@ g x
palo has joined #ocaml
<Onemorenickname> How can I do something like type test = E | F of mutable int
<Onemorenickname> So I can modify it later ?
<Onemorenickname> I tried with "ref", it bugged
Algebr has quit [Remote host closed the connection]
<ggole> int ref should work
<Onemorenickname> oh
<Onemorenickname> i tried ref int
<ggole> And when we finally get 4.03, it includes constructor records with mutable fields
<Onemorenickname> as I always do let f = ref 4
<ggole> type application syntax is half-backwards for hilarious reasons.
<Onemorenickname> ok, now, we don't have constructor with mutable
<Onemorenickname> (what are these reasons ?)
<ggole> Roughly "that's how SML did it"
<ggole> And I think SML did it that way because it means fewer parens in common cases
<Onemorenickname> What is a paren ?
<Onemorenickname> What is SML ?
<Onemorenickname> oh, parenthesis
<ggole> SML is Standard ML, an ancestor language
yomimono has joined #ocaml
zpe has quit [Remote host closed the connection]
hay207 has joined #ocaml
BitPuffin|osx has joined #ocaml
ollehar has joined #ocaml
BitPuffin|osx has quit [Remote host closed the connection]
BitPuffin|osx has joined #ocaml
palo has quit [Quit: Lost terminal]
rossberg has quit [Ping timeout: 248 seconds]
Hannibal_Smith has quit [Quit: Leaving]
<Onemorenickname> let t = (ref 2, "test")
<Onemorenickname> What is the best way to modify the first element ?
darkf_ is now known as darkf
rossberg has joined #ocaml
bbc_ is now known as bbc
zpe has joined #ocaml
<tani> Onemorenickname, for example (fst t) := 1337
<tani> or let (r,_) = t in r := 1337
<Onemorenickname> ok, thanks :)
zpe has quit [Ping timeout: 252 seconds]
<tani> Onemorenickname, do you have a book or other resource to learn ocaml?
<Onemorenickname> Not really, but I don't have the time to study one, sorry
<tani> mh, carry on then :)
<Onemorenickname> (I have until tonight in fact ~)
<tani> some univ. assignment?
<Onemorenickname> entrance exams
<Onemorenickname> for a very good school
<Onemorenickname> Tomorrow is english test, and after tomorrow is the computer science one
<tani> ok
<tani> good luck
<Onemorenickname> Thanks :)
<def`> good luck, reading a primer won't take much time and will help a lot though
<Onemorenickname> what's a primer ?
<def`> I mean an introduction to ocaml
jave has quit [Ping timeout: 244 seconds]
<def`> I am not sure which one to suggest :)
<Drup> adrien: which one of the iocaml is better ?
<Drup> None really
<Drup> one runs on the server, hence it needs a server and can run non-ocaml things
<adrien> Drup: I meant, between iocaml and try.ocamlpro.com
<Drup> ah
<adrien> and actually, if one of the iocaml host is newer/better/more popular or even has more ponies, I'd like to know
<adrien> I want to add that to /topic
<Drup> the comparison should be between http://ocsigen.github.io/js_of_ocaml/ and iocamljs, for a start
<adrien> well, there have been a few questions about that recently and I think it makes sense to put the most beginner-friendly in the topic
<Drup> iocaml is more suited for interactive tutorials, since you can have pre-loaded code
jave has joined #ocaml
<Drup> adrien: yeah, but the jsoo ones has much more ponies^W syntactic coloration.
<adrien> :)
<Onemorenickname> ponies ?
<Drup> Onemorenickname: he has a bit of an obsession, just roll with it
<Onemorenickname> I see
<adrien> Drup: bunnies actually
<adrien> ponies is simply because it's the internet currencty
<adrien> currency*
<adrien> Drup: try.ocamlpro.com loads *much* more quickly however
<Onemorenickname> how can i make a balanced tree from a binary tree ?
<Drup> adrien: the camlp4 effect
yomimono has quit [Ping timeout: 248 seconds]
<adrien> Drup: well, one freezes my web browser for a bit and the other doesn't so I guess I'll put try.ocamlpro.com even though it doesn't have colors
<Drup> Onemorenickname: that's more of an algorithmic question, there are plenty of very pedagogic answers on the web.
<Onemorenickname> Drup : I see
octachron has quit [Ping timeout: 264 seconds]
<Onemorenickname> Can I paste you a code, and one of you tells me how I can improve it so it looks better in ocaml ?
<Drup> Sure, use pastebin
<Onemorenickname> (It's already written in ocaml, and it works)
<Onemorenickname> I feel like it's too long
ollehar has quit [Ping timeout: 248 seconds]
<Drup> merge sort on arrays, hum, this is not very functional :3
<Onemorenickname> I don't know which nlog(n) sort is functional ^^'
<Onemorenickname> So I made the quickiest one
<Drup> merge sort is functional, it's just better on lists
<Onemorenickname> how do you fold a list in two ?
<ggole> The first function could just be Array.iteri (Printf.printf "%d : %d") a
<Drup> fold a list in two ?
<Onemorenickname> I dont' know what's the right word in english
<Onemorenickname> From a list, making two lists of equal lengths
<Drup> you don't need to do that
<Onemorenickname> ?
<Drup> you don't mutate the list
<Drup> so no need to copy it
<Onemorenickname> how do you sort then ?
<Drup> It's exactly the same algorithm
<Onemorenickname> the one I know is making two sub arrays
<Drup> just that, instead of copying around all the time, it creates new lists
<Onemorenickname> sorting them, and merging them
<Onemorenickname> The list only contains references ?
<Drup> No
<Drup> Onemorenickname: I advise you to try to separate the algorithm in 3 phase (clearly define each by a function): split, sort (the recursive call), merge
<Onemorenickname> so, when you split
<Onemorenickname> oh, you delete the old list ?
<Drup> well, not really, you don't take care of it :)
<Drup> if it's not used anymore, the GC will take care of it
<Onemorenickname> I don't see how it is different than with arrays then
<Drup> Try to write it, you'll see you can express it in a much more functional style.
<Onemorenickname> I think it's because I don't know what a functional style is
idegen has joined #ocaml
octachron has joined #ocaml
<Onemorenickname> Drup : I edited a lil' bit the code I've written before, in order to compare with a defined function
<Onemorenickname> But I get an error and I don't understand where it comes from
<Onemorenickname> http://pastebin.com/mk081QrT is the pastebin
<Drup> and the error ?
<Onemorenickname> File "hello_world.ml", line 61, characters 20-28:
<Onemorenickname> Error: This expression has type int * int -> int * int -> int
<Onemorenickname> but an expression was expected of type int -> int -> int
<Onemorenickname> Type int * int is not compatible with type int
<Onemorenickname> I don't know why he expects an "int -> int -> int"
<flux> onemorenickname, well, what's the type of merge_sort?
<Onemorenickname> flux : he gives an int, but i don't know why
<Onemorenickname> same with merge_sorting
<Onemorenickname> I don't see what in merge_sorting fixes an int
<flux> onemorenickname, you can annotate the expected types like this: let rec merge_sort (f : (int * int) -> (int * int) -> int) tab = ..
<flux> and then you get a new type error, this time inside merge_sort
<Onemorenickname> I found where it came from
<flux> but as merge_sort simply forwards the type to merge_sorting, you should instead put the type signature there
<Onemorenickname> When I initiate my return tab
<Onemorenickname> I do
<Onemorenickname> Array.make (l) 0
<Onemorenickname> and 0 is an int
<Onemorenickname> It would be good to have something telling us where the typing comes from
<Onemorenickname> Is there such a tool ?
<flux> I don't think so, but usually type retrieval (ie. emacs/vi + merlin) is a good tool for finding those
<Onemorenickname> I see
<Onemorenickname> I hope there will be emacs on the machine
<flux> school machine?
<Onemorenickname> yep
<Onemorenickname> windows i think
<flux> oh.. windows..
<Onemorenickname> ?
oscar_toro has quit [Quit: Lost terminal]
yomimono has joined #ocaml
jabesed has joined #ocaml
djellemah has joined #ocaml
zaquest is now known as ace15
ace15 is now known as zaquest
waneck_ has joined #ocaml
waneck has quit [Ping timeout: 255 seconds]
jeffmo has quit [Ping timeout: 250 seconds]
octachron has quit [Quit: Leaving]
darkf has quit [Quit: Leaving]
hay207 has quit [Quit: Leaving]
steshaw has joined #ocaml
dhil has joined #ocaml
psy_ has quit [Ping timeout: 252 seconds]
ollehar has joined #ocaml
Hannibal_Smith has joined #ocaml
psy_ has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
<Onemorenickname> ~
Hannibal_Smith has joined #ocaml
<struktured> Onemorenickname: windows + ocaml is not a frictionless experience, that's all
<adrien> s/ + ocaml//
adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.2 announced http://ocaml.org/releases/4.02.html | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
<struktured> fine, but windows is on the far end of the friction spectrum
<struktured> ah yes good ol 4.02.2 breaking all my ppx based code :)
<Onemorenickname> struktured, Oh, I see
<Onemorenickname> what is ppx ?
<Drup> Onemorenickname: ocaml's metaprogramming thing
<struktured> Onemorenickname: its a a relatively new generic syntax extension framework for ocaml that allows you to extend the AST...for example,to derive common traits like show,compare,etc, use ppx_deriving: https://github.com/whitequark/ppx_deriving
mcclurmc has joined #ocaml
<Onemorenickname> struktured, what is the AST ?
<Onemorenickname> I'm new to ocaml
<Onemorenickname> I was wondering too, how do you guys use ocaml ?
mcclurmc has quit [Ping timeout: 256 seconds]
creichert has joined #ocaml
dhil has quit [Ping timeout: 256 seconds]
<struktured> Onemorenickname: abstract syntax tree.. the compiler has a phase which it turns the code into a tree like structure, ppx allows a developer to inject stuff into the tree at certain eXtension Points
<Onemorenickname> oh i see
<Onemorenickname> i didnt know
<Onemorenickname> sounds cool
<Onemorenickname> so you can add your own stuff to ocaml ?
<struktured> Onemorenickname: it's almost like AOP or bytecode weaving, or code generation
<struktured> hence drup called it metaprogramming
<Onemorenickname> oh, i thought you were really touching the parser
<Onemorenickname> but, it's the same at the end
<Onemorenickname> I think I'd love to build my own interpreter
<struktured> It is, I guess, it touches the AST. I am only describing it in terms of other techniques to express it's usefulness
<Onemorenickname> I think I will do it once I finish my exams
<Onemorenickname> OH, I understand
<Drup> Onemorenickname: basically, you insert your onw AST to AST transformation, before the compiler does anything
<Drup> just after parsing
<Onemorenickname> Drup : That's what I understood
<Onemorenickname> And it makes me want to create my own language
<Drup> ppx is not really made for that
<Onemorenickname> I understood
<Onemorenickname> It's just something I want
<struktured> Onemorenickname: a dsl, or a better generic functional ML like language? If the latter, see https://www.fstar-lang.org/papers/icfp2015/full.pdf
<Onemorenickname> But ppx looks fun too as it is
<Onemorenickname> A generic language
<Onemorenickname> I think I'll try to make something which can generates code in whatever I want
<struktured> ambitious...one step at a time :)
<Onemorenickname> I don't know, I think it's easier to translate something I code in an other language
<Onemorenickname> I already made stuff like that between python and js
<Onemorenickname> So I'll dig in deeper
<struktured> the challenge comes from unportable libraries typically
<Onemorenickname> Get a better understanding, and do better things
sh0t has joined #ocaml
<Onemorenickname> Oh I see, but as I will be using this language as a learning tool, I don't really care about libraries
<Onemorenickname> I think I will mostly do low-level stuff
<Onemorenickname> But maybe it could be interesting to try to port libraries
<Onemorenickname> Problem is, a lot of them use stuff I don't even know
<Onemorenickname> So it looks kinda hard
<Onemorenickname> For instance, in C, I can't re-code read or write from the unistd, or make a window without library
<Onemorenickname> Do you have any advices ?
SomeDamnBody has joined #ocaml
<struktured> just learn ocaml, get very good at it. that's my tldr on the subject
<Onemorenickname> What does mean "getting very good" at ocaml ? And how can I do so ?
<struktured> working knowledge good
<struktured> read books, write software, play with utop, make sure merlin is working with your editor
<Onemorenickname> I don't know what are the interesting stuff to do with ocaml
<Onemorenickname> Or what the language aimed for
dhil has joined #ocaml
<Drup> how did you ended up here ? :p
<Onemorenickname> Drup : Exams ~
<Drup> Oh.
<flux> maybe the opam package list gives some idea what to do with ocaml? https://opam.ocaml.org/packages/
<Drup> Onemorenickname: which course ? :)
NomePadrao has joined #ocaml
<Onemorenickname> Drup : Computer science ? Seriously, they could chose python, javascript or c, it would have been the same, for what they do
<Onemorenickname> "Interactive theorem prover based on lambda-tree syntax"
<Onemorenickname> It sounds so cool
NomePadrao has quit [Remote host closed the connection]
<Drup> "computer science" is a bit vague
sh0t has quit [Quit: Leaving]
moei has quit [Quit: Leaving...]
<Onemorenickname> I don't know how to tell better, sorry
<Onemorenickname> I wasnt in courses
moei has joined #ocaml
<Onemorenickname> In fact, I wasn't in a school
<Onemorenickname> I passed the first part of the entrance test as a "free candidate"
<Onemorenickname> So, I don't really know what they did, I just have the program
<Drup> I see.
<Onemorenickname> And, you can see stuff like "Dynamic programming" "Recursive programming" "Floyd-Marshall search" "Karatsuba multiplication"
mcclurmc has joined #ocaml
MilleJamille has joined #ocaml
<Drup> well, they certainly couldn't have done recursive programming in python </troll>
ollehar has quit [Ping timeout: 252 seconds]
<struktured> eww
<Onemorenickname> So far they go, they could
<Onemorenickname> I think what they did is quite shitty
MilleJamille has quit [Remote host closed the connection]
yomimono has quit [Quit: Leaving]
MilleJamille has joined #ocaml
mcclurmc has quit [Ping timeout: 244 seconds]
tani has quit [Quit: Verlassend]
tane has joined #ocaml
tmtwd has joined #ocaml
ollehar has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has joined #ocaml
tmtwd has quit [Ping timeout: 246 seconds]
MilleJamille has quit [Remote host closed the connection]
ggole_ has joined #ocaml
ggole has quit [Ping timeout: 264 seconds]
djellemah has quit [Ping timeout: 250 seconds]
mcclurmc has joined #ocaml
mcclurmc has quit [Ping timeout: 244 seconds]
tmtwd has joined #ocaml
creichert has quit [Remote host closed the connection]
ygrek has joined #ocaml
creichert has joined #ocaml
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Hetu has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
milosn has quit [Quit: Lost terminal]
milosn has joined #ocaml
freling has joined #ocaml
milosn_ has joined #ocaml
milosn has quit [Ping timeout: 244 seconds]
<ollehar> test
<ollehar> how hard would it be to program a static analyzer that uses type-inference for php, so a variable of type string can't be assigned ints?
<Drup> theblatte: are you around ? :)
milosn_ is now known as milosn
<theblatte> hey :)
<theblatte> oh, that's my cue
<theblatte> ollehar: http://hacklang.org/
<Drup> can you enlight ollehar :D
<ollehar> hacklang I know
<theblatte> ah :)
<ollehar> does it parse <?php too?
<theblatte> yes
<ollehar> but you have to explicit type : int etc
<ollehar> ?
<ollehar> I mean, it's just php if you don't use type hints, right?
<theblatte> yes, it leaves <?php alone and untyped, but <?hh //strict has to be typed
<ollehar> yeah
<ollehar> (btw, you know what "blatte" means in swedish? oO)
<theblatte> (blue or red?)
<ollehar> so I want my colleagues to be more type-safe, but without forcing hacklang upon them
<ollehar> myself, I'd love to use hacklang
<ollehar> but architecture, blah blah blah
<Drup> but, facebook is using it :D
<Drup> (also, I don't think you need to type the whole file, don't you ?)
<theblatte> Drup: you need to give type hints to all your functions
<Drup> hum, ok
<theblatte> if you don't that's fine too, but you won't get any guarantees
<theblatte> ollehar: I see what you mean, and the answer is that there is not such static analyzer right now. Of course typing the whole of php is impossible without hints, but maybe you can type the easy bits without going insane
<theblatte> with type inference I mean
<theblatte> the question is whether that would cover a pratically significant portion of the code you write
<ollehar> yeah, some basic stuff would be interesting to do
<ollehar> good point
<theblatte> and whether there is value in typing only parts of your code
<Drup> theblatte: how much of facebook's php code is covered with typing now ?
<ollehar> wait, if you don't use // strict, you can type-hint parts of it?
Hetu has quit [Ping timeout: 244 seconds]
<theblatte> Drup: I'd say a lot :)
<theblatte> ollehar: yep
<theblatte> <?hh defaults to // partial and accepts any (or almost iirc) <?php code
<ollehar> (and how f-cking awesome it is that one of the hacklang devs hang around here!!)
<theblatte> except that you can start using hack features such as datatypes
<theblatte> I'm not a hacklang dev :)
<ollehar> oh
<theblatte> but I work at fb
<ollehar> ah
<ollehar> with ocaml?
<theblatte> yes
<theblatte> on static analysis :)
<ollehar> infer?
<theblatte> yes :D
<ollehar> +1
<theblatte> Drup: We have deployed Hack at Facebook and it has been a great success. Over the last year, we have migrated nearly our entire PHP codebase to Hack, thanks to both organic adoption and a number of homegrown refactoring tools.
walter|r has quit [Remote host closed the connection]
<ollehar> didn't fb make a program to check types in javascript?
<Drup> interesting
<theblatte> ollehar: yes, that's flow
<theblatte> it uses more type inference, interestingly
<theblatte> you only have to spell out the type at module boundaries
<ollehar> cool
ggole_ has quit []
<ollehar> one useful thing could be to check for nulls, as in hack, but use function docs instead of type hints. also, function docs should be enforced.
<ollehar> maybe.
<theblatte> ollehar: so yeah, maybe you can convince your colleagues that it's ok for you to write types and they don't have to unless they want to change your code
<ollehar> as in "@return string|null@
<ollehar> -"
<theblatte> and sneakily convert more and more of the codebase to hack
<ollehar> theblatte: yeah, but for that I have to convince the hosts guys, project leader, what have you
<theblatte> then enjoy the better performances from hhvm since it knows the types
<ollehar> so, politics
<theblatte> (you guys use hhvm, right? ;)
<ollehar> a type-inferring linter would be easier.
<ollehar> nope, no hhvm.
<ollehar> I could try push it more.
<ollehar> if it works with typo3.
<ollehar> (don't ask)
<theblatte> (yeah, not going there)
<theblatte> it looks like typo3 wasn't 100% compatible with hhvm a year ago
<Drup> what is typo3 ?
<Drup> I feel like I'm going to be horrified, but my curiosity is too strong
<theblatte> Drup: it's still time not to learn anything about it
<Drup> Go on, I'm ready.
mcclurmc has joined #ocaml
<theblatte> it's a cms
<Drup> for now, I see nothing terrifying.
<theblatte> ah
<theblatte> my bad
<theblatte> well I've used it at a university and it was a very unpleasant experience
<Drup> ^^'
slash^ has quit [Read error: Connection reset by peer]
<ollehar> it's the qurkiest piece of software ever invented.
<ollehar> they made their own configuration language called typoscript
johnf_ has quit [Read error: Connection reset by peer]
<ollehar> parsed with regexp, I would assume, no lexer or stuff
<ollehar> the template engine, fluid, is also parsed with regexp.
mcclurmc has quit [Ping timeout: 265 seconds]
<ollehar> it's only big here in germany, basically.
<Drup> =')
<ollehar> very easy to make sql injection by mistake in typoscript
<ollehar> also, some horryfying security bug were discovered in an earlier version, due to messy function signatures.
<ollehar> one function could return 100, 200, false and something else
<ollehar> and then later, "if return_value > 100, let the user in"
<ollehar> but 200 is "not authorized"
<ollehar> stuff like that
lobo has joined #ocaml
<ollehar> I could go on
<Drup> That is quite amazing
<ollehar> still, typo3 is ok compared to the replacement framework started 10 years ago: neos.
<ollehar> oh well
<ollehar> we'll see what will happen
Hannibal_Smith has quit [Quit: Leaving]
<ollehar> anyway, I should read the code to flow et al
<ollehar> I could just steal the parser/lexer/ast from hacklang and then make my own evals, no?
<theblatte> hack and flow actually share some infrastructure too
<theblatte> all the stuff that makes them paralellisable basically
<ollehar> hm ok
<SomeDamnBody> I want to create an array of references...
<SomeDamnBody> I need to know how to tell ocaml that I want just a uninitialized reference...
<SomeDamnBody> do I do ref 0? or ref?
<Drup> an array of references, really ?
<flux> ref None
<SomeDamnBody> ah ok
<SomeDamnBody> Drup, well right now my program is leaking like hell
<SomeDamnBody> So I think that instead of initializing the array to contain a default item, having a reference will allow me to only allocate for what I need
<SomeDamnBody> because tons of the memory elements just represent duplicate items
<SomeDamnBody> I guess I could create an Array of optional you know, but...
<Drup> No, that's not going to work as you expect it
<SomeDamnBody> which, array of optional or array of ref?
<Drup> both, really
<SomeDamnBody> I'm not sure how you mean to be explaining it work work "as I expect it"
<SomeDamnBody> can I draw out how I think it would use memory
<SomeDamnBody> and then you clarify, that way we're certain? :)
<Drup> sure =)
<SomeDamnBody> Really my program is consuming so much memory that it eventually just runs out of swap and dies
<Drup> what is your program doing ?
<SomeDamnBody> I expect it to consume about 1.5 gigs, because that's what it really needs. Not 20 gigs
<SomeDamnBody> Well, basically, I have a 300 mb memory dump gathered from an analysis tool
<SomeDamnBody> I want to conservatively interpret at every byte offset what the data item could be, because we don't know which offset is correct
<SomeDamnBody> so, that would mean about 1.2 gigs, because it's 4 * 300mb
<SomeDamnBody> Which is fine. I don't care if I chew 2-3 gigs, I have space. It just needs to have the right complexity
<SomeDamnBody> anyway-
<Drup> can you show the program ?
<SomeDamnBody> I can successfully iterate over the array I create for that and initialize them all correctly, but in converting the array to a list, it eats all the memory
<SomeDamnBody> well, my program is part of some private code
<SomeDamnBody> but I think that I can slice off a piece of it and show it to you. I need to pretty much excise it so that others can use it, there are quite a few moving pieces, and I will have to basically test to make sure that it compiles and all in order to show you
<SomeDamnBody> that might take some time...
<SomeDamnBody> can I finish the explanation so that you can tell me how I'm wrong?
<SomeDamnBody> about how memory gets used in ocaml?
<Drup> sure
<rgrinberg> Drup: :D
<Drup> rgrinberg: It's one of these patch "CI is happy, hence it's correct".
<rgrinberg> lwt has quite a backlog with pr's
<rgrinberg> i should learn the internals a little better to help out :/
<Drup> I merge on the part I know, but not on the rest, and since nobody is actively working on things, it stays like that
<SomeDamnBody> ok thanks drup
<SomeDamnBody> anyway, I know that all arguments and names and stuff in ocaml are pass by reference
<Drup> SomeDamnBody: if an array of int is eating your memory, I don't see how an array of ref is going to be better, on the contrary
<SomeDamnBody> it's not an array of int
<SomeDamnBody> it's an array of { list * int }
<SomeDamnBody> so, that list could be empty, and the int be 0
<Drup> and how is that better than an array of list * int ?
<Drup> (introducing a ref)
<SomeDamnBody> (in the default case, and the default happens a lot for our analysis data)
<SomeDamnBody> well it's not going to be an array of list * int
<SomeDamnBody> it's array of (list * int) ref
<SomeDamnBody> and that ref is always one word size
<Drup> That's my question, how is "array of (list * int) ref" better than "array of (list * int)"
<SomeDamnBody> so, my thinking is, I'll save space by only having allocating for the times when I actually have something to put there
<Drup> "array of (list * int)" is already an array of pointer
<SomeDamnBody> oh I didn't know that
<SomeDamnBody> So could I save space by having array of (list * int) option?
<Drup> no, that would not save space
<SomeDamnBody> ok
<SomeDamnBody> well, I guess what I'll do is just try and slice off what I can so that I can let you look at it
<SomeDamnBody> would it help if I were just to quickly create a gist for it?
<Drup> sure, a gist is fine
<SomeDamnBody> or do you want something that compiles?
<Drup> it's not essential at first :p
<SomeDamnBody> ok
<ollehar> theblatte: btw, how come hacklang isn't waster than twice the speed of php?
<ollehar> *faster
<theblatte> ollehar: where did you get that number?
<ollehar> when the v8 jit for js is so much faster than, say, mozillas js engine (or it was?)
<ollehar> hm, good question
<theblatte> I'm not sure if spidermonkey is that much slower than v8 nowadays
<theblatte> ollehar: the 2x figure I find on google comes from migrating wikimedia to hhvm
<theblatte> note that they didn't make the switch to hack :/
<ollehar> hm ok
<theblatte> for a variety of reasons
<theblatte> so that's without types
<ollehar> faster than 2x, though
<adrien> theblatte: "mediawiki" is a word I'd use to scare my kids if I had any
<ollehar> hey, they dont use "// strict" in those tests :P
<ollehar> so strict hh is faster than partial?
<theblatte> ollehar: when you fall out of strict, you cannot trust your types anymore, so the jit misses some optimisations
<ollehar> ok
<ollehar> well, then the benchmarksgame should be updated.
<ollehar> :|
rgrinberg has quit [Ping timeout: 272 seconds]
obadz has quit [Ping timeout: 256 seconds]
ousado has quit [Read error: Connection reset by peer]
obadz has joined #ocaml
ousado has joined #ocaml
ousado has quit [Changing host]
ousado has joined #ocaml
mcclurmc has joined #ocaml
mcclurmc has quit [Ping timeout: 248 seconds]
Hannibal_Smith has joined #ocaml
tane has quit [Quit: Verlassend]
Onemorenickname has quit [Read error: Connection reset by peer]
ollehar has quit [Read error: Connection reset by peer]
ollehar has joined #ocaml
swgillespie has joined #ocaml
rgrinberg has joined #ocaml
Hetu has joined #ocaml
rgrinberg has quit [Ping timeout: 276 seconds]
mcclurmc has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
mcclurmc has quit [Remote host closed the connection]
obadz has quit [Ping timeout: 246 seconds]
amnn has joined #ocaml
Hetu has quit [Remote host closed the connection]
Kakadu has quit [Remote host closed the connection]
obadz has joined #ocaml
<ollehar> it should be possible to do a llvm binding for hacklang too, no?
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
mcclurmc has joined #ocaml
rgrinberg has joined #ocaml
lobo has quit [Quit: leaving]
<SomeDamnBody> is there a way to get the size of a given ocaml entity?
<SomeDamnBody> nevermind I foudn it
<zozozo> SomeDamnBody: just curious, but what did you find to get the size ?
<SomeDamnBody> Obj.size @@ Obj.repr some_named item
<Drup> that count pointer as ints
<SomeDamnBody> yeah I just checked it out in utop
<SomeDamnBody> I don't think that that's correct...
<SomeDamnBody> :)
<Drup> it's perfectly correct
<Drup> you should really read the link I gave you
<zozozo> SomeDamnBody: well if your value has a linked structure (such as a list), it will probably not give you what you expect
Sim_n has quit [Quit: Leaving]
mcclurmc has quit [Remote host closed the connection]
<zozozo> SomeDamnBody: if you want, I have a tool that outputs nice graph to show how values are represented in ocaml, that outputs things like : https://github.com/Gbury/ocaml-memgraph/blob/master/examples/test.svg
<SomeDamnBody> zozozo, wow that's pretty cool :)
<Drup> oh, it's working already ? :p
<zozozo> yup
amnn has quit [Remote host closed the connection]
<zozozo> but it's only designed to work on small inputs
<zozozo> else the graph simply gets too big
<zozozo> and the interface could be better
<zozozo> Drup: if you have any comments, do not hesitate, ^^
walter|r has joined #ocaml
<Drup> not right now
freling has quit [Quit: Leaving.]
profan has quit [Ping timeout: 252 seconds]
amnn has joined #ocaml
ollehar has quit [Quit: ollehar]
mcclurmc has joined #ocaml
dhil has quit [Quit: Leaving]
SomeDamnBody has quit [Ping timeout: 246 seconds]
SomeDamnBody has joined #ocaml
mlamari has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
<SomeDamnBody> Drup ah, I see that Table 20.1 in the link you sent me where it talks about the values that an OCaml program uses for each time
mcclurmc has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
amnn has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
amnn has joined #ocaml
mcclurmc has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
amnn has quit [Client Quit]
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
rgrinberg has quit [Ping timeout: 264 seconds]
rgrinberg has joined #ocaml
seanmcl has joined #ocaml