dark_light changed the topic of #ocaml to: OCaml 3.09.2 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
setooo has joined #ocaml
seto has quit [Read error: 110 (Connection timed out)]
<datrus> is there a builtin function that does the python/perl equivalent of split/join on strings?
<lde> Str.split
<datrus> ok , found String.concat
dbueno_ has joined #ocaml
<dbueno_> What is the reason that :: is treated specially while (e.g.) + is not so that (::) doesn't yield a function but (+) does?
<abez> :: is a constructor
* abez shrugs
<dbueno_> It's natural to think of it as a function (especially if you come from Lisp); and I frequently do.
<dbueno_> But I see your point.
ZeeGeek has joined #ocaml
<abez> dbueno_: I'm not saying I agree with it. I'm saying that is what it is.
<ZeeGeek> I'm trying to test something and if it's true return "Some s" where s is a user defined type, if it's false then return None. the compiler said that None is not the right type.
<abez> do you mean type or value
<ZeeGeek> type
<ZeeGeek> here's the error message
<abez> I thought ocaml was statically typed I didn't think it was possible to runtime typing like that. I could be wrong.
<ZeeGeek> This expression has type 'a option but is here used with type int->k option
<abez> sounds like you have a curryed function there
<abez> or you are expecting it
<ZeeGeek> I'm expecting it
<abez> what is k
<abez> did you make that up?
<abez> is k a type you made
<ZeeGeek> it seems like that it works if I use "match blahblah -> None | blahblah -> somethingelse"
<ZeeGeek> yeah
<ZeeGeek> but it doesn't work when I use "if then else"
<abez> yah... I'd need more code than that
<abez> Show me how you are constructing your Somethingelse
<ZeeGeek> okay
<ZeeGeek> I used "if condition-is-true then fun x -> func a b else None
<ZeeGeek> where that func's return type is k
<ZeeGeek> sorry, k option
<abez> if (cond) then Some(fun x -> func a b) else None
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- IRC with a difference"]
<ZeeGeek> okay, let me try it
<ZeeGeek> the same error
<abez> # if (true) then Some(fun x -> x * x) else None;;
<abez> - : (int -> int) option = Some <fun>
<abez> # if (true) then (fun x -> x * x) else None;;
<abez> This expression has type 'a option but is here used with type int -> int
<abez> works for me
<abez> perhaps you are expecting a different value elsewhere
<abez> perhaps you not expecting None or Some
<ZeeGeek> aight, I'll double check it
<ZeeGeek> thank you
* ZeeGeek did make a stupid error and he thanks abez for helping out
<abez> Ocaml can be really cryptic but you always have to make sure you're returning values of a consistent type from if statements
<ZeeGeek> yeah, I've learnt a lesson. it's not easy to pick up this language
<abez> You'll find it is really really consistent
<abez> but the type inferencering will send you off into the wrong direction to look for bugs
<ZeeGeek> thanks for pointing it out, I'll be more careful :P
<dbueno_> ZeeGeek: The error messages are the price to pay for the wonderful type system.
<ZeeGeek> dbueno_: lol, there's always a price to pay for
yondalf has joined #ocaml
fab_ has quit [Remote closed the connection]
<Ugarte> Of course, using explicit type declarations can make it a bit easier to localize errors.
<Ugarte> I try to use them on every function definition.
<Ugarte> Sometimes even within the function.
<Ugarte> And I start applying them like mad when I get a bug I can't track down.
<abez> asserts are good too
chessguy has joined #ocaml
romildo has quit ["Leaving"]
<datrus> how would you define a type that can represent all expressions involving + and - (addexpr), another type representing expressions using * and / (mulexpr) and another type using the previous two types that can use + - * / (expr)
<datrus> is it possible using some kind of type inheritance or something like that
Smerdyakov has quit [Remote closed the connection]
Smerdyakov has joined #ocaml
yondalf has quit ["leaving"]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- State of the art IRC"]
pango_ has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
david_koontz has quit ["Leaving"]
pango has quit [Remote closed the connection]
knobo has quit [Read error: 110 (Connection timed out)]
chessguy has joined #ocaml
<Ugarte> datrus: For what purpose? What are you trying to do?
<Ugarte> Are you wriing a compiler?
<Ugarte> writing, even.
<Ugarte> Anyway:
<Ugarte> If you want to do it for an AST representation of arithmetic operations, and you want the separate ones for order of operations, you could do this:
<Ugarte> type low_order = Add of expr * expr | Sub of expr * expr
<Ugarte> type high_order = Mul of expr * expr | Div of expr * expr
<Ugarte> type arithmetic = Low_order of low_order | High_order of high_order
<Ugarte> Or something like that.
<Ugarte> Adapted to your needs.
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- 100,000+ downloads can't be wrong"]
ramkrsna has joined #ocaml
Skal has joined #ocaml
bluestorm has quit ["Konversation terminated!"]
knobo has joined #ocaml
_velco has joined #ocaml
pattern has quit [Read error: 104 (Connection reset by peer)]
pattern has joined #ocaml
shawn has quit [Connection timed out]
Wild_Cat has joined #ocaml
TheArthur has joined #ocaml
david_koontz has joined #ocaml
ozzloy has joined #ocaml
<ozzloy> what does the "_" mean?
<ozzloy> in: match (list1,list2) with ([],_) -> ...
<pango_> anonymous pattern
pango_ has quit ["brb"]
pango has joined #ocaml
_fab has joined #ocaml
gim has quit [Remote closed the connection]
shawn has joined #ocaml
yondalf has joined #ocaml
yondalf has quit [Client Quit]
yondalf has joined #ocaml
m3ga has joined #ocaml
love-pingoo has joined #ocaml
ZeeGeek_ has joined #ocaml
ZeeGeek has quit [Read error: 131 (Connection reset by peer)]
david_koontz has quit ["Leaving"]
<flux__> datrus, function sum 1 2 wouldn't work anyway, because ((sum 1) 2) = (1 2) = error
<flux__> tada, I think I just figured out why my program dies unexpectly every now and then..
<flux__> SIGPIPE!
<flux__> darn..
<flux__> after I noticed that it appeared to die especially often when it was conversing via flaky connections, I begun to think about the networkin code..
<flux__> too bad it never says it exited due to sigpipe, it just exits :)
<flux__> (I haven't verified my sigpipe-theory yet, though)
gim has joined #ocaml
b00t has joined #ocaml
yondalf has quit ["leaving"]
Snark has joined #ocaml
ramkrsna has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["Leaving"]
velco has joined #ocaml
Nayru has joined #ocaml
b00t has quit [Remote closed the connection]
<Nayru> Hi everybody! Here is a simple question: How to escape a " quotation mark in a String?
<m3ga> \"
<m3ga> just like in C / C++ / Java
<Nayru> Hm.. the compiler said: Warning X: illegal backslash escape in string.
<m3ga> must be some other problem in the string.
<Nayru> Ah... got it. I forgot about the Windows "I want path's with backslash"-thing.
<Nayru> Thanks m3ga :)
<m3ga> no prob!
yondalf has joined #ocaml
romildo has joined #ocaml
mikeX has joined #ocaml
yondalf_ has joined #ocaml
Nayru has quit []
yondalf has quit [Read error: 145 (Connection timed out)]
pattern has quit ["Reconnecting to server - dircproxy 1.1.0"]
pattern has joined #ocaml
yondalf_ has quit ["leaving"]
ramkrsna has joined #ocaml
romildo has quit [Read error: 110 (Connection timed out)]
romildo has joined #ocaml
slipstream has joined #ocaml
slipstream-- has quit [Read error: 110 (Connection timed out)]
Godeke has quit [Read error: 110 (Connection timed out)]
<datrus> Ugarte: what's the definition of the expr type in your example?
Godeke has joined #ocaml
<datrus> i'm trying to define types for expressions with +,-, for expressions with *,/ and for expressions with +,-,*,/
<datrus> i use this:
<datrus> type ('a)expr1_ = Add of 'a * 'a | Sub of 'a * 'a;;
<datrus> type ('a)expr2_ = Mul of 'a * 'a | Div of 'a * 'a;;
<datrus> type expr1=(expr1)expr1_;;
<datrus> type expr2=(expr2)expr2_;;
<datrus> type expr3 =(expr3)expr1_ | (expr3)expr2_;;
<datrus> but ocaml complains:
<datrus> The type abbreviation expr1 is cyclic
<datrus> how come?
<flux__> hmm..
<flux__> wouldn't expr1 be always an infinite data structure?
<flux__> oh, and you can't write type a = type1 | type2, it needs to be type a = Constructor1 of type1 | Constructor2 of type2
<datrus> ok, replace expr1_ by
<datrus> type ('a)expr1_ = Int of int | Add of 'a * 'a | Sub of 'a * 'a;;
<datrus> still the same error
<datrus> expr1 is not infinite still the terminators are integers
<datrus> i'm trying to define expr3 in terms of expr1 and expr2
<flux__> this works:
<flux__> type expr1=expr1' expr1_ and expr1'=Expr of expr1;;
<pango> without expr3 definition, it only compiles with -rectypes
<datrus> ok thanks
rickdangerous has joined #ocaml
<ZeeGeek_> don't quite understand unification algorithm, any recommandation on reading materials?
ZeeGeek_ is now known as ZeeGeek
love-pingoo has quit ["Leaving"]
velco has quit ["Ex-Chat"]
Smerdyakov has joined #ocaml
chessguy has joined #ocaml
shawn has quit [Connection timed out]
shawn has joined #ocaml
Wild_Cat has quit [Remote closed the connection]
Skal has quit [Remote closed the connection]
smimou has joined #ocaml
<Ugarte> datrus: I was saying that expr would be the type of whatever expressions are in your language.
<Ugarte> That evaluate to ints or floats or whatever else can be arithemtically combined.
<Ugarte> Change as needed. :)
<Ugarte> Perhaps it was an unnecessary restriction, since you're just using polymorphic types and assuming you'll check it later.
batdog is now known as batdog|gone
dark_light has joined #ocaml
Selva_ has joined #ocaml
bluestorm has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
bluestorm_ has joined #ocaml
batdog|gone is now known as batdog
Snark has quit ["Leaving"]
bluestorm has quit [Read error: 113 (No route to host)]
pango has quit [Remote closed the connection]
pango has joined #ocaml
pango_ has joined #ocaml
jajs has joined #ocaml
pango has quit [Remote closed the connection]
bluestorm_ is now known as bluestorm_aw
shawn has joined #ocaml
Leonidas has joined #ocaml
pattern has quit [Read error: 110 (Connection timed out)]
pattern has joined #ocaml
danly has quit [Read error: 104 (Connection reset by peer)]
danly has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
pango_ has quit [Remote closed the connection]
danly has quit [Client Quit]
pango_ has joined #ocaml
PollyMorph has joined #ocaml
<PollyMorph> Hello
PollyMorph has left #ocaml []
pattern has quit ["I shouldn't really be here - dircproxy 1.1.0"]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- State of the art IRC"]
jajs has quit [Read error: 110 (Connection timed out)]
jajs has joined #ocaml
chessguy has joined #ocaml
_velco has quit ["I'm outta here ..."]
Ballin_05 has joined #ocaml
<Ballin_05> back to working on my stuff
danly has joined #ocaml
pango_ has quit ["Leaving"]
pango has joined #ocaml
_fab has quit [Read error: 110 (Connection timed out)]
_fab has joined #ocaml
<romildo> I am still looking for help on porting GtkDatabox to lablgtk.
<romildo> Is it the case that anymore here would help me on some questions regarding lablgtk implementation?
<romildo> s/anymore/anyone/
<abez> no xp sorry :(
<abez> Are you on their mailing list?
bluestorm_aw has quit ["Konversation terminated!"]
<romildo> yes, I am. I has just post a message there. I was hoping to find someone to interact in real time here.
<Ballin_05> what is GtkDatabox ?
gim_ has joined #ocaml
<romildo> It is a Gtk based library that implements a widget for plotting graphics data, like points, lines, bars, marks, etc.
<romildo> Here you can see some screenshots: http://www.eudoxos.net/gtk/gtkdatabox/screenshots/index.html
pattern has joined #ocaml
jajs_ has joined #ocaml
jajs has quit [Read error: 54 (Connection reset by peer)]
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- Leading Edge IRC"]
gim_ has quit ["sleep(8*3600);"]
Demitar_ has joined #ocaml
olivier has joined #ocaml
danly_ has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
danly has quit [Read error: 60 (Operation timed out)]
olivier has quit ["Leaving"]
smimou has quit ["bli"]
jajs_ has quit [Remote closed the connection]
mikeX has quit ["leaving"]
rickdangerous has quit ["leaving"]
<dark_light> is there any way to build the "inverse" function? like, the inverse of (fun x -> 2*x+1) is (fun x -> (x-1)/2)
<dark_light> I was thinking in how define the integral function in ocaml, so i though, if let deriv f x = let epsilon = sqrt epsilon_float in ((f (x +. epsilon) -. (f x)) /. epsilon is a good definition for derivate a function, the integral would be just let integral = inverse deriv
<dbueno_> dark_light: There's synta for accessing the body of a function inside ocaml.
<dark_light> so..?
<dbueno_> That's just seems like the most direct way to build what you want to build.
<dbueno_> dark_light: What I meant to say is there is *no* syntax....
<dark_light> Ah
m3ga has joined #ocaml
<dark_light> dbueno, so you think there is no way to build? or you are sure there aren't a way?:(
<dbueno_> dark_light, I don't think you're going to be able to build an inverse function like that.
<dbueno_> You'd need to be able to traverse the expression in the body of the function whose inverse you need to cpmpute... which can't be done, in ocaml.
<dark_light> Hmmm but i though, maybe there are a trick to do it
<dark_light> or a trick to build the integral function without using this inverse function, it would help :)
<dbueno_> dark_light, maybe you could do some numerical analysis to compute the inverse.
<dark_light> dbueno, but for a float, it would be like.. well.. or i choose a interval, or i choose do not have many precision, or i choose to do it only in compile time
romildo has quit ["Leaving"]
m3ga has quit ["disappearing into the sunset"]
_fab has quit [Remote closed the connection]