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
kdef has quit [Quit: Leaving]
<apache2> has anyone here got experiecne with using Apache Thrift in ocaml?
asQuirreL has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tinhead has quit [Remote host closed the connection]
larhat1 has joined #ocaml
tinhead has joined #ocaml
keen___________1 has joined #ocaml
keen___________0 has quit [Ping timeout: 265 seconds]
larhat has quit [Ping timeout: 272 seconds]
gabemc has joined #ocaml
jeffmo has quit [Read error: Connection reset by peer]
inf-groupoid is now known as pyon
klj has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
swgillespie has joined #ocaml
wraithm has quit [Quit: leaving]
Denommus has joined #ocaml
Denommus has quit [Max SendQ exceeded]
tinhead has quit [Remote host closed the connection]
codesmythe has joined #ocaml
Denommus has joined #ocaml
Denommus has quit [Max SendQ exceeded]
Denommus has joined #ocaml
Denommus has quit [Max SendQ exceeded]
Denommus has joined #ocaml
Denommus has quit [Max SendQ exceeded]
Denommus has joined #ocaml
Denommus has quit [Max SendQ exceeded]
Denommus has joined #ocaml
Denommus has quit [Max SendQ exceeded]
tg has joined #ocaml
Denommus has joined #ocaml
Denommus has quit [Max SendQ exceeded]
c74d has quit [Remote host closed the connection]
nullcat_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
c74d has joined #ocaml
hay207 has joined #ocaml
Denommus has joined #ocaml
mietek has quit [K-Lined]
mietek has joined #ocaml
hay207 has quit [Quit: Leaving]
sigjuice has quit [K-Lined]
sigjuice has joined #ocaml
c74d is now known as Guest90315
codesmythe has quit [Quit: Leaving.]
Guest90315 has quit [Ping timeout: 276 seconds]
c74d3 has joined #ocaml
c74d3 is now known as c74d
<Algebr> How can I typedef anonymous structs in ctypes?
struktured has joined #ocaml
shinnya has quit [Ping timeout: 265 seconds]
codesmythe has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
darkf has joined #ocaml
codesmythe has quit [Quit: Leaving.]
BitPuffin|osx has joined #ocaml
badkins has joined #ocaml
gabemc has quit [Ping timeout: 272 seconds]
ygrek has quit [Ping timeout: 256 seconds]
badkins_ has joined #ocaml
badkins has quit [Ping timeout: 246 seconds]
gabemc has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
mcclurmc_ has joined #ocaml
mcclurmc has quit [Read error: Connection reset by peer]
victoroak has joined #ocaml
<victoroak> ;topic
victoroak has quit [Client Quit]
psy_ has joined #ocaml
c74d has quit [Read error: Connection reset by peer]
<rgrinberg> Drup: how would i best type a dict of options in jsoo?
badkins_ is now known as badkins
<rgrinberg> e.g. a method that can be called like x.meth({ xx: "one", yy: "two" })
manizzle has quit [Ping timeout: 256 seconds]
c74d has joined #ocaml
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
idegen has quit [Quit: Leaving.]
<rgrinberg> nvm i think i got it.
<rgrinberg> binding to JS is madenning though
swgillespie has joined #ocaml
mietek has quit [K-Lined]
mietek has joined #ocaml
Algebr has quit [Remote host closed the connection]
MrScout has quit [Ping timeout: 256 seconds]
nullcat_ has joined #ocaml
BitPuffin|osx has quit [Ping timeout: 265 seconds]
Submarine has quit [Ping timeout: 252 seconds]
rgrinberg has quit [Ping timeout: 264 seconds]
manizzle has joined #ocaml
zaquest has quit [Ping timeout: 245 seconds]
zaquest has joined #ocaml
badkins has quit []
tmtwd has joined #ocaml
<l1x> hey guys, what is the easiest to use format to store nested data (text) on disk? like ruby -> yaml clojure -> edn etc.
Denommus has quit [Ping timeout: 255 seconds]
mcclurmc_ has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
<struktured> I used git cherry-pick for the first time. I'm going places
tinhead has joined #ocaml
Denommus has joined #ocaml
gabemc has quit [Ping timeout: 272 seconds]
MercurialAlchemi has joined #ocaml
tinhead has quit [Remote host closed the connection]
tinhead has joined #ocaml
siddharthv_away is now known as siddharthv
tinhead has quit [Remote host closed the connection]
tinhead has joined #ocaml
tinhead has quit [Remote host closed the connection]
tinhead has joined #ocaml
tinhead has quit [Ping timeout: 240 seconds]
Simn has joined #ocaml
zaquest has quit [Quit: Leaving]
Gama11 has joined #ocaml
tmtwd has quit [Quit: Leaving]
GeorgeHahn has joined #ocaml
tinhead has joined #ocaml
tinhead has quit []
tinhead has joined #ocaml
tinhead has joined #ocaml
kushal has joined #ocaml
rgrinberg has quit [Ping timeout: 256 seconds]
Drup has quit [Ping timeout: 252 seconds]
Drup has joined #ocaml
matason has joined #ocaml
ousado has quit [Ping timeout: 244 seconds]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ousado has joined #ocaml
vincenzoml has joined #ocaml
<vincenzoml> Hi there, I am still learning ocamlgraph, I have a custom graph and I would like to display it using neato; I see there is a Graphviz module, but I can not find how to actually "display" the file, e.g. using neato's "x11" driver
<vincenzoml> Any hint?
tinhead has quit [Remote host closed the connection]
oscar_toro has quit [Ping timeout: 256 seconds]
ousado has quit [Ping timeout: 264 seconds]
oscar_toro has joined #ocaml
rgrinberg has joined #ocaml
ousado has joined #ocaml
ousado has quit [Client Quit]
fds has joined #ocaml
rgrinberg has quit [Ping timeout: 245 seconds]
Haudegen has quit [Ping timeout: 258 seconds]
GeorgeHahn has quit [Quit: Leaving]
stux|RC-only has quit [Quit: Aloha!]
stux|RC-only has joined #ocaml
Haudegen has joined #ocaml
nullcat_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
asQuirreL has joined #ocaml
m___ has joined #ocaml
A1977494 has joined #ocaml
zpe has joined #ocaml
A1977494 has left #ocaml [#ocaml]
asQuirreL is now known as amnn
freling has joined #ocaml
dsheets has quit [Ping timeout: 256 seconds]
igitoor has quit [Ping timeout: 252 seconds]
igitoor has joined #ocaml
igitoor has joined #ocaml
igitoor has quit [Changing host]
stygianguest has quit [Ping timeout: 246 seconds]
zaquest has joined #ocaml
m___ has quit [Ping timeout: 246 seconds]
dsheets has joined #ocaml
zpe_ has joined #ocaml
rgrinberg has joined #ocaml
zpe has quit [Ping timeout: 244 seconds]
ingsoc has joined #ocaml
rgrinberg has quit [Ping timeout: 258 seconds]
kushal has quit [Ping timeout: 264 seconds]
oscar_toro has quit [Ping timeout: 245 seconds]
thomasga has joined #ocaml
kushal has joined #ocaml
kushal has quit [Read error: Connection reset by peer]
freling has quit [Quit: Leaving.]
manizzle has quit [Ping timeout: 244 seconds]
pyon has quit [Ping timeout: 245 seconds]
Kakadu has joined #ocaml
deavidsedice has quit [Ping timeout: 244 seconds]
sdothum has joined #ocaml
<Drup> vincenzoml: output a dot file and call dotty on it ? ^^'
<dsheets> how does one turn < m : 'a > into < m : 'a; .. >?
<dsheets> alternately, if I have: let o x = object method m = x end;; how can I make this function return an open object type?
deavid has joined #ocaml
<dsheets> The universal type variable 'r cannot be generalized: it is not a variable.
<Leonidas> is there a function that allows mapping over a string and supplies the mapper function with the int value of the characters?
<Leonidas> (which would hopefully be faster than just creating strings of length 1)
<Drup> String.map ? :|
<dsheets> let smap f = String.map (fun x -> f (Char.code x));;
sdothum has quit [Remote host closed the connection]
<Leonidas> oh. yes, indeed
<Leonidas> need to convert it back too, but yes perfect
<dsheets> # let x : [> `A ] = `A;; works as expected but # let x : < v : int; .. > = object method v = 3 end;; gives val x : < v : int > = <obj> :-(
mal`` has quit [Ping timeout: 265 seconds]
<Leonidas> thanks!
<Drup> dsheets: "let x : [> `A] : `A" doesn't work because of the annotation
<Drup> it works because `A is type openly by default
<flux> dsheets, that would amount to a polymorphic value, no?
<dsheets> sure, but i can manually close it
<dsheets> # let x : [ `A ] = `A;; val x : [ `A ] = `A
<Drup> dsheets: yeah but once close, you can't manually re-open it
kushal has joined #ocaml
inf-gropeoid has joined #ocaml
<Drup> # let x : [`A] = `A in (x :> [> `A]);;
<Drup> - : [ `A ] = `A
cml__ has joined #ocaml
<Drup> you are having the same issue with the object
<Drup> I remember seeing a trick to do that, but I can't remember it
<dsheets> indeed but i don't see why the ability to create an open object is bad
sdothum has joined #ocaml
<Drup> wait
<Drup> creating an object of type "< m : 'a ; .. >" is wrong
<Drup> you could call any method on it ...
<Drup> that's just completely wrong, why do you want to do that ?
<dsheets> no more wrong than having [] with type "'a list". you could map any type of function over it
<dsheets> but yes, it does seem to fight variance
<Drup> except list is immutable
sdothum has quit [Client Quit]
<Drup> an object may not be
<dsheets> bah, so are my objects
<flux> there are no 'a objects in the list
<Drup> yeah but the type doesn't show that
<flux> but you are now creating an object that is ~~ 'a
<flux> you cannot have non-empty list with type 'a list
<dsheets> 'a constraint 'a = < m : int; .. >
mal`` has joined #ocaml
<Drup> yeah, that's ok, what about it ?
<dsheets> that's exactly the same type?
<Drup> but that's not a value, that's a type variable
<dsheets> a type variable of the return type of a function
<Drup> *return* type ? not input type ?
<dsheets> yes, it seems impossible to write a constructor function with type unit -> < m : int; .. >
<Drup> well, yeah, as I said, unsafe
<dsheets> 'a. unit -> < m : int; .. > as 'a
TheLemonMan has joined #ocaml
<Drup> (I'm still wondering why, though)
Haudegen has quit [Ping timeout: 240 seconds]
<dsheets> i'd not like my consumers to assume they know the structure of the object
<dsheets> but perhaps just an object is good enough
<flux> let's say 'a' was an instance of your proposed type. what wold a#foo then do?
<Drup> more important, I can do that : "a#foo <- 3 ; print_string a#foo"
<dsheets> a#foo is a type error
<dsheets> the object type is universal with a constraint
<Drup> not in the way you wrote it :3
<flux> dsheets, this is valid ocaml: let x : < v : int; .. > -> <v : int; b : int> = fun x -> x;;
<dsheets> 'a. unit -> < m : int; .. > as 'a ==> 'a. unit -> 'a constraint 'a = < m : int; .. >
sdothum has joined #ocaml
<flux> oh, never mind, I was missing the quantifier :)
<flux> but right, after I add it it no longer typechecks
<Drup> right, I'm not sure how you are going to use that, but ok.
<dsheets> well, i don't want people writing the type < m : int > because it may gain methods
<dsheets> but perhaps that's their own fault if they do
<Drup> just provide a type alias and use it everywhere ? :|
<dsheets> I have a type alias but i made it type ('a, 'r) t = < value : 'a; .. > as 'r which is impossible to instantiate
octachron has joined #ocaml
<flux> let foo (x:(_, _) t) = fun t -> t#a + t#b * t#c :-)
<Drup> dsheets: avec you considered using a class type ? :3
<vincenzoml> Drup: is that "the" answer? I mean: is the neato module in GraphViz only capable of writing a dot? I somewhat expected that it had also the other functionalities of neato
<dsheets> Drup, no... do I gain something there?
<Drup> vincenzoml: why reimplement what neato is doing just fine ? it's a complicated algorithm
<flux> he didn't mean reimplementing neato, but it has many features. not sure if the GraphViz module exposes them all.
<flux> in fact I remember at some point it didn't even properly quote input strings
<Drup> ah yeah
<Drup> no, it doesn't, I started a patch for that and never finished it
<Drup> dsheets: class type ['a] t = object method x : 'a end ;;
<Drup> t is the type you would expect
<Drup> #t is the open version
<dsheets> oooo i forgot about this... only considered for polymorphic variants
<vincenzoml> Drup: I think I did not explain myself correctly. As the Graph.Graphviz.Neato module is an interface to neato (it even has a way to set the neato command line) I expected that it not only can use neato for layouting and outputting a dot file, but also to change the driver and show the graph on screen, or e.g. output a pdf
<Enjolras> hi
<Enjolras> Anyone knows a trick to make vim happy with generative functors ?
<Enjolras> the coloration is totally broken
<Drup> vincenzoml: yeah, actually no, it just compose a .dot
<Drup> dsheets: it's funny, since it's deprecated for poly variants :3
<dsheets> really?! when?
<vincenzoml> Drup: so yes I fully agree with you, that I want to use neato, but even more, I want to use the already implemented code to interface ocaml and neato, which I thought to bethe graphviz module of ocamlgraph
<Drup> dsheets: in type signature
matason has quit [Ping timeout: 272 seconds]
<Drup> not in pattern match
<dsheets> oh
<vincenzoml> Ah sorry Drup I did not see your answer
<vincenzoml> drup: ok, that clarifies it
* vincenzoml wonders why freenode webchat does not automatically scroll down
<Drup> vincenzoml: I think here is a .dot viewer somewhere, though
<Drup> but it's not directly in ocamlgraph
<Enjolras> I don't even know what is handling ocaml coloration in vim :/
<vincenzoml> Drup: ok, thanks. And also I have seen wonderful graph viewers on the js_of_ocaml web site, and in the end I think I will also try that route, for the sake of it
<Drup> (but it will use the neato binary anyway)
<vincenzoml> Drup: there is Viewgraph_core in ocamlgraph, but as far as I can see it's either gtk or labltk and that may destroy portability.
<TheLemonMan> Enjolras, /usr/share/vim/vim74/syntax/ocaml.vim
<Enjolras> (ok, i found a solution, i installed vim-ocaml plugin instead of distributed ocaml syntax file)
<Drup> you wanted to both open a visualization *and* be portable ? in which universe is that possible ? :D
<Enjolras> TheLemonMan: thanks. Yeah looks like it's not up to date, but https://github.com/rgrinberg/vim-ocaml works fine
<Drup> vincenzoml: there is something in the dgraph directory in the ocamlgraph sources
<TheLemonMan> Enjolras, thanks for the link :) it'd be nice to have some of the changes backported to the upstream version
<Enjolras> it will probably be. I guess the vim version is just lagging a bit behind
Haudegen has joined #ocaml
<reynir> Do you use ocp-indent with vim?
<reynir> I'm not sure how to disable /usr/share/vim/vim74/indent/ocaml.vim while using ocp-indent. Currently I just delete the content of the file, but it obv. breaks on each update :/
<Enjolras> not sure. I've the ocp-indent plugin enabled but i've not check it is actually used instead of ocaml.vim
ggole has joined #ocaml
freling has joined #ocaml
rgrinberg has joined #ocaml
thomasga has quit [Quit: Leaving.]
The_Mad_Pirate has quit [Excess Flood]
rgrinberg has quit [Ping timeout: 272 seconds]
The_Mad_Pirate has joined #ocaml
vincenzoml has quit [Quit: Page closed]
oscar_toro has joined #ocaml
michael_lee has joined #ocaml
michael_lee has quit [Read error: Connection reset by peer]
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
sdothum has joined #ocaml
psy_ has quit [Read error: Connection reset by peer]
sepp2k has joined #ocaml
amnn has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jgjl has joined #ocaml
k1000 has quit [Ping timeout: 240 seconds]
siddharthv is now known as siddharthv_away
Hannibal_Smith has joined #ocaml
Algebr has joined #ocaml
<Algebr> Is it possible to know in code at runtime whether the code was natively compiled or running as bytecode?
k1000 has joined #ocaml
<adrien_znc> yes
<Algebr> How?
<adrien_znc> that's a different question :D
<adrien_znc> iirc there's a value somewhere in a module but I don't remember in which
<Algebr> not sure if this is false hope
<dmbaturin> Algebr: How will you use this knowledge?
<dmbaturin> Out of curiousity, I don't remember where is it either (but I bet I've seen it somewhere).
<flux> actually the code can be executed differently depending on that
<Drup> read the binary and see if it starts with #!.../ocamlrun :D
<flux> wasn't foo (a := 1) (a := 2) one of those case?
<Drup> flux: that was changed iirc
<Drup> and it's implementation dependent anyway, so it could change
<Algebr> I'm having trouble correctyl compiling bytecode for a ctypes based project. I get the invocation through without error but at runtime I get an exception of a DL_error. I can compile and execute native code just fine. I think I have a fix for this DL_error, I can load the file at runtime, but I need this code to only go off if its been compiled as bytecode.
<adrien_znc> that sounds dirty
<Algebr> its a solution.
<Drup> wouldn't be simpler to actually solve the underlying problem by asking the competent people instead of trying some ugly voodoo ?
<adrien_znc> a flamethrower would also get rid of the bug
k1000 has quit [Remote host closed the connection]
nicoo has quit [Ping timeout: 244 seconds]
k1000 has joined #ocaml
<Algebr> Drup: Okay, how can I get this to work correctly for ocamlc. I'm calling ocamlfind ocamlc -package ctypes.foreign,uri -cclib libgit2.0.22.0.dylib -linkpkg git.ml
<Algebr> which does give me a .cmo, but at runtime blows up.
<Drup> No idea, ask on the mailing list
<Drup> (and do you have a reason not to use ocaml-git ?)
<Algebr> no
<Algebr> just wanted to do ctypes really.
thomasga has joined #ocaml
freling has quit [Quit: Leaving.]
nicoo has joined #ocaml
idegen has joined #ocaml
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
sdothum has joined #ocaml
<reynir> there are functions in Sys to check if it's interactive, byte order etc, but it seems there's no bytecode check
tmtwd has joined #ocaml
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
psy_ has joined #ocaml
psy_ has quit [Max SendQ exceeded]
psy_ has joined #ocaml
Algebr has quit [Ping timeout: 244 seconds]
Algebr has joined #ocaml
rgrinberg has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
rgrinberg has quit [Ping timeout: 272 seconds]
_andre has joined #ocaml
<vbmithr_> val hypot : float -> float -> float
<vbmithr_> hypot x y returns sqrt(x *. x + y *. y), that is, the length of the hypotenuse of a right-angled triangle with sides of length x and y, or, equivalently, the distance of the point (x,y) to origin.
<vbmithr_> Since 4.00.0
<vbmithr_> lol
<vbmithr_> Who said the standard library was incomplete
<adrien_znc> since 4.00.0
klj has quit [Quit: ZZZzzz…]
<MercurialAlchemi> good grief
<vbmithr_> yeah, ocaml users had to live for all this time without the hypot function
<MercurialAlchemi> yes, I suppose that's a matter of getting one's priorities right
<vbmithr_> :)
<flux> well, I think it's been a lot easier to live without the hypot function, than without the pi constant :-)
<flux> though it has taught me the easy way to calculate it
<adrien_znc> vbmithr_: most likely it's because this function has a good SSE2/x87 implementation
mort___ has joined #ocaml
<flux> it now occurs to me that all these years I've used the lame-ass sqrt(..) way in C(++) as well
<flux> #ocaml is really an educational channel ;-)
<reynir> 22/7? :D
<reynir> 22. /. 7., of course
arj has joined #ocaml
<flux> for the sake of education: let pi = atan 1.0 *. 4.0
<vbmithr_> adrien_znc: ha, probably
<flux> I don't know but perhaps it gives you a slight precision advantage if you make that a function?
<Armael> or just learn the 10-20 first digits :]
<zozozo> flux: why not acos (-1.) ?
<adrien_znc> atan
<flux> no idea, that's the way others before me have done it ;-).
<zozozo> multiplying by 4 probably makes you loose some precision
<zozozo> by the way, it is really strange to see the documentation mentioning pi, but not defining it ...
<flux> the difference after subtraction is 0, though
<flux> but I suppose I might still lose internal precision
<flux> I wonder if calculating acos (-1.0) might be more involved than atan 1.0?
<flux> being an 'edge' value
<flux> or more easy, being one :)
<zozozo> we should micro-benchmark acos and atan to check, :p
<flux> we should also measure CPU power consumption
<zozozo> and memory usage ?
<adrien_znc> cache effect
BitPuffin has joined #ocaml
seanmcl has joined #ocaml
freling has joined #ocaml
inf-gropeoid has quit [Ping timeout: 264 seconds]
hay207 has joined #ocaml
klj has joined #ocaml
thomasga has quit [Quit: Leaving.]
kdef has joined #ocaml
mcclurmc has joined #ocaml
struk|work has joined #ocaml
helix has joined #ocaml
<vbmithr_> is string_of_float the strict inverse of float_of_string ?
<vbmithr_> .. of course not
<zozozo> vbmithr_: when does it differ ?
A1977494 has joined #ocaml
<reynir> string_of_float (float_of_string "1.00000") ---> "1."
<vbmithr_> yeah…
<vbmithr_> basically I have one problem
<vbmithr_> I want to convert a string representing a float to a int
<vbmithr_> Like "1.23456789" -> 123456789
<vbmithr_> I want to find a method that guarantees that I will end up with the right digits
<vbmithr_> Oh, and additional requirement, I have actually a float, not a string
<vbmithr_> I have a = float_of_string "1.23456789" and I want 123456789
A1977494 has left #ocaml [#ocaml]
badkins has joined #ocaml
<vbmithr_> frexp ?
<theblatte> vbmithr_: take (string_of_float a) and remove the "." yourself, then int_of_string it?
<vbmithr_> Yeah, only if string_of_float @@ float_of_string s = s
<theblatte> and pick something sensible for NaN, etc.
<vbmithr_> There won't we NaN
<vbmithr_> The string is [0-9]+\.[0-9]+
rgrinberg has joined #ocaml
<Algebr> So Result.t was accepted. What if you want to use it now without using a libraruy?
<Algebr> library
<vbmithr_> utop # string_of_float @@ float_of_string "2345678.343434";;
<vbmithr_> - : bytes = "2345678.34343"
<vbmithr_> out of precision already… ?!
<theblatte> correct me if I'm wrong, but wouldn't string_of_float sometime give you the nearest representable float instead of the one in the string anyway?
<vbmithr_> yeah of course
<theblatte> then I don't understand the semantics of your operation :)
<vbmithr_> I'm not controlling the float_of_string thing.
<vbmithr_> I use ppx_deriving_json to parse json from the internet
<vbmithr_> so I end up with an ocaml float value
<flux> vbmithr_, maybe a better idea to put a special type to those fields and have your own json parser
<vbmithr_> yeah
<flux> though, I'm not actually sure if it will help!
<vbmithr_> I wanted to avoid writing more code
<flux> because the json tree uses floats itself already?
<vbmithr_> yes
<flux> it has special handling when it sees 'too big' integers, but I bet nothing for floats
<vbmithr_> yojson parses json decimal as float
<flux> too smaht :/
<vbmithr_> I see there is a `Floatlit variant but not sure when it's used
<flux> it could be use always in this scenario
<flux> try and see :)
<flux> sadly the code of json with its creative use of C preprocessor isn't the most readable in the world..
<flux> code of yojson that is
<vbmithr_> I assume it float_of_string them
<flux> in this case, I suggest not to assume anything :)
<vbmithr_> you're right :)
<vbmithr_> utop # string_of_float @@ float_of_string "2419.78640896";;
<vbmithr_> - : bytes = "2419.78640896"
<vbmithr_> This works
<vbmithr_> utop # string_of_float @@ float_of_string "2345678.343434";;
<vbmithr_> - : bytes = "2345678.34343"
<vbmithr_> But not this.
<flux> so I guess you see how the only solution is not going via float in the first place?
<flux> I would think there are other situations as well..
<vbmithr_> ok, 12 maximum digits ?
<vbmithr_> yeah.
<flux> ie. 2345678.999999
<vbmithr_> I seems that as long as the number is not more than 12 numbers is works
<flux> and aren't the disappearing trailing zeroes already a problem?
<vbmithr_> No, I don't care about those
gabemc has joined #ocaml
<flux> so you take the . out of that and get an integer. what use could this have :-)
<vbmithr_> Basically I want to keep those numbers, that have all a certain amount of significative numbers, into an int
inf-gropeoid has joined #ocaml
<Drup> vbmithr_: did you consider, I don't know, using zarith ?
<vbmithr_> Haha, I'll have a look
<vbmithr_> now
<flux> basically, zarith for manipulating a string.. sounds like overkill to me :-)
ski has quit [Remote host closed the connection]
<Drup> why do people keep saying "overkill" about libraries that are installed on everyone's machine and that are not even that big ?
<vbmithr_> I'd like to be sure I _understand_ my problem in the first place
freling has quit [Quit: Leaving.]
<Drup> flux: using a theorem prover to format string is overkill, that is still basically what you are doing everytime you are using Printf.
<flux> yes, running programs is proving theorems indicateed by types :)
inf-gropeoid has quit [Ping timeout: 255 seconds]
<flux> drup, how does zarith solve this issue anyway?
<Drup> it will get rid of the imprecision issues, wasn't that the main issue ?
<vbmithr_> utop # Yojson.Safe.from_string "{\"Bleh\": 716038.35679345}";;
<vbmithr_> - : Yojson.Safe.json = `Assoc [("Bleh", `Float 716038.35679345)]
<vbmithr_> At least the float doesn't get borked by Yojson when it stays a float
<flux> drup, the problem is that the precision is limited in the first place
<vbmithr_> So, basically, float_of_string works when the string represent a number that fits the precision of a float
<flux> vbmithr_, but that's quite unfortunate
<vbmithr_> what's unfortunate ?
shinnya has joined #ocaml
<flux> that yojson.safe discards precision so early in the pipeline
<vbmithr_> Jsonm does the same
<vbmithr_> JSON numbers are represented with OCaml float values. This means that it can only represent integers exactly in the in the interval [-253;253]. This is equivalent to the contraints JavaScript has.
<flux> maybe it should have code like: if string_of_string floatified <> original then `FloatLit
<vbmithr_> (2^53 obviously)
<flux> ah well, that's a good point, that JavaScript is the limiting factor here
<vbmithr_> yes
<flux> so your problem remains converting the number as precisely as possible to a string. maybe zarith indeed can help there :-)
<vbmithr_> yes
<flux> though I must wonder what does OCaml use for displaying floats
<flux> if not string_of_float or its friend
leafac has joined #ocaml
<vbmithr_> If I multiply a float by 1e<something> I do not affect the precision
<vbmithr_> The thing that worries we is that I had a problem, before.
<vbmithr_> Doing exactly that
<vbmithr_> utop # int_of_float @@ 1e8 *. float_of_string "2.030000";;
<vbmithr_> - : int = 202999999
<vbmithr_> HERE we go ! :)
<vbmithr_> Can someone explain this ?
<vbmithr_> My string has not many significative numbers
<octachron> vbmithr_: doesn't that work exactly only for multiplying by multiples of 2?
<vbmithr_> maybe, I don't know
<octachron> digits are not a very natural notion for real numbers
<vbmithr_> I definitely need Zarith
<Drup> do you need that piece of code to run in js ?
<vbmithr_> NO :)
<vbmithr_> I needed js to use a nodejs libraryr
<Drup> good
<Drup> (it's technically possible to run zarith in js, since we already have a replacement for big_int, but nobody did a nice package for it just yet)
thomasga has joined #ocaml
<vbmithr_> The thing I must avoid absolutely is to perform any computation on the float I get
<vbmithr_> so the only thing I can do with it is to retransform it in a string
<vbmithr_> from a string I can do whatever I want
<vbmithr_> Ok, I think I understand
<vbmithr_> string_of_float @@ float_of_string s = s iff s can be exactly represented in a float
<cml__> I use Uri.of_string "http://webpage.com:8080", and when i run my code, I get the error: unknown scheme. anyone knows the problem? (without http, I get "no scheme")
<vbmithr_> bug somewhere
<vbmithr_> Uri.of_string with your provided string works here
<vbmithr_> Ok, thanks guys.
<dsheets> cml__, need to see your code
cml__ has quit [Ping timeout: 246 seconds]
octachron has quit [Quit: Leaving]
darkf has quit [Quit: Leaving]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
Algebr has quit [Remote host closed the connection]
Denommus has quit [Ping timeout: 258 seconds]
rgrinberg has quit [Ping timeout: 240 seconds]
hay207 has quit [Quit: Leaving]
rgrinberg has joined #ocaml
amnn has joined #ocaml
<tobiasBora> Hello !
<tobiasBora> I would like to know, is it less efficient to use objects rather than classic types or is it the same ?
<Drup> by classic types, you mean record ?
<Drup> then yeah, it's less efficient
<tobiasBora> Yes for example
<tobiasBora> Is the difference "important" or is it something like 1.2 times slower ?
<Drup> I don't have the numbers in memory, but yeah, it's important
<tobiasBora> Because objects are really powerfull (and it's often easier to use since there is no more need to give a namespace)
<tobiasBora> and I was curious to know why I cannot see lot's of places where objects are used
<tobiasBora> It's the same thing with methods I guess ? For example if an object has a method "close", it will be slower to do myobj#close rather than close myobj ?
mort___ has left #ocaml [#ocaml]
<vbmithr_> tobiasBora: There are lots of things that you can do without objects in OCaml
<Drup> tobiasBora: you shouldn't let that prevent you to use object if it's better for your use case, the speed is unimportant in most usages compared to the other factors
<Drup> (like, say, the time to actually close the window in your windows manager ...)
<tobiasBora> vbmithr_: I know, but I think it's longer to write. I'm coding in python for my internship (not my choice but it's powerfull and easy to use for scripting) and it's easier to code in object view because you don't need to provide a full list of argument to the function, you don't need to remember the order of the arguments, you don't need to give the name of the module you are using every time you call a
<tobiasBora> function... And really it's practical !
<tobiasBora> Drup: Ok thank you for your advices !
* tobiasBora has to go but will read any answer later
<Drup> those are actually rather poor arguments.
matason has joined #ocaml
<Drup> 1 and 2 are solved by labels
<Drup> 3 ... well, there is no problem to begin with
helix has quit [Disconnected by services]
slash^ has joined #ocaml
inf-gropeoid has joined #ocaml
badkins has quit []
<vbmithr_> Yeah, the objects are not intended to solve the problem you mention
<vbmithr_> The thing that objects are really useful at is inheritance
<vbmithr_> You can include a module in another module, but you cannot easily emulate the behaviour of inheritance with modules
<vbmithr_> Personally I don't use objects because I don't understand them well :)
kushal has quit [Ping timeout: 240 seconds]
Hannibal_Smith has joined #ocaml
MrScout has joined #ocaml
zpe_ has quit [Remote host closed the connection]
shinnya has quit [Ping timeout: 255 seconds]
ggole has quit [Ping timeout: 256 seconds]
freling has joined #ocaml
Denommus has joined #ocaml
BitPuffin has quit [Read error: Connection reset by peer]
jonludlam has quit [Ping timeout: 272 seconds]
tinhead has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
nullcat has joined #ocaml
psy__ has joined #ocaml
tinhead has quit [Remote host closed the connection]
helix__ has joined #ocaml
shinnya has joined #ocaml
tinhead has joined #ocaml
tinhead has joined #ocaml
psy_ has quit [Read error: Connection reset by peer]
psy__ has quit [Read error: Connection reset by peer]
psy_ has joined #ocaml
psy_ has quit [Max SendQ exceeded]
psy_ has joined #ocaml
Algebr has joined #ocaml
The_Mad_Pirate has quit [Excess Flood]
The_Mad_Pirate has joined #ocaml
freling has quit [Quit: Leaving.]
ygrek has joined #ocaml
dsheets has quit [Ping timeout: 256 seconds]
The_Mad_Pirate has quit [Max SendQ exceeded]
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
The_Mad_Pirate has joined #ocaml
Hannibal_Smith has joined #ocaml
rgrinberg has quit [Ping timeout: 246 seconds]
kushal has joined #ocaml
kushal has quit [Changing host]
kushal has joined #ocaml
gabemc has quit [Ping timeout: 258 seconds]
dsheets has joined #ocaml
badkins has joined #ocaml
<Algebr> Is there a way to say in ocamlfind's findlib setup that whenever someone uses my package that I want to include a -cclib argument?
<tobiasBora> I know that it's not the goal of objects, and that inherance is really nice (and in Ocaml I think that since the objects type is very flexible it's possible to do much more flexible code with them).
<tobiasBora> but when you want to use a langage for scripting (Ocaml can be used with script) you want a syntax as clear and short as possible
<tobiasBora> and objects can be an interesting solution
inf-gropeoid has quit [Quit: fix config]
badkins has quit []
<tobiasBora> The labels that you mention are pretty long to write
<tobiasBora> and write a word in front of every single function isn't really concise
<Drup> "~foo:foo" can be shorten ~foo
inf-gropeoid has joined #ocaml
Kakadu has quit [Quit: Page closed]
Submarine has joined #ocaml
Simn has quit [Ping timeout: 276 seconds]
<tobiasBora> It's right it's practical, but sometimes it's not possible to use it. And another thing nice with objects : with utop you can easily get all the methods that you can use with an object
<tobiasBora> By the way is there a way to ask it in one line ? (For the moment I do "a;; ==> unit -> myobj = <fun> #show_class myobj"
thomasga has quit [Ping timeout: 258 seconds]
rgrinberg has joined #ocaml
jonludlam has joined #ocaml
robink has quit [Ping timeout: 248 seconds]
<Algebr> does ocamllabs have any plans for overhauling ocamlfind
thomasga has joined #ocaml
robink_ has joined #ocaml
mort___ has joined #ocaml
freling has joined #ocaml
robink_ is now known as robink
Anarchos has joined #ocaml
jeffmo has joined #ocaml
sh0t has joined #ocaml
kdef has quit [Quit: Leaving]
kdef has joined #ocaml
<sh0t> guys please: before I go crazy what's the error here? http://paste.ubuntu.com/11416871/ it just says syntax error
<sh0t> (sorry i started with ocaml today...)
<Drup> sh0t: it's "and"
<Drup> not "and let rec"
<Drup> or you remove the "and"
<sh0t> i can't remove the and
<sh0t> cause otherwise i can't call the previous funciton...but
<sh0t> if i remove
<sh0t> rec it still doesn't work
<Drup> the syntax for mutual recursive binding is "let rec ... and ... and ..."
<Drup> the rec is on the first "let", not in the middle :)
<sh0t> ah! ok let me try
mort___ has quit [Ping timeout: 256 seconds]
Kakadu has joined #ocaml
<sh0t> Drup, http://paste.ubuntu.com/11416986/ it doesn't work
<sh0t> can u please check it out again?
tinhead has quit [Remote host closed the connection]
<struk|work> sh0t: remove the "let"s before the "and"
mort___ has joined #ocaml
<struk|work> sorry I mean after the ande
<sh0t> ok struk|work
<sh0t> thanks
tinhead has joined #ocaml
tinhead has quit [Remote host closed the connection]
gabemc has joined #ocaml
nullcat has joined #ocaml
amnn has quit [Ping timeout: 264 seconds]
amnn has joined #ocaml
rgrinberg has quit [Quit: WeeChat 1.1.1]
jpdeplaix` has quit [Quit: WeeChat 0.4.0]
matason has quit []
mort___ has left #ocaml [#ocaml]
slash^ has quit [Read error: Connection reset by peer]
inf-gropeoid is now known as inf-groupoid
tinhead has joined #ocaml
badkins has joined #ocaml
lordkryss has joined #ocaml
tinhead has quit [Remote host closed the connection]
Simn has joined #ocaml
manizzle has joined #ocaml
Cyanure has joined #ocaml
TheLemonMan has joined #ocaml
tinhead has joined #ocaml
zaquest has quit [Ping timeout: 264 seconds]
ollehar has joined #ocaml
badkins has quit []
ousado has joined #ocaml
ousado has joined #ocaml
natrium1970 has joined #ocaml
<natrium1970> I was checking the performance of three variations of some code, and I noticed some surprising differences. http://pastebin.com/qWB6BLYN. The functions f1, f2, and f3 conditionally pop items from the stack, each with the condition done differently. Is the performance difference likely due to polymorphic comparison?
Submarine has quit [Quit: Leaving]
_andre has quit [Quit: leaving]
ygrek has quit [Ping timeout: 246 seconds]
ousado has quit [Ping timeout: 276 seconds]
<struk|work> natrium1970: not that I have a clue, but I'd like to see it anyhow..can u paste to gists or paste.ubuntu.com?
<natrium1970> I pasted a link in the text above. http://pastebin.com/qWB6BLYN
<natrium1970> I can do it at paste.ubunto.com, if you give me a sec.
ousado has joined #ocaml
ousado has quit [Changing host]
ousado has joined #ocaml
<natrium1970> Pardon the clumsy timing code. I don’t know a more elegant method.
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nullcat has joined #ocaml
<zozozo> natrium1970: polymorphic comparison is indeed significatively slower than int comparison
ousado_ has joined #ocaml
<natrium1970> I knew that part, but the interesting part is that f1 and f3 are about the same speed, but f2 is much slower. However, if the type assertion for f3 is left out, it is slow as well.
<natrium1970> My question is how do I know when polymorphic comparison will be used, and how can I force a type-specific one.
ousado has quit [Ping timeout: 265 seconds]
matason has joined #ocaml
ousado_ is now known as ousado
ousado has quit [Changing host]
ousado has joined #ocaml
Cyanure has quit [Remote host closed the connection]
<zozozo> natrium1970: in f1, the inferred type 'a stack -> ('a -> 'a) -> unit, so when you apply it to (fun x -> x > 5) the (>) operator knows its argument to be integers, so the specialized function is used
<zozozo> basically, if you can statically infer that at least one of the argument of the comparison is int, the specialized comparison will be called
<zozozo> sorry, the inferred type of f is 'a stack -> ('a -> bool), and it doesn't really matter for my explanation, :p
<natrium1970> So it’s because of the constant 5 in (fun x -> x > 5) that it is able to use int comparison, but when passing (>) as a function, there is nothing to indicate that types will be compared?
<struk|work> natrium1970: just annotate with types when you want to enforce it, I guess. Perhaps functors are faster too, not sure though
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Submarine has joined #ocaml
Submarine has joined #ocaml
<natrium1970> How can I obtain a greater-than function specific to integers?
nullcat has joined #ocaml
<natrium1970> let gt : int -> int -> bool = (>) does not seem to do it.
<zozozo> natrium1970: let gt (x:int) (y:int) = x > y
<natrium1970> Hmm. Passing gt as you indicated slightly improves the performance of f2, but not that much.
<natrium1970> Perhaps there are other things in play that make f2 slower. I don’t mean to make a big deal out of this, but it’s something I’ve wondered about in general cases before.
thomasga has quit [Quit: Leaving.]
ollehar has quit [Ping timeout: 272 seconds]
<Algebr> Say you have this pattern .... A a -> a | B a -> a | C a -> a and so on. How do you match on all of them at once? naive me tried _ a -> a, but that didn't work
Anarchos has quit [Remote host closed the connection]
ygrek has joined #ocaml
<theblatte> Algebr: A a | B a | C a -> a
<Algebr> I'm saying I don't want to type all that out.
<apache2> use objects/classes and :>
<apache2> :P
<Algebr> heh
kushal has quit [Quit: Leaving]
<theblatte> Algebr: doesn't look like you can do better than avoiding the repeat of -> a : http://askra.de/software/ocaml-doc/3.12/full-grammar.html#pattern
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<nicoo> Algebr: You cannot with OCaml's ADT & pattern-matching syntax
<nicoo> Ask gashe to put let-patterns in the next release :>
<theblatte> (ugh, that's a weird and outdated link actually)
<natrium1970> Do you need to handle A, B, and C frequently with the same branch in a match, or is it just one case?
ingsoc has quit [Ping timeout: 265 seconds]
MercurialAlchemi has quit [Ping timeout: 272 seconds]
thomasga has joined #ocaml
<Algebr> Its the same over and over, think A..Z, all of which wrap a string.
tinhead has quit [Remote host closed the connection]
leafac has quit [Quit: Leaving.]
jabesed has joined #ocaml
Simn has quit [Quit: Leaving]
tinhead has joined #ocaml
struk|work has quit [Quit: Page closed]
natrium1970 has quit [Quit: natrium1970]
Anarchos has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
jwatzman|work has joined #ocaml
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
tg has quit [Ping timeout: 255 seconds]
Haudegen has quit [Ping timeout: 250 seconds]
<apache2> then you can have a function that normalizes them
<dsheets> use gadts
<dsheets> 'a constr * 'a where 'a constr is a gadt carrying 'a but with all constructors as nullary (A, B, C, etc)
<dsheets> wait never mind, that's a horrible idea for this problem
tinhead has quit [Remote host closed the connection]
tinhead has joined #ocaml
tinhead has joined #ocaml
<tobiasBora> Bonsoir !
<tobiasBora> Hello !
<Anarchos> salut tobiasBora
<tobiasBora> I have a little question : I would like to configure the file myocamlbuild.ml with a little modifier dispatcher (it just do some things before the option configuration)
<tobiasBora> however I am already using this one : https://ocsigen.org/eliom/manual/workflow-compilation#h5o-3
<tobiasBora> and I don't know how to mix them...
freling has quit [Quit: Leaving.]
tg has joined #ocaml
Gama11 has quit [Remote host closed the connection]
Haudegen has joined #ocaml
helix__ has left #ocaml [#ocaml]
obadz has quit [Ping timeout: 255 seconds]
Haudegen has quit [Ping timeout: 250 seconds]
obadz has joined #ocaml
<struktured> vbmithr_: I use zarith when I truly care about precision
seanmcl has joined #ocaml
klj has quit [Quit: ZZZzzz…]
Algebr has quit [Remote host closed the connection]
Kakadu has quit [Remote host closed the connection]
gabemc has quit [Ping timeout: 265 seconds]
jabesed has quit [Ping timeout: 265 seconds]
<tobiasBora> I finish by editing my dispatcher to run the eliom's one just after mine. It seems to work pretty well.
<tobiasBora> (I mean after each hook I run the eliom's dispatcher)
Haudegen has joined #ocaml
tinhead has quit [Remote host closed the connection]
jabesed has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
swgillespie has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
badkins has joined #ocaml
idegen has quit [Remote host closed the connection]
idegen has joined #ocaml
matason has quit []
klj has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]