<zvrba>
but still I don't get immediate output to stdout
<zvrba>
ah, print_endline :)
love-pingoo has joined #ocaml
chessguy has joined #ocaml
DRMacIver has joined #ocaml
chessguy has quit [Read error: 104 (Connection reset by peer)]
Smerdyakov has joined #ocaml
DRMacIve1 has quit [Read error: 110 (Connection timed out)]
chessguy has joined #ocaml
DRMacIve1 has joined #ocaml
<flux__>
zvrba, the Printf-module is useful. Printf.printf "%d\n%!" d
chessguy has quit [Connection timed out]
chessguy has joined #ocaml
DRMacIver has quit [Read error: 110 (Connection timed out)]
DRMacIver has joined #ocaml
DRMacIve1 has quit [Read error: 110 (Connection timed out)]
pango has quit ["Leaving"]
pango has joined #ocaml
Wild_Cat has joined #ocaml
velco has quit ["Ex-Chat"]
DRMacIve1 has joined #ocaml
Smirnov has joined #ocaml
<Smirnov>
Hi guys, I was looking through the manual and I was wondering where to find functions like print_string, cause I am trying to print a string on its own line and usually languages have their own print_line
<Smerdyakov>
Pervasives
mnemonic has joined #ocaml
<Smirnov>
Thanks much :)
<Wild_Cat>
by the way, is there a function in the Ocaml interpreter similar to Python's dir() -- that is, one that lists the contents of a module?
<Smerdyakov>
No. Like type information, module signatures are lost during compilation.
<Wild_Cat>
that's too bad. Thanks anyway.
_velco is now known as velco
<mnemonic>
hi
DRMacIver has quit [Read error: 110 (Connection timed out)]
sreeram has joined #ocaml
<Smirnov>
so ocaml is more like C where it loses type information?
<Wild_Cat>
yeah, but in C it's possible to ignore that information at compile-time. Not in Ocaml.
<Smirnov>
ok
<Smirnov>
so there's no duck typing in ocaml then ?
<ski>
in one sense, there is
<love-pingoo>
That's not exactly accurate.. in C you need to bypass the type info all the time, in OCaml you don't need -- but you can explicitely do casts too, using black Obj.magic.
<love-pingoo>
Smirnov: to me, most of "duck typing" is in structual subtyping
<love-pingoo>
OCaml OO has a great structural subtyping scheme, very "ducky"..
<Smerdyakov>
Dynamic typing is superceded by static typing, when you have a strong enough type system (like Coq does).
<Wild_Cat>
yeah, I think you can say Ocaml uses duck-typing in its OO scheme.
<Smirnov>
I haven't done any OO in ocaml yet, :(
<Smerdyakov>
Smirnov, good. It's lame. :P
<Wild_Cat>
neither have I, only read stuff in tutorials ^^
<Smirnov>
I tried doing "foo".length and that didn't work so I gave up
<Smerdyakov>
Most OCaml users don't use the OO.
<Smirnov>
but i like OO land :-\
<Wild_Cat>
but the type inference system validates arguments not from their types, but from the methods/attributes that are used in the function.
<Wild_Cat>
Ocaml's OO looks like it's been bolted on.
<love-pingoo>
OO in OCaml is worth trying, if you're writing software in OO-friendly domains
<Wild_Cat>
guess so. GUIs, for example.
<Smirnov>
ocaml looks hardcore
<Smerdyakov>
Smirnov, Coq is even more hardcore! It is the future!
<Smerdyakov>
Programming and proving are the same thing.
<love-pingoo>
part of "programming" has been explained that way
<Smerdyakov>
Nope, it all has. :)
<love-pingoo>
Smerdyakov: why aren't you doing haskell by the way ? you should love the separation between pure coq-explainable and dirty I/O code.
<ski>
"haskell isn't pure enough"
<Smerdyakov>
Haskell is too impure for me.
<love-pingoo>
Smirnov: forget about these fights for the moment ;p
<Smirnov>
wtf?
<Smerdyakov>
This isn't a ridiculous aesthetic squabble; try proving the correctness of your Haskell program and you will see the trouble.
<Smirnov>
wow man you guys are hardcore functional people
<love-pingoo>
not everybody wants to prove formally correctness (Smirnov probably doesn't care) and not everything can be written in Coq
<love-pingoo>
I love that tool, but there are limits, that's all
<Smirnov>
i dont even know what correctness is
<love-pingoo>
forget about that for now and go enjoy OCaml, then :)
<Smirnov>
ok
<Smerdyakov>
I disagree. Everything can be written in Coq.
<Smerdyakov>
It's a Turing-complete programming language.
<Smerdyakov>
(When you use a non-termination monad)
<Smirnov>
wow you're not going to believe the homework problem that i just had
<love-pingoo>
why are you still using OCaml ? did you every formalized what an IRC client was ? and so on...
* love-pingoo
stops trolling
<Smerdyakov>
love-pingoo, ATM, I use OCaml to write Coq plug-ins. :)
<Smirnov>
Write a function app3 that takes a function needing 3 arguments, followed by each of the 3 arguments, and applies the function to the 3 arguments
<Smirnov>
it cant get any more trivial than that
<ulfdoz>
use id, it fullfills the spec. ;)
<ski>
curried or not (respectively for 'app3' and the argument function) ?
<Smirnov>
curried
<Smirnov>
they give us the signature
<Smirnov>
let app3 f x y z = ...
<Smirnov>
i wonder if they think we are in beginning cs?
<ski>
('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd
<Smirnov>
yes that would be the type
<Smirnov>
pretty funny cause you just put f x y z again and you're done
<Smirnov>
it takes more writing to invoke that function than to describe it :(
Wild_Cat has quit []
<Smirnov>
oh well, i'm sure its gonna get harder, i'm in a programming languages course
<Smirnov>
Does the word "permutation" carry a special connotation in Ocaml?
Snark has quit ["Leaving"]
Mr_Awesome has joined #ocaml
<ski>
not that i know
<Smirnov>
Ok they must be talking about a regular permutation then
<Smerdyakov>
Smirnov, at which university?
<Mr_Awesome>
i have a module B that uses module A, and I'd like to quickly make an interface file to B.ml. however, when i run ocamlc -i A.cmo B.ml i get errors about things in B that are defined in A. is there any way to create an interface file with ocamlc when the module depends on another?
mnemonic has quit ["leaving"]
<Smerdyakov>
Mr_Awesome, you're using the recursive module extension? Traditionally, modules _can't_ depend on each other.
<Mr_Awesome>
oh, didnt know that
<pango>
Smerdyakov: I don't think he meant cross-dependancy
<Smirnov>
do I need to do something special to use Int, String, etc?
<Mr_Awesome>
i mean B depends on A, not A depends on B
<Smirnov>
Smerdyakov: university of illinois at urbana champaign
<Mr_Awesome>
Smirnov: hey, im going there in year
<Smirnov>
for grad school ?
<Smerdyakov>
Mr_Awesome, oh.
jcreigh has joined #ocaml
<Mr_Awesome>
as a freshman
<Smirnov>
congrats
<Smerdyakov>
Mr_Awesome, I just use OCamlMakefile and don't worry about the magic incantations.
<Smirnov>
Mr_Awesome: you got accepted already... its september?
<Mr_Awesome>
trust me, ill get accepted
<Mr_Awesome>
im applying this weekend
<Smirnov>
oh you should've said that
<Mr_Awesome>
anyway, the ocaml makefile doesnt create .mli files for me
<pango>
Mr_Awesome: is the A.cmo really necessary ?
<Smirnov>
Int/String? :(
<pango>
Mr_Awesome: a possible problem is that, while module names take a capital letter, the module file names start with a lowercase
<Mr_Awesome>
my filenames start with lowercase
<Mr_Awesome>
i have open A at the top of b.ml, so if i ever try to compile anything with just B, of course i get an error
<Mr_Awesome>
but even when i include a.ml or a.cmo, it still gives the same error
<pango>
Mr_Awesome: ok then.. here, with a.cmo already build, ocamlc -c -i b.ml works just fine
<pango>
maybe it's the -c ?
<Mr_Awesome>
why do i need the -c?
<pango>
-c Compile only
<Smerdyakov>
Mr_Awesome, I didn't know there was any OCaml tool to create mli files automatically.
<Smerdyakov>
Mr_Awesome, I can't think of a situation when I'd want to do that.
<Mr_Awesome>
its a quick way to get all of the definitions into an mli file, then you edit it later
mnemonic has joined #ocaml
<Smerdyakov>
I think it's useful to write your mli files from scratch. Write them before their ml files, even.
<Mr_Awesome>
i suppose so
<Smerdyakov>
Writing a large ml file before writing its interface is probably a bad idea, and this -i won't save you much time if you use it when the ml file is still small.
<flux__>
why would it be a bad idea?
<Smerdyakov>
flux__, it's a period of not taking advantage of separation between interface and implementation.
<Smerdyakov>
Mr_Awesome, what makes UIUC your first choice?
<flux__>
but it's taking advantage of the type inference removing your work or writing types
<flux__>
anyway, I usually start without an mli, but when the module reaches a certain size, I use ocamlc -i and then keep maintaining it
<Smerdyakov>
The whole point of interface files is that you give values _different_ types in them than in implementations.
<Mr_Awesome>
if nothing else, its a good way to find out what ocaml thinks the types are
<flux__>
hm, I don't think I'm quite following?
<Mr_Awesome>
Smerdyakov: from what i can tell, its one of the best (if not the best) college in illinois
<Smerdyakov>
Mr_Awesome, OK, but not in the world or even the country.
<Smerdyakov>
flux__, ml file contains : val f : int -> int
<Smerdyakov>
flux__, mli file contains : type t val f : t -> t
<Mr_Awesome>
Smerdyakov: my parents want me to stay in the midwest
<Smerdyakov>
Mr_Awesome, OK, but you should just recognize that that choice is against your best interests.
<Smerdyakov>
It's not as big of a deal for undergrad, but going to grad school at UIUC when you have other options would be a big mistake.
<Mr_Awesome>
how so? uiuc is great university
<Smerdyakov>
For CS, Berkeley, CMU, MIT, and Stanford are much better.
<Mr_Awesome>
MIT is out of my league; i dont have that much money
<flux__>
smerdyakov, well yes, but for small programs thats not really that essential - single developer
<Smerdyakov>
Mr_Awesome, it would be worth taking out loans.
<Smerdyakov>
flux__, I use abstraction all the time in single-developer programs.
<Smerdyakov>
flux__, it's not a question of what's _necessary_, but rather what is worthwhile.
<flux__>
smerdyakov, I think the example was simplifying a bit, usually one (well, I) doesn't do type t = int, but something with a constructor to avoid accidental type errors even within the same module
<Smerdyakov>
flux__, I have several examples in code I've written recently of abstract types implemented with int.
<flux__>
and if you're using the module from some other module, it's not likely you'll use the concrete type by accident
<flux__>
I suppose that's a difference in our styles then
<flux__>
s/in/between/
<Mr_Awesome>
in my module, i use a function that requires random numbers. should i include Random.self_init () in this module?
zmdkrbou_ has joined #ocaml
zmdkrbou has quit [Read error: 110 (Connection timed out)]
<Smerdyakov>
Mr_Awesome, probably
<Mr_Awesome>
ok
<Smirnov>
How come using Int 5;; gives me an unknown constructor error?
<Smerdyakov>
Why wouldn't it?
<Smirnov>
cause ocaml-tutorial.org is doing it :(
<Smerdyakov>
They probably defined the Int constructor first.
<pango>
Num module is not loaded by default (much less opened)
Snark has joined #ocaml
mnemonic has quit ["leaving"]
beschmi has joined #ocaml
<Smirnov>
How do you end a match?
<Mr_Awesome>
you dont
<Snark>
you win or you lose...
<Smerdyakov>
Bracket it in parentheses or begin..end if needed for order-of-operations.