wagle has quit [Read error: Connection reset by peer]
emmanuelux has quit [Ping timeout: 248 seconds]
tbrady has joined #ocaml
asdfhjkl has quit [Quit: Leaving]
ivan\ has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
struktured has joined #ocaml
ivan\ has joined #ocaml
wagle has joined #ocaml
tbrady has quit [Quit: tbrady]
wagle has quit [Remote host closed the connection]
wagle has joined #ocaml
wagle has quit [Ping timeout: 265 seconds]
tmaedaZ has quit [Ping timeout: 265 seconds]
tmaedaZ has joined #ocaml
mister_m has quit [Quit: WeeChat 0.3.7]
wagle has joined #ocaml
slash^ has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
err404 has joined #ocaml
eni has joined #ocaml
osa1_ has quit [Quit: Konversation terminated!]
osa1 has joined #ocaml
edwin has joined #ocaml
Cyanure has joined #ocaml
Submarine has quit [Remote host closed the connection]
tac-tics[home] has joined #ocaml
tac-tics[home] has quit [Read error: Connection reset by peer]
sepp2k has joined #ocaml
<wieczyk>
01:43 < Drakken> one of the more tragic features of ML
<wieczyk>
I agree.
<wieczyk>
01:55 < thizanne> wieczyk: if you want to do this in OCaml, you want to use objects
<wieczyk>
indeex, thanks.
<wieczyk>
indeed*
edwin has left #ocaml []
BiDOrD_ has joined #ocaml
BiDOrD has quit [Ping timeout: 240 seconds]
<adrien>
wieczyk: objects might be a bit overkill though
<adrien>
and you can have records in different modules, which will let you avoid ambiguities
Sablier has joined #ocaml
avsm has joined #ocaml
avsm has quit [Client Quit]
pangoafk is now known as pango
<orbitz>
Ahah! Finally a use case for funcors!!!
<adrien>
now that you've found one, you'll find many and everywhere
<orbitz>
:)
K_F has joined #ocaml
Cyanure has quit [Read error: Operation timed out]
mnabil has joined #ocaml
ski has quit [Ping timeout: 240 seconds]
ski has joined #ocaml
ski has quit [Ping timeout: 265 seconds]
ski has joined #ocaml
ski has quit [Ping timeout: 252 seconds]
netrino has joined #ocaml
Cyanure has joined #ocaml
netrino_ has joined #ocaml
netrino has quit [Ping timeout: 265 seconds]
<orbitz>
God I hate exceptions in Ocaml
<adrien>
warum?
<orbitz>
In this code I prefer to use a Result.Ok/Result.Error type. And since, AFAIK, I cannot enforce a subtype of exn it makes converting an exn to a Result.Error challenging.
<orbitz>
It's just really hard to handlien exceptions in a typesafe way IMO
<orbitz>
handle*
<mrvn>
converting an exception to option type is stupid. better to write the code the other way around
<orbitz>
it's not an ption type
<orbitz>
type ('a, 'b) result
<mrvn>
variant type. same thing for the runtime
<orbitz>
I don't see why it's stupid, I don't what the exceptions, it makes the code harder to work with
<mrvn>
orbitz: because you incurr the overhead for creating and catching an exception
<orbitz>
Not a problem here, it's all I/O bound
<orbitz>
And Ocaml exceptiosn are fast enough I wouldn't really worry abotu that
<mrvn>
a big problem can be that it destroys tail recursiveness
<orbitz>
Why would it destroy tail recursivness?
<orbitz>
(any more than just using an exception woudl)
<mrvn>
if you write the code to directly emit a Result that is avoided.
<mrvn>
generally speaking
<orbitz>
Isn't that not tail recursive withotu the result?
<orbitz>
mrvn: try foo blah with exn -> blub -- Isn't this just as non-tail recursive?
<mrvn>
???
<mrvn>
orbitz: if you write foo to return a Result directly then there is no try
<orbitz>
That isn't what you wrote above though. I'm asking: isn't that try/catch block just as non tail recursive as the example you gave?
ski has joined #ocaml
<mrvn>
that would depend on the implementation. not sure what ocaml does.
<orbitz>
Regardless, I haven't run into issues with using thisin a tail recursive way
err404 has quit [Remote host closed the connection]
<orbitz>
Thebigest issue is not being able to subtype exn
<mrvn>
use a class
<orbitz>
How does that help me here?
<mrvn>
since I don't know your code I have no idea
<mrvn>
but if you throw a class then you can subtype the class
<orbitz>
The main problem I have isn't me throwing exceptions, because I don't, but it's using third party libraries
<orbitz>
Where the exceptions they throw are not well documented
<mrvn>
don't we all wish ocaml would include the exceptions as part of a functions signature?
<adrien>
java, nightmare
<orbitz>
mrvn: I do
<orbitz>
checked exceptinos in java sucks because java's type system sucks
<orbitz>
YOu can do it better than Java fairlye asily IMO
<adrien>
or you'd need to have it automatic so they are added by default to the signature if you don't do anything, and you can do nothing about them
<mrvn>
obviously the execptions have to be derived automatically
<orbitz>
Which shouldn't be hard
<mrvn>
and declaring a type with an exception missing would be a type error
<adrien>
shouldn't ;-)
<mrvn>
exceptions are basically polymorphic variants so there should be a lot of code reusable
<orbitz>
The way I look at it: I can already effectively do this with a Result type. I just wan tot hoist the Result type into the language, so I don't see why it would be hard to do
<mrvn>
orbitz: but that complicates your code. Think of what that means for e.g. List.fold_left
<orbitz>
How so?
<orbitz>
I mean, List.fold_left how has to handle the exceptions all your functinos might trhow
<orbitz>
but I think that is ok
<orbitz>
By handle, i mean its type has to represent the union of all exceptions f might throw
emmanuelux has joined #ocaml
<orbitz>
and if you're iterating a list of functions, those too
<orbitz>
But that is the behavior I want
<mrvn>
I ment for the closure argument. (fun x y -> x + y) becomes (fun x y -> match x with Result.Ok x -> Result.Ok (x+y) | err -> err)
<mrvn>
and it not longer stops the folding on error
<mrvn>
having ocaml track exceptions in the type would be much nicer.
<orbitz>
mrvn: It wouldn't be a problem, the way I envision it is it's effectively running your entire Ocaml program in a Result monad, where let is always a bind on that and try/catch is the only wao to match on the Error type
<orbitz>
Err, It hink you're saying the same thing as I?
<mrvn>
yes
<orbitz>
^5!
<orbitz>
mrvn: I'm told tehre is a branch of ocaml that does this, although I don't find that very useful of course (I don't want to use non-mainline ocaml)
<mrvn>
I want my stuff to compile on plain debian so that is out of the question for me, too.
<K_F>
I wonder if ocaml-core would be of difference for this
<orbitz>
mrvn: In the fictional language I think about writing every few months, near 100% checked exceptions is something I'd have. Only one I'd probably leave out is any error that can happen *all* the type, liek OOM
* K_F
has to read up on that again..
ski has quit [Ping timeout: 246 seconds]
ski has joined #ocaml
ski has quit [Ping timeout: 252 seconds]
emmanuelux has quit [Ping timeout: 246 seconds]
ski has joined #ocaml
err404 has joined #ocaml
err404 has quit [Remote host closed the connection]
smerz has joined #ocaml
Submarine has joined #ocaml
emmanuelux has joined #ocaml
ski has quit [Ping timeout: 264 seconds]
ski has joined #ocaml
ski has quit [Ping timeout: 255 seconds]
ski has joined #ocaml
Submarine has quit [Ping timeout: 240 seconds]
Cyanure has quit [Remote host closed the connection]
Cyanure has joined #ocaml
Sablier has quit [Quit: Kat]
Sablier has joined #ocaml
Kakadu has joined #ocaml
SanderM has joined #ocaml
SanderM has quit [Client Quit]
SanderM has joined #ocaml
avsm has joined #ocaml
Sablier has quit [Quit: Kat]
Submarine has joined #ocaml
Sablier has joined #ocaml
Submarine has quit [Ping timeout: 250 seconds]
tbrady has joined #ocaml
tbrady has quit [Client Quit]
emmanuelux has quit [Ping timeout: 245 seconds]
slash^ is now known as slash__
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
SanderM_ has joined #ocaml
slash__ is now known as slash^
SanderM has quit [Ping timeout: 246 seconds]
tbrady has joined #ocaml
err404 has joined #ocaml
Sablier has quit [Ping timeout: 245 seconds]
tbrady has quit [Quit: tbrady]
Sablier has joined #ocaml
Submarine has quit [Ping timeout: 264 seconds]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
Cyanure has quit [Remote host closed the connection]
Sablier_ has joined #ocaml
Cyanure has joined #ocaml
Sablier has quit [Quit: Kat]
Sablier_ has quit [Quit: Kat]
Sablier has joined #ocaml
Submarine has quit [Quit: Leaving]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
Yoric has joined #ocaml
mister_m has joined #ocaml
ftrvxmtrx has joined #ocaml
Yoric has quit [Ping timeout: 264 seconds]
gnuvince has quit [Ping timeout: 265 seconds]
tbrady has joined #ocaml
Yoric has joined #ocaml
Submarine has quit [Ping timeout: 255 seconds]
avsm has quit [Quit: Leaving.]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
Submarine has quit [Ping timeout: 245 seconds]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
<tbrady>
I have a money type where either larger or smaller values are preferable, corresponding to buying or selling. So compare is either compare or (flip compare). What's the standard way to implement this? Functor? Will there be a performance penalty?
Yoric has quit [Ping timeout: 264 seconds]
<orbitz>
Functors are generally used for performance benefits
<Yoric>
Currently, in OCaml, there is a small runtime penalty for functors.
<Yoric>
iirc, removing this penalty is on the roadmap
gnuvince has joined #ocaml
<tbrady>
So what would be the way to implement this if you wanted to avoid that (albeit small) performance penalty?
<orbitz>
i thoguht whole piot of functors was like C++ templates, maybe that's SML that oes it all at ocmpile time...
Yoric has quit [Ping timeout: 244 seconds]
robocop has joined #ocaml
robocop has quit [Remote host closed the connection]
mister_m has quit [Quit: WeeChat 0.3.7]
<adrien>
are the "ocamlc" executable plus the usual .cm[io] files enough to build new .cmo files?
Submarine has quit [Ping timeout: 246 seconds]
Yoric has joined #ocaml
<Drakken>
tbrady you could define separate modules with Sell.better and Buy.better
<Drakken>
if your selling & buying prices are separate types
<Drakken>
or even if you just want separate code for buying and selling
avsm has joined #ocaml
<Drakken>
I'm not sure what the point would be though. It should be easy enough to just write > for selling and < for buying.
Kakadu has quit [Quit: Konversation terminated!]
<K_F>
it might be more complicated than that, if the money type was used in a trading algorithm, best execution wouldn't be based on a single comparison, but you'd have to consider order depth across multiple trading facilities and split the order to give the optimal result
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
<Drakken>
Well, I guess the heavyweight option would be to define a price class and then define subclasses for buying and selling.
<Drakken>
but it might be simpler to define a variant type trade = Buy of price | Sell of price, and then define better to take a trade instead of a price.
<Drakken>
or type side = Buy | Sell and type trade = { side; price }
<K_F>
missing volume, but indeed :)
<Drakken>
volume, product, etc., etc.
<orbitz>
Best option is proabbly to do the most obvious solution then profiel it ;)
thelema has quit [Remote host closed the connection]
thelema has joined #ocaml
Cyanure has quit [Remote host closed the connection]
milosn has quit [Read error: No route to host]
milosn has joined #ocaml
<thelema>
orbitz: functors are like c++ templates, but they have proper separate compilation, which is why ocaml doesn't have rediculous compile times like C++
<orbitz>
thelema: yes, but I was udnerteh impression they were gone at compiletime
<thelema>
orbitz: how would that work with separate compilation?
<thelema>
The code for a functor is generated when that functor is compiled, not when it is applied
<orbitz>
K
foocraft has joined #ocaml
Yoric has quit [Ping timeout: 264 seconds]
Yoric has joined #ocaml
sepp2k1 has joined #ocaml
sepp2k has quit [Ping timeout: 264 seconds]
<flux>
well, they could work by compiling an intermediate representation of modules..
jave has joined #ocaml
<Drakken>
But how close is the object code in the functor to the final object code of the resulting module? What does the functor do at runtime? Is it like a runtime compiler?
<Yoric>
No, nothing that complicated.
<mrvn>
no, its a compile time compiler
<Yoric>
It just performs method lookup.
<Yoric>
(well, not "method", but it is the same idea)
Tobu has quit [Remote host closed the connection]
Tobu has joined #ocaml
<Drakken>
Yoric so the functor contains some kind of compiled template for the module and it just returns a copy of the template with a few pointers filled in?
ulfdoz has quit [Read error: Operation timed out]
<Yoric>
Yes. Basically like an object with virtual methods in OOP.
<mrvn>
doesn't it also inline?
eni has quit [Quit: .]
<Drakken>
That's an interesting question. How much difference is there between a regular module and an equivalent one constructed by a functor?
<mrvn>
rather the difference between a functor and first class modules
slash^ has quit [Quit: Lost terminal]
ftrvxmtrx has quit [Ping timeout: 246 seconds]
<orbitz>
Sometimes tehse type errors can be a doozy to figure out...
<mrvn>
orbitz: yeah, syntax errors are usualy simpler
<mrvn>
Thats the problem with only 2 errors. One tends to be simpler.