Yurik changed the topic of #ocaml to: http://icfpcontest.cse.ogi.edu/ -- OCaml wins | http://www.ocaml.org/ | http://caml.inria.fr/oreilly-book/ | http://icfp2002.cs.brown.edu/ | SWIG now supports OCaml| Early releases of OCamlBDB and OCamlGettext are available
<thedark> hum.. it seems to be working in fact
<thedark> the bug was in the big -> big int conversion of caml
<thedark> or more precisely in my way to test my program.....
<seth_> thedark: that's interesting
<Vincenz> thedark: how so?
<seth_> brb
<thedark> well i was trying to cast an int to a big_int, but the int was seen as a negative number by ocaml
<thedark> i havent figured out how to launch a function with a big int as a parameter
<Vincenz> ah
<thedark> since fun (big_int_of_int foo) will not work with a big int..
<Vincenz> anyways
<Vincenz> I'm crashing
<thedark> (and eventually cast to a negative number )
<Vincenz> very tired
<thedark> same
<Vincenz> 3am
<Vincenz> have slept 5-6 hours last few nights
<Vincenz> tomorrow I have to work :(
<Vincenz> time to hit the sack
Vincenz has quit []
docelic is now known as docelic|sleepo
thedark has quit [Read error: 60 (Operation timed out)]
TimFreeman has joined #ocaml
<TimFreeman> I have code that creates an exception and marshalls it. Another program unmarshalls it and tries to match against it. Matching fails even though the exceptions have the same name and are generated by the same compilation of ...
<TimFreeman> a .ml file. Any idea how to get the matching to succeed?
<seth_> TimFreeman: is the exception defined in a separately compiled file and included with both programs?
<TimFreeman> Oops, I was afk. Yes, the exception is defined in a file C_compile_exn that is included in both programs. The failing code reads:
<TimFreeman> match exn with
<TimFreeman> C_compile_exn.Ncconstr n -> n
<TimFreeman> | _ -> failwith
<TimFreeman> (Printf.sprintf "Bad exception %s passed to ncconstr_eventdesc"
<TimFreeman> (Printexc.to_string exn))
<TimFreeman> and it prints
<TimFreeman> Fatal error: exception Failure("Bad exception C_compile_exn.Ncconstr(_) passed to ncconstr_eventdesc")
<TimFreeman> so the printed representation is exactly the same as what isn't matching in the source file.
<TimFreeman> There is only one C_compile_util. No functors involved.
<seth_> so you aren't trying to raise it in the second program, just print information about it?
<TimFreeman> Extract information from it. "exn" is the only extensible data type. Didn't feel like battling with polymorhpic variants.
<seth_> No, you shouldn't need to.
<TimFreeman> seth_: So my answer to you is "yes", more or less. shouldn't need to what?
<seth_> shouldn't need polymorphic variants
<TimFreeman> Well, the ... afk again...
<seth_> So it didn't exactly fail pattern matching, it bombs out about the marshalled value.
<TimFreeman> I'm back. If the pattern matched, it wouldn't have got to the failwith.
<seth_> yes, but the message doesn't say that it couldn't match, rather that it is a bad value. So it fails because the object is messed up, not because the pattern is wrong.
<mrvn> Your marshaling an exception?
<TimFreeman> The message is generated by my Printf.sprintf code. It fails because it reaches that point in the code. Yes, I'm marshalling an exception.
<seth_> I suspect that you need to extract the info you want and send it as part of another, marshallable object.
<mrvn> Are you marshaling functions?
<TimFreeman> nrvn: No, I'm not marshalling functions.
<mrvn> exceptions are somewhat special, could be you need to.
<seth_> Isn't it trying to unravel a stack that belongs to the other process instead of its own?
<TimFreeman> If there's no obvious way to get this to work, I'll make a simple variant type and marshall that. But then I have to extend it in one central place whenever more alternatives pop up.
<TimFreeman> seth_: No stacks involved. What are you talking about?
<mrvn> seth_: One should be able to unmarshal it and raise it again.
<seth_> mrvn: But he isn't raising it again, he is just dumping info from it.
<seth_> TimFreeman: I meant the call stack, not a stack in your program.
<TimFreeman> I agree with mrvn, but I'm not raising it. What call stack are you talking about?
<seth_> TimFreeman: the executing program has a call stack.
<TimFreeman> If you don't raise the exn, then there's no connection between the exn and any stacks anywhere. If the exn doesn't store a stacktrace, then there's never a connection between the exn and a stack.
<mrvn> Hmm, the closures flag shouldn't be the problem. if it where marshaling an exception should barf.
<TimFreeman> mrvn: Agreed. I'm not making any closures, so I agree twice.
<TimFreeman> Oh well, looks like the accumulated wisdom of IRC isn't making an instant solution here. I gotta eat dinner. I'll report this to caml-bugs and use a variant instead of an exception. afk for an hour.
<mrvn> Do you use the same code to marshal und unmarshal the data? recompiling can invalidate marshaled data.
<seth_> mrvn: I'm still a bit cloudy on when to use the double semicolon (;;) in a compiled program.
Kinners has joined #ocaml
<mrvn> never
<mrvn> ;; is a special thing for the runtime to say "evaluate and gimme a prompt"
<mrvn> (afaik)
skylan has quit ["EPIC Panic: EPIC4-1.0.1:Referential integrity failure: Channel [#emacs] on server [0] is connected to window [18] on server [0"]
skylan has joined #ocaml
TimFreeman has quit [Read error: 110 (Connection timed out)]
TimFreeman has joined #ocaml
mattam has joined #ocaml
TimFreeman has left #ocaml []
Kinners has left #ocaml []
lament has joined #ocaml
TachYon has joined #ocaml
TachYon has quit ["Client Exiting"]
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
polin8_ has joined #ocaml
mrvn_ has joined #ocaml
mrvn has quit [Read error: 54 (Connection reset by peer)]
polin8 has quit [Dead socket]
lament has quit ["Support Darwin Awards! Join the military!"]
Vincenz has joined #ocaml
docelic|sleepo has quit [Connection reset by peer]
_BT has quit [brunner.freenode.net irc.freenode.net]
seth_ has quit [brunner.freenode.net irc.freenode.net]
mellum has quit [brunner.freenode.net irc.freenode.net]
Jimzy has quit [brunner.freenode.net irc.freenode.net]
avn has quit [brunner.freenode.net irc.freenode.net]
<Vincenz> hi
<pattern_> hey
Vincenz is now known as _
<_> I'm all of you
_ is now known as Vincenz
_BT has joined #ocaml
seth_ has joined #ocaml
mellum has joined #ocaml
Jimzy has joined #ocaml
avn has joined #ocaml
lowks has quit [Read error: 104 (Connection reset by peer)]
lowks has joined #ocaml
Jimzy has quit [Read error: 60 (Operation timed out)]
docelic has joined #ocaml
_BT has quit ["Client Exiting"]
<emu> we can make noise here too yuo know
<Vincenz> I wish you did :)
<Vincenz> hmm
<Vincenz> want to see some code I wrote?
<Vincenz> (less than a page)
<Vincenz> 47 lines (including topcomment)
<Vincenz> oh yeah check this out:
<Vincenz> this is funky
<Vincenz> that site doesn't support Ocaml!! :(
<Vincenz> what kinda site is that anyways?
<Vincenz> that's a cool concept
<Vincenz> thnx for the link!
<pattern_> :)
<Vincenz> what do you think of the code?
<Vincenz> would you have done it differently?
<Vincenz> ?
<pattern_> i dunno... too advanced for me
<Vincenz> oh
<Vincenz> it's from chapter 2 of this book on OCaml (exercises)
<Vincenz> chap 1 was intro
<Vincenz> and it's got like 18 chaps
<Vincenz> so ...basic stuff?
<pattern_> not for me :P
<Vincenz> anyways time for lunch
lowks__ has joined #ocaml
lowks has quit [Read error: 60 (Operation timed out)]
Jimzy has joined #ocaml
docelic is now known as docelic|away
thedark has joined #ocaml
malc has joined #ocaml
systems has joined #ocaml
<Vincenz> how significantly different is ocaml syntax from SML?
<Vincenz> (it's for the nopaste site, he might consider adding ocaml
<systems> huh
<systems> you will find an sml vs ocaml website
<systems> url or page or something
<systems> yea that one
<systems> and i remember i saw a webpage which compare a syntax of like a dozen lang
<systems> was called syntaz across languages or something like that
<pattern_> i've seen sml code and it seems very similar to ocaml
<Smerdyakov> It is.
<Smerdyakov> There is no significant difference if you don't use OO in OCaml.
<systems> ocaml vs sml, ocaml won by a ko
<systems> >:)
<Smerdyakov> Is that supposed to mean something, systems?
<systems> mmm...it means I think between the two, choose ocaml
<Smerdyakov> Why?
<systems> for me, and seriously, one the reputation, two more docs and books , three it was easier to find a compiler and install it and such
<Smerdyakov> LOL
<Smerdyakov> If you think it's hard to find and install an SML compiler, you either live 10 years ago or have poor basic computer use skills.
<Smerdyakov> I don't know what reputation you mean.
<systems> or didnt really try
<systems> i didnt really try or looked for one
<Smerdyakov> The "more docs and books" is certainly a positive point.
<systems> but, ocaml was there, the book was free, and many websites said it was fast
<Smerdyakov> MLton produces optimizied output on par with ocaml.
<Smerdyakov> (MLton is an SML compiler.)
<Smerdyakov> I think you may be right that OCaml is a better choice at the moment, but it's for a very small number of reasons, not including most of the things you've named!
<systems> :)
<systems> at the moment!
<Smerdyakov> I think a standardized ML language will be the best choice 2 years after it is created, if ever.
<Smerdyakov> A standard that is actually followed, I mean.
<Smerdyakov> Since I think ocaml was created after _Standard_ ML :P
<systems> how would that be better then ocaml
<pattern_> actually i think it was created before
<Smerdyakov> Because there would be more compilers for it.
<Smerdyakov> Presumably the dozen or so free SML compilers out there today would change to read the new standard, along with ocaml.
<Smerdyakov> By the way, your statement about difficulty of finding an SML compiler is quite funny given that there are at least 10 free ones, and only one current ocaml compiler...
<systems> yea excatly
<systems> i was lookin at haskell, and was thinking, ocaml or haskell ...mmmm
<pattern_> "Why is the syntax of Caml different from SML's one ?" "The main reason is historical: Caml was invented before SML." "The Caml language is issued from the original ML language, invented by Robin Milner in 1978, and developped jointly at INRIA from 1981. The first Caml compiler was written in 1984, and distributed from 1985. Standard ML was not yet invented, and Caml's syntax was similar to the syntax of ML V6.2, whose compiler was used t
<pattern_> pile the first Caml compiler. When the syntax of Standard ML has been defined, Caml kept its own syntax, for several reasons..."
<systems> i picked ocaml cause there was only one compiler and because i heard it was faster
<systems> sml is kinda weird too
<pattern_> from what i've heard of haskell, i think ocaml is a much better choice
malc has quit [Read error: 110 (Connection timed out)]
<systems> well the book am reading now, developing apps with ocaml, compare ocaml to haskell from time to time
<Smerdyakov> pattern_, well, the ML node at www.everything2.com disagrees, but what would I know....
<pattern_> ocaml is, allegedly, much faster than haskell... ocaml doesn't restrict you to a functional style, and even has oo extensions
<Smerdyakov> OO extensions don't matter at all to me.
<Smerdyakov> I haven't written an OO program in years =)
<pattern_> smerdyakov, well that quote was from the OCaml FAQ... a bit more official than everything2.com, imo
<pattern_> oo matters to me, simply because i don't know it yet, and i want to learn it
<pattern_> ocaml makes that convenient, because i don't have to learn a new language to learn oo
<Smerdyakov> Don't hold your breath, pattern_.
<Smerdyakov> Even the OCaml creates recommend rarely using OO.
<pattern_> heh
<systems> mmm, pattern_ if you just want to learn OO, you should look at other langs like ruby or python
<pattern_> smerdyakov, i'm not necessarily going to _use_ oo with ocaml... i just want to learn the paradigm
<pattern_> systems, but then i'd have to learn those other languages :P
<systems> yea which is great
<pattern_> if you have the time
<systems> i want to learn programming , programming in general , so after i looked around i found that
<systems> you should learn at least 4 different langs, and as much as you can about the OS
<pattern_> i know probably ten or 12
<systems> ten or 12 what
<pattern_> or, rather, i've _learned_ ten or 12 languages
<pattern_> can't say i know them all anymore
<systems> none of them is python ....eeeeek
<pattern_> nope
<pattern_> perl was good enough for me, to make me not want to bother learning python, which is really similar
<systems> for me it was the other way
<pattern_> yeah
<pattern_> well, i was a sysadmin, and perl was getting popular (around when perl 4 came out)... and python was still pretty obscure
<pattern_> so i learned perl
<pattern_> and loved it, btw
<pattern_> if i were to learn another scripting language, i think it would be ruby
<pattern_> but at this point i really don't have any reason to
<systems> i can't disagree
<pattern_> i might learn scheme or haskell, though
<Smerdyakov> I've learned way more than 12 languages.... but, as we all know, there are really only around 5 paradigm representatives you have to learn before almost everything else follows instantly.
<pattern_> simply because most functional programming docs and papers are geared towards scheme and haskell
<systems> s Smer, which langs do you think one should learn to cover those 5 paradigms
<pattern_> mozart:oz
<pattern_> ;)
<Smerdyakov> A minimal set of languages that covers: C-style low level, assembly, dynamically and statically typed functional, logic, object oriented
<Smerdyakov> Maybe that's it
<Vincenz> Ocaml is sexy
<Vincenz> pattern_: ruby is really good, it's very clean design-wise, and it's fully OO (more than Java)
<systems> hehe
<Smerdyakov> And is "fully OO" a good thing, Vincenz?
<Vincenz> Smerdyakov: well what I maen is...
<Vincenz> you can do "fdd".method
<Vincenz> instead of
<Vincenz> (new String("GFSD")).method
<Vincenz> 1.metho
<Vincenz> instead of (new Integer(1)).method
<Vincenz> so yes
<Vincenz> if you want OO, fully OO is better
<Smerdyakov> That's not terribly attractive to me.
<pattern_> vincenz, yeah, ruby looks interesting.. but ocaml is supposedly even better -> http://tinyurl.com/5wyt
<Vincenz> pattern_: I already know Ruby, and I didn't know of Ocaml back then, now I'm fully learning Ocaml :)
<Vincenz> oh yeah, already read that site
<pattern_> cool
<Vincenz> :P
<Vincenz> what's the big difference between List.fold_left and List.fold_right (besides the obvious)?
<Smerdyakov> Just so you know, Vincenz, "fdd".method is quite legal in Java.
<pattern_> one is tail recursive, iirc
<Vincenz> Smerdyakov: hmm, that's one of the shortcuts then
<Riastradh> Vincenz - One goes left to right, the other goes right to left.
<Smerdyakov> Shortcuts?!
<Vincenz> Smerdyakov: it prolly generates what I typed above
<Smerdyakov> A String is an Object in Java.
<Vincenz> Riastradh: yes, but besides that?
<Riastradh> Vincenz - That's the difference!
<Vincenz> Smerdyakov: hmm, ph yeah
<Smerdyakov> The only things that aren't are integer and floating point types.
<Vincenz> Riastradh: what's the point then?
<Vincenz> Smerdyakov: and bool, char...
<Smerdyakov> Those are integer types to me.
<Riastradh> Vincenz - List.fold_left (::) someList (* reverses a list *)
<Vincenz> Smerdyakov: you're a c-progger aren't you?
<Riastradh> List.fold_right (::) someList (* copies a list *)
<Smerdyakov> I know C. I mostly use SML, however.
<Riastradh> ...just an example of how you use them differently.
<Vincenz> Riastradh: but for typical uses like (add), ...
systems has quit ["Client Exiting"]
<Riastradh> Vincenz - Most people will use fold_left unless they explicitly need to return a sequence in the same order as the list.
<Riastradh> i.e., if you want to copy the list.
<Vincenz> ah
<Vincenz> alright :)
<Vincenz> (and what's the use of copying? lists are immutable anyways...)
<Riastradh> It was just an example!
<Vincenz> hehe
<Vincenz> Riastradh: I hope you never optimize my code
<Vincenz> :P
<Vincenz> let's copy things to fill ram, seeing neither of them will ever be altered
<Smerdyakov> Vincenz, ... you could try thinking a little harder about things before saying them :P
<Vincenz> Smerdyakov: I'm lazy
<Vincenz> but I was just kidding about the optimizations :)
<Vincenz> Smerdyakov: I'm a Ocaml-newb
<Smerdyakov> Yes, and "lazy" and "programmer" are a bad combination, despite what bad programmers will say. :P
<Vincenz> indeed
<Vincenz> why else learn Ocaml :P
<Vincenz> oh no
<Vincenz> lazy and programmer are a PERFECT combination
<Vincenz> don't forget I studied engineering, the quickest and shortest solution is the best
<Vincenz> (except when writing documentation, which I should be doing now :( _
<Vincenz> )
<Smerdyakov> There is a difference between lazyness and efficiency.
<Vincenz> I know
<Vincenz> but lazyness is good, YAGNI!
<Vincenz> Smerdyakov: and about the fold_left and fold_Right, I thikn having the choice is just syntactical flavouring
<Vincenz> so I was curious why they provided both
<Smerdyakov> No, there are efficiency differences.
<Vincenz> well one is more efficient than the other I'd presume
<Smerdyakov> Yes. You should be able to figure out which given that lists only have next-node pointers, not previous-node.
<Vincenz> check this code out, would you have done it any different?
<Vincenz> Smerdyakov: fold_left
<Vincenz> (if I got correct what it does..)
<Smerdyakov> Right
<Smerdyakov> Ah, you actually used higher order functions for one of yours!
<Smerdyakov> However, you can do all of these with higher order functions.
<Smerdyakov> Or almost all of the code, at least
<Vincenz> wasn't sure how
<Vincenz> (don't forget I'm new to ocaml, new to FP, and used to OO.... so I need a while to readjust to thinking in higher order functions)
<Vincenz> I guess contains could be based on List.exists
<Smerdyakov> OO and FP are not two choices for one decision, as is made clear by OO in OCaml....
<Vincenz> but that was the latest addition
<Vincenz> Smerdyakov: I know...but you know what I mean
<Smerdyakov> Yes, and the insert function can be written simply using the contains you already have.
<Vincenz> oh yeah
<Vincenz> like I said...cnotains only came into play at the very end
<Vincenz> so (if contains...don't add, else..add)
<Vincenz> right?
<Smerdyakov> You can write insert with map, but it would traverse more of the list than necessary.
<Smerdyakov> Yes
<Vincenz> hmm
skylan_ has joined #ocaml
<Vincenz> this was the easy exercise though
<Smerdyakov> Honestly, using a finite map structure would be better for this, if you actually want to use this graph structure somewhere.
<Vincenz> the other one was harder
<Smerdyakov> Since then you have all the work done for you.
<Vincenz> Smerdyakov: I had to to do it that way
<Vincenz> exercises in the ocaml-oreilly book
<Smerdyakov> OK
<Vincenz> this was the harder assignment
<Vincenz> took me a while to do some things
<Vincenz> all constructive criticism and suggestions are welcome, so I can learn from my mistakes :)
<Vincenz> I personally think the insert function is bloated, but I don't see another way
<Smerdyakov> It's a lot nicer if you explode the string to a list first....
<Vincenz> yeah I know
<Vincenz> I was thinking of doing that
<Vincenz> but since there was no internal function I never thought of writing one myself
<Vincenz> that way I could just recurse the main func
<Vincenz> plus
<Vincenz> (hmm, disregard that last comment, the argument still has to be a string)
<Vincenz> is there a shortcut for (String.make 1 somechar)?
<Smerdyakov> I don't know.
<Smerdyakov> It's String.explode in SML
<pattern_> there is an explode in the ocaml example progs
<pattern_> and possibly the faq
<Vincenz> pattern_: shouldn't be too hard
<pattern_> let explode s =
<pattern_> let rec expl i l = if i < 0 then l else expl (i - 1) (s.[i] :: l) in
<pattern_> expl (String.length s - 1) []
<Vincenz> yup :)
<Vincenz> any other comments on the tries-source?
<Vincenz> besides exploding strings?
<Smerdyakov> No, but I'm not really looking at it :P
skylan has quit [Success]
<Vincenz> alright
<Vincenz> what did you think of it at your first glance?
<Vincenz> good?bad?
<Smerdyakov> Fine, but perhaps better done by creating higher order functions for operating on the types you have created.
* Smerdyakov goes away: shower
<Vincenz> alright thank you :)
docelic|away has quit [Excess Flood]
docelic|away has joined #ocaml
polin8_ has quit [Read error: 104 (Connection reset by peer)]
polin8 has joined #ocaml
thedark has quit [Read error: 104 (Connection reset by peer)]
<Vincenz> hmm
<Vincenz> odd
<Vincenz> anyone good at mutables?
<Vincenz> I have a question
<pattern_> just ask
<Vincenz> let x = ref[];;
<Vincenz> x := (function y -> y)::!x;;
<Vincenz> - : ('_a -> '_a) list ref = {contents = [<fun>]}
<Vincenz> x := (function f -> f f)::!x;;
<Vincenz> This expression has type 'a -> 'b but is here used with type 'a
<Vincenz> it complains
<Vincenz> but!
<Vincenz> - : (('_a -> '_b) -> '_a -> '_b) list ref = {contents = [<fun>]}
<Vincenz> it changes the type but doesn't add it to the list...
<Vincenz> is this a bug?
<Vincenz> x := (function al -> al (+))::!x;;
<Vincenz> This expression has type 'a but is here used with type
<Vincenz> (int -> int -> int) -> 'a
<Vincenz> - : (((int -> int -> int) -> '_a) -> (int -> int -> int) -> '_a) list ref =
<Vincenz> it doesn't add the funcs but it changes the type-spec
<Vincenz> why?
karryall has joined #ocaml
<pattern_> vincenz, what was the statement that led to the type following your "but!" ?
<Vincenz> x;;
thedark has joined #ocaml
<Vincenz> (just inspected it again after I did x := (function f -> f f)::!x;;)
<Vincenz> I posted it to ocaml-bugs, perhaps they have answers :)
<Vincenz> vewy vewy odd
<pattern_> maybe you meant:
<pattern_> let x = [ ref ] ;;
<pattern_> ?
<Vincenz> no no
<Vincenz> ref [];;
<Vincenz> learn the sytnax on ref
<Vincenz> it creates a struct with one mutable
<Vincenz> like
<Vincenz> let x = ref 1;;
<Vincenz> x:= !x + 1;;
<Vincenz> x;;
<pattern_> and that mutable contains an empty list
<Vincenz> ref = {contents = 2}
<Vincenz> yes exactly :)
<pattern_> and that empty list is then replaced by what you put in later
<Vincenz> no
<Vincenz> I add it on
<Vincenz> (function f -> f f)::!x
<Vincenz> ::!x
<Vincenz> well yeah, I make a new list..but you get the idea
<karryall> is this an instance of the "type variable cannot be generalized" FAQ ?
<Vincenz> not sure
<Vincenz> do you have a reference for it?
<Vincenz> (url?)
<karryall> see the entries about '_a
<Vincenz> hmm, doesnt' say
<Vincenz> I know what '_a means
<pattern_> "When an identifier is defined by an expression which cannot be generalized, the identifier can have a type with unknowns (that is type variables which cannot be generalized) which will be determined (that is assigned a type value) by the usage of the identifier in the rest of the program. These unknown types are special type variables, prefixed by an underscore (e.g. '_a). Beware, these variables stand for unknown types to be determined by
<pattern_> ype checking process: that's why these variables may disappear, precisely because their type value has been discovered."
<Vincenz> I know
<Vincenz> but still...
<Vincenz> it does the type checking process, changes the type but DOESNT ADD THE FUNCTION THAT CAUSED THE CHANGE IN TYPE
<karryall> what's your problem exactly ?
<Vincenz> let x = ref[];;
<Vincenz> x := (function y -> y)::!x;;
<Vincenz> x := (function f -> f f)::!x;;
<Vincenz> the last statement changes the type but doesn't add the function
<karryall> oh
<Vincenz> odd, don't you think?
<pattern_> not in light of the part of the faq i just quoted
<karryall> that's because fun f -> f f is not typable
<karryall> that's unrelated to the ref
<Vincenz> sure f -> f f is typeable
<Vincenz> very easy
<Vincenz> ('a -> 'a) -> ('a -> 'a) (I think)
<Vincenz> oh yeah, damn it
<Vincenz> I thought it was typeable
Vincenz has left #ocaml []
Vincenz has joined #ocaml
<Vincenz> oops
<Vincenz> you're right it doesn't work
<Vincenz> but why does it change the type then?
<Vincenz> of x?
<Vincenz> (also in scheme it works....
<pattern_> the unknowns "will be determined (that is assigned a type value) by the usage of the identifier in the rest of the program..."
<Vincenz> ((\x.x x) (\x.x x)) causes an infinite loop)
<karryall> it works with recursive types
<Vincenz> pattern_: yes but it restricts my type again!!!
<karryall> use ocaml -rectypes
<Vincenz> ah thank you :)
<karryall> # fun f -> f f ;;
<karryall> - : ('a -> 'b as 'a) -> 'b = <fun>
<Vincenz> alright :)
<Vincenz> still don't get why it restricts the type of x though...
<karryall> because the typing begins ... it sees that f is a function, so it restricts the type of x a bit
<Vincenz> but then it rejects f..
<karryall> and then the typer sees a problem and stops but x is left with the restricted type
<Vincenz> that sux
<karryall> that's just a consequence of using toplevel and '_a type variables
<karryall> not really a problem with compiled files
<Vincenz> alright
<Vincenz> karryall: care to look at some code I wrote and perhaps give some constructive criticism?
<karryall> sorry, I don't have time to look at it in detail
<karryall> the code looks nice (functional style)
systems has joined #ocaml
mellum has quit [Read error: 60 (Operation timed out)]
<Vincenz> thank you :)
<Vincenz> I'm new to functional programming so
<thedark> is somebody familiar with the rabin miller test?
<karryall> thedark: what's that ?
mellum has joined #ocaml
systems has quit ["Client Exiting"]
<Vincenz> thedark: primality testing?
karryall has quit ["bye"]
<thedark> Vincenz: yes
<Vincenz> I just refreshed my memoery
<Vincenz> what about it?
<thedark> well i'm supposed to do something for every j with 0<j<l .. my problem is that l can sometimes be equal to 0 .. so 'im a little confused with this test ...
<mrvn_> Why?
<thedark> well it seems i've my answer.. it was obvious...
<thedark> the test is designed for odd numbers only....
<mrvn_> thedark: 0<j<l means (0<j) && (j<l)
<mrvn_> no harms done if both are false.
<thedark> yes ... l was equal to 0 for even numbers.. but the test is not designed for thoses...
<mrvn_> still works.
<mrvn_> have those all the time.
<thedark> i have a function that takes a big_int parameter.. how can i launch it ... fun (big_int_of_int foo) is not what i want...
<thedark> let k = Random.int (2^30) in <- whats wrong with this, ocaml tells me about 2 :This expression has type int but is here used with type string
<thedark> hmm another way to ask my question : how do u write a^b in ocaml?
<mellum> a**b
<thedark> ok:)thx
<Smerdyakov> Maybe it would help if you said what you want ^ to do.
<Smerdyakov> I know of 4 completely different meanings for it in various programming languages.
<mellum> Pointer dereferencing, power, xor and string concatenation?
<Smerdyakov> Yay! You got them!
<mellum> Do I get w washing machine?
<Smerdyakov> You get x washing machine.
<mellum> s,w,a,
<thedark> let k = Random.int (2**30) in tells me about 2 :
<thedark> This expression has type int but is here used with type float
<thedark> any ideas on how to solve this ?
<mellum> thedark: use lsl
<thedark> lsl?
<mellum> logical shift left
<mellum> pow is for floating point
<thedark> oh ok:) good idea:)
<thedark> i cant find lsl in the keyword index...
<thedark> and is lsl working for big ints?
<mellum> lsl is for ints only.
<mellum> Everything except = and < is for one type only.
<thedark> let k = Random.int (lsl 1 30) in <- syntax error on the " 1 " ...
<mellum> lsl is infix
<thedark> oh ok
mrvn has joined #ocaml
mrvn_ has quit [Read error: 110 (Connection timed out)]
<Vincenz> or
<Vincenz> ((lsl) 1 30)
<Vincenz> (never mind...only works for symbolix infix operators_
Vincenz has quit [Read error: 104 (Connection reset by peer)]
_ has joined #ocaml
_ is now known as Vincenz
<Vincenz> hmm
<Vincenz> question about dualview
<Vincenz> ugh, I hate it that labels of different records have to have different names
<mellum> Well, usually you put stuff in different modules, so it's not that bad
<Vincenz> anyone care to look at some code, it keeps giving me a warning and I don't know why
<Vincenz> it's in the last function
<Vincenz> File "D:/Mijn Documenten/Coding/Projects/OCaml/matrix.ml", line 45, characters 3-280:
<Vincenz> Warning: this function application is partial,
<Vincenz> maybe some arguments are missing.
<Vincenz> any clues?
<Vincenz> I added the begin
<Vincenz> but with or without that begin the effect is the same
<Vincenz> it's on that first print
<Vincenz> any clues?
<Vincenz> line 45
<Vincenz> :(
<mellum> Hm, the line number is wrong, it means line 57
<mellum> weird
<Vincenz> why, what's wrong with line 57?
<mattam_> add ()
<mattam_> to print_newline
<mellum> well, as the message says
<Vincenz> oh!!!
<Vincenz> doh
<mellum> You generate a closure from print_newline. That has no effect.
<Vincenz> Yay!
<Vincenz> thank you so much :)
mattam_ is now known as mattam
<mellum> The whole "begin" block will then be unit->unit, that's why you get a warning in line 45
* Vincenz nods
<mellum> It's useful to use something like emacs that will color the exact range given in the error message
<Vincenz> heh
<Vincenz> what do you think of the code by the way?
<Vincenz> (I had to implement it with records, and the chapter is on imperative programming...)
<mrvn> Vincenz: you do know that they don#t have to have different names, right?
<Vincenz> (it's not homework, I'm reading the pdf-translation of the oreilly book of ocaml)
<Vincenz> mrvn: how so?
<Vincenz> yes they do
<mrvn> They don't. Not at all. Its just plain and simple shadowing of bindings that occurs.
<mrvn> You can rebind them to something else. Write accessor functions and such
<Vincenz> ah, i see :)
<Vincenz> type-def, accessor funcs, type-def 2, accessor funcs 2..?
<mrvn> as an example.
<mrvn> Works wonders if you have multiple structures with a prev and next field.
* Vincenz listens
* mrvn wonders what he listens for
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
<Vincenz> mrvn: but you'd have to define each accessor right after the type, right?
clam has joined #ocaml
<seth_> I have an error message I don't understand. sock is a file_descr, saddr is a sockaddr, but for the statement "Unix.bind sock saddr" I get "This expression has type int -> Unix.file_descr but is here used with type Uhix.file_descr"
<seth_> but bind has type: file_descr -> sockaddr -> unit
<clam> seth_: your sock is int -> Unix.file_descr then
<clam> probably missed an argument somewhere
<seth_> clam: yes, but why? it is returned by the socket call. No, no missing args.
<clam> seth_: show me how you obtained it
<seth_> clam: It's a line I've used before, but maybe there is a flaw in it: val sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM;
<seth_> hmm, UnixLabels has a different definition for socket
<seth_> clam: you are right, it's a partial application.
<clam> seth_: it's not me, its occam
<seth_> I wonder why it worked before. :)
<clam> to quote 'i myself am often surprised at life's little quirks'
<seth_> hmm, not it doesn't like this: let (cfd,csaddr) = Unix.accept sock
<seth_> s/not/now/
<clam> val accept : file_descr -> file_descr * sockaddr
<clam> is all i can say about it
<seth_> I'm getting a syntax error. must be in a previous line.
stepcut has joined #ocaml
c1am has joined #ocaml
<seth_> How do I do a forward reference? I have two classes that need to reference each other.
<Smerdyakov> The standard solution for normal modules is to functorize one in terms of the other.
<c1am> Smerdyakov: bullcrap
<c1am> came up with a signature for those classes
<c1am> code
<c1am> profit
<Smerdyakov> Not exactly that.... you have to break up functionality a wee bit.
<c1am> again load of bull
<Smerdyakov> Well, I've done it.
<Smerdyakov> So ha.
<seth_> Smerdyakov: explain the issue to me.
<Smerdyakov> I'm trying to remember the details.
<seth_> I don't see how signatures will help, since then the signatures will still reference each other.
<seth_> but, I don't see anything in the docs saying I can use the "functor" statement inside of a class.
<seth_> or maybe I use it outside the class
<seth_> the same way as if the module defines functions instead of classes.
<Smerdyakov> I guess if the signatures reference each other you are in trouble.
<seth_> I don't see how, if the classes reference each other, the signatures can _not_ reference each other.
<Smerdyakov> Indeed. I don't ever use OO, so I have no insights into this.
<Smerdyakov> I do know that it very rarely makes sense to use OO.
<Smerdyakov> I hope you have a good reason.
<seth_> that's a separate issue. I still have the forward reference problem even if I don't use classes.
<Smerdyakov> Why do you want forward reference?
<Smerdyakov> What modular decomposition are you using where that makes sense?
<seth_> it's somewhat complicated, but there are many classic software patterns with forward references.
<Smerdyakov> In functional languages?
<c1am> create signature for class a, class b
<c1am> put mutable var in class a of type sig b
<c1am> likewise for b
<c1am> d'oh
clam has quit [Read error: 110 (Connection timed out)]
<Smerdyakov> Most "classic patterns" are hobbled versions of easy functional techniques.
<seth_> c1am: that's ugly.
<c1am> seth_: that wroks
<c1am> works
<seth_> Smerdyakov: no, I don't agree with that at all. Why are you using ocaml if you hate objects?
<c1am> cause they suck
<c1am> slow useless spawns of evil
<Smerdyakov> seth_, I'm not using OCaml. I may be using OCaml soon, but I really just use SML at the present, and I won't use the O in OCaml if I can help it.
<seth_> I see no reason not to use it where it makes sense.
<Smerdyakov> Yes, but you have to justify that it makes sense...
<c1am> it never makes sense, just take a look at compiler sources
<seth_> I'm not really an OO person, but it is just foolish to claim that oo is useless.
<c1am> it's only used in the heart of ocamlopt
<liyang> c1am: (slowness is not an issue, maintainability _is_. If you want speed go play with assembler. ;)
<c1am> which means its EVIL
<c1am> liyang: FUCK YOU
<c1am> in fact fuck you all
<seth_> c1am: that's very enlightening.
<Smerdyakov> seth_, excuse me, but who claimed that OO is useless?
<seth_> c1am: go back to playing with yourself.
<seth_> Smerdyakov: c1am
<c1am> seth_: you think so.. hmm, maybe i will
<Smerdyakov> Oh. But c1am seems to be installed here solely for entertainment value.
<seth_> OK :)
<seth_> can I use a parameterized class for my problem?
<liyang> (didn't realise the debate was this heated. <g> I think I'll stay out of this one. :o)
<seth_> liyang: not heated as far as I can see. well, a certain amount of hot air, yes...
<c1am> geez..
<c1am> you spoil quite healthy discussion here
<Smerdyakov> seth_, sounds like no.... but, again, I reaaaally think you should reconsider wanting forward reference!