<Number17>
by any chance does anyone know what's wrong with this? List.sort(compare;[3;1;9;12;2]);; from the docs it seems correct, however the interpereter gives me a warning and doesn't return the desired results
<whee>
are you sure you mean a semicolon after compare?
<Number17>
well, it was giving me an error if I put a comma there
<Number17>
# List.sort(compare,[3;1;9;12;2]);;
<Number17>
This expression has type ('a -> 'a -> int) * int list
<Number17>
but is here used with type 'b -> 'b -> int
<whee>
oh, haha I'm stupid
* Number17
is a novice
<whee>
you're calling it incorrectly; remove the outer parens and replace the first semicolon with a space
<whee>
I'm quite a bit rusty :P
<Number17>
awesome :)
<Number17>
thanks
<whee>
you were giving it a single argument (a tuple) of the function compare and the list, so you got the error
<Number17>
ahh, so O'Caml uses Haskellish calling syntax instead of C
<whee>
indeedy
* Number17
should have suspected that
<whee>
going through the tutorial?
<Number17>
no, I was reading the manual and trying to make a simple program
<dan2_>
Smerdyakov: ideally, not many people use sml or ocaml
<dan2_>
r2d4: its comfortable
<Smerdyakov>
dan2_, what?
<dan2_>
:)
<dan2_>
Smerdyakov: can sml do real concurrency without the stupid global gc lock?
<Smerdyakov>
SML has Concurrent ML, which is quite real enough for me.
<Smerdyakov>
What you're asking seems to be a question about a compiler and runtime implementation, not a language.
<dan2_>
Smerdyakov: then are there implementations that do this?:
<Smerdyakov>
r2d4, but, hey, I'd still love to explain why you're getting that syntax error, if I can see the program. ;)
<r2d4>
Smerdyakov: the question is not really about this code.
<Smerdyakov>
dan2_, I'm not sure what you're asking. Are you talking about utilizing multiple processors for the same application?
<dan2_>
yes
<Smerdyakov>
dan2_, the better term for that is "parallelism," not "concurrency."
<r2d4>
I have generally found that OCaml gives me a lot of syntax errors without further explanation.
<r2d4>
I have recently been using Python for most part.
<Smerdyakov>
dan2_, I'm not aware of any fundamentally parallelized ML implementations.
<dan2_>
r2d4: hmm
<Smerdyakov>
r2d4, I have no problems with that
<Smerdyakov>
r2d4, syntax errors are no problem if you learn the language.
<dan2_>
r2d4: it takes some time
<r2d4>
I got better messages there. I am actually moving to functional languages as an occational alternative for Python.
<dan2_>
Smerdyakov: that sucks
<dan2_>
r2d4: I like python
<{[mono]}>
what explanation?
<dan2_>
ocaml has a nice strong typing system
<Smerdyakov>
r2d4, you will not get anything better if you stick with OCaml. We can answer individual questions about why you are getting syntax errors.
<r2d4>
Smerdyakov: thanks. for now I will stick to reading the manuals better. I don't have IRC worthy questions yet.
<Smerdyakov>
r2d4, "why is this syntactically erroneous?" is quite IRC-worthy.
<dan2_>
time to do that music searching thing
<dan2_>
:)
<{[mono]}>
ocaml tells me the like of "line 5 chars 4-10" I'm quite happy with that.
<r2d4>
most of my errors currently are because I have not understood reading the method signatures from ocaml browser
<Smerdyakov>
ml-yacc-based parsers say things like "error at THIS_TOKEN; inserting THAT_TOKEN."
<r2d4>
back in 10 min.
<Smerdyakov>
r2d4, I don't know what most people do, but I never use the ocaml browser.
<Smerdyakov>
r2d4, I just look at .mli files.
<Smerdyakov>
There's something to be said for the value of a consciously ordered presentation of this kind of information.
<Smerdyakov>
I just want to take this opportunity to plug Don Syme's Abstract IL library for F# (AKA OCaml.NET).
<Smerdyakov>
The .mli files are super-effective documentation.
* Smerdyakov
dies trying to imagine something like this for C#.
<r2d4>
back
<r2d4>
I have been looking at F# for the past few days.
<Smerdyakov>
Don't use it unless you work at Microsoft.
<Smerdyakov>
If you do, it's a godsend. :D
<r2d4>
The Visual Studio plugin is fantastic.
<r2d4>
One thing good about F# is there is a large standard library. So I don't complain I can't do something due to library non-familiarity while learning.
<r2d4>
On the other hand the lib built with C# in mind.
<Smerdyakov>
That's a cop-out: you still need to be familiar with the .NET SDK.
<dan2_>
C# is pain
<dan2_>
more pain than Java
<dan2_>
:(
<r2d4>
Well! I do know .NET about enough.
<r2d4>
And there is plenty of docs on MSDN and on the web.
<Smerdyakov>
ML documentation is fundamentally more effective than C# documentation.
<r2d4>
dan2_: actually I find C# experience much better than Java's
<r2d4>
Smerdyakov: It's not just the docs. It's the little examples.
<dan2_>
a lot of people say that
<Smerdyakov>
"Little examples" I consider part of documentation.
<dan2_>
yet I can't compel myself to code on an m$ based language
<dan2_>
its pain
<dan2_>
I still refuse to learn basic
<Smerdyakov>
You don't need examples to learn how to use an ML module without reading anything but compiler-checked code.
<r2d4>
dan2_: your reasons are idealogical then.
<r2d4>
dan2_: you don't need to learn basic. I completely abandoned it several years ago.
<dan2_>
just my point
<dan2_>
I know, C, C++, Ocaml, Python, Perl, Some PHP, Java
<r2d4>
Smerdyakov: I don't know. I am used to working with examples. Take Python docs for example. They are not API docs. They are often a bit tutorial-ish
angagon has joined #ocaml
<dan2_>
r2d4: heh
<r2d4>
dan2_: About the same language spectrum, sans OCaml, plus Delphi.
<Smerdyakov>
r2d4, and cave men were used to doing everything with rocks.
angagon has left #ocaml []
<r2d4>
dan2_: I find Visual Studio C# a good compromise.
<dan2_>
I haven't used Windows on my desktop in YEARS
<dan2_>
r2d4: which is why C# still doesn't make sense for development
<r2d4>
dan2_: That explains.
<dan2_>
I'm content with IntelliJ IDEA and Java
<r2d4>
Smerdyakov: ???
<r2d4>
dan2_: IntelliJ is now getting C# in.
<Smerdyakov>
r2d4, I'm saying that learning by example is less efficient than learning by type.
<dan2_>
r2d4: I am using IntelliJ IDEA 5.0 eaps, it has no C#
<dan2_>
but you can get C# support by buying reshaper
<dan2_>
resharper even
<{[mono]}>
Suppose there are N functions to be learned. You could give N examples, one for each function; or you could give N + N^2 + N^3 + ... examples, one for each possible composition of the functions. Those people who call themselves "I learn best from examples" mean the latter, not the former.
<dan2_>
erm nevermind
<dan2_>
still requires studio.net
<Smerdyakov>
{[mono]}, and are you claiming that the groups-of-functions example paradigm works better than types?
<r2d4>
Smerdyakov: why do you say that? Personal observation? I agree there is a tendency to learn incompletely of a module when learning by example.
<{[mono]}>
No, I don't think so.
<Smerdyakov>
r2d4, personal observation, and basic observations about how a type gives absolute information and examples leave holes.
<r2d4>
Smerdyakov: They need not be mutually exclusive.
<r2d4>
Smerdyakov: I like examples when I am starting out. Less intimidating. I later move to API when I am comfortable.
<Smerdyakov>
I claim that a competent ML programmer can skip the examples stage.
<{[mono]}>
I say that statement to blow the cover of "I learn best from examples".
<r2d4>
Smerdyakov: Ah! There lies the problem. I am not competent yet :-)
<{[mono]}>
Notice that if you have done all N + N^2 + N^3 + ... examples, you have also done the work for the reader.
<{[mono]}>
So you can deduce that "I learn best from examples" means "I learn best from your doing my work."
<r2d4>
{[mono]}: Examples by definitions mean "Partial but common". I don't think N + N^2 ... argument is valid here.
<r2d4>
{[mono]}: No "learn by example" documentation, for example, Perl/Python CookBook (I know there is one for OCaml on the web) do not attempt to cover all possible combinations. They only try to be a little less abstract.
<Smerdyakov>
{[mono]}, I don't believe that examples can be complete enough to "do the work for the reader."
<r2d4>
{[mono]}: Maybe it is just me. I know a lot of programmers find JavaDoc style information useful. I don't except for it's use for tooltips in an IDE.
<Smerdyakov>
{[mono]}, if there are common patterns that the reader can ape, then these patterns ought really to be encapsulated in single functions.
Frederick has quit ["Leaving"]
ulfdoz has joined #ocaml
<{[mono]}>
Examples cannot be complete. Yet I-learn-from-examples does ask for complete examples (at least complete enough to trivialize his work.) So you can conclude that he is asking the impossible and unreasonable.
<{[mono]}>
There is also a cultural gap between the imperative programmers and the functional programmers. (This is gap is not necessarily caused by imperative programming or functional programming.)
<r2d4>
{[mono]}: What I would like to see is something like http://javaalmanac.com/ for every language.
<r2d4>
{[mono]}: I think we have different goals. My goal is never to learn a library. My goal is to produce functionality with the least amount of effort required.
<Smerdyakov>
ML doesn't need such a thing, because it sucks less.
<{[mono]}>
If a library is designed badly, not all combinations (not even all N^2) are sensible; probably only 5 combinations are ever used. (Like Smerdyakov says.) An example is the unix socket library: you must always follow one of a few recipes.
<r2d4>
Smerdyakov: I agree Java needs this more, especially since I feel much of the libs are over engineered, at least from my stand point.
ulfdoz_ has quit [Read error: 110 (Connection timed out)]
<{[mono]}>
Then there are two things you can do. The right thing to do is to forget it and create/use a higher-level library that provides just 5 functions, one to replace each of the old useful combinations.
<{[mono]}>
The wrong thing to do is to write a cookbook on those 5 combinations.
<Smerdyakov>
The rightest thing to do if you're using a non-trivial imperative API is to use finite state machine types to express how it must be used. :-)
<{[mono]}>
Imperative programmers tend to do the latter alot. After a while they're used to it as a fact of life. When they see a new library, they expect a corresponding cookbook.
<{[mono]}>
Functional programmers tend to do the right thing. They have a library in which all functions are orthogonal to each other (I'm exaggerating, of course life cannot be that ideal). All combinations make sense. You cannot, and you need not, provide a cookbook covering all useful combinations; if you understand each function alone, then you also understand their combinations.
<Smerdyakov>
Heeeey, who's going to CONCUR/SPIN 2005?
<{[mono]}>
So now we have a cultural clash. An imperative programmer comes into functional programming, then cries "where is the cookbook! you have no cookbook! this is impractical!"
<dan2_>
I went from imperative to functional
<dan2_>
and after I fully understood functional programming
<dan2_>
my skill set was dramatically improved
<{[mono]}>
There is also a point caused by functional programming. There are patterns in functional programming too. But since we are used to higher-order functions, our patterns tend to be highly parameterized.
<dan2_>
helped me design code much more efficiently, and with much better tactics
<Smerdyakov>
The patterns in functional programming are reified in the language.
<Smerdyakov>
(If you're doing it properly!)
<{[mono]}>
A common pattern goes like "fold (unfold (x))". "unfold" may be any function that generates a large data structure; "fold" may be any function that consumes that large data structure. There are N possible unfolds, and N possible folds. It is reasonable to give 2N examples. It is unreasonble to ask for N^2 examples.
Herrchen has joined #ocaml
<Smerdyakov>
I like to write a new function that is equivalent to that composition.
<{[mono]}>
It has been written. It's called function composition.
<Smerdyakov>
Compilers don't generally compile composition to be efficient enough.
<Smerdyakov>
If you have a separate name for the composition, you're free to be as fancy as you want in its definition.
<{[mono]}>
Some compilers (e.g. ghc for haskell) can recognize the data structure in-between, then do deforestation to eliminate it.
<{[mono]}>
Yes, true.
<Smerdyakov>
I'll be surprised if there is some comprehensive sense in which ghc recognizes all such patterns and removes all overhead.
<{[mono]}>
Heh, of course, ghc doesn't recognize all data structures. It works best if the in-between is a list.
<Smerdyakov>
Not to mention that it's unclear to me that it's better to write the more verbose version in the first place.
Herrchen_ has quit [Read error: 60 (Operation timed out)]
<{[mono]}>
Alright, there are optimization issues. But the point is that a pattern in functional programming tends to be very general. It can go like "f . g" where you can almost plug in anything for f and g. Yes, you can say you have a function that stands for the pattern; but the function is a higher-order function.
<{[mono]}>
This is something the imperative programmer is not used to. There is no cookbook; there cannot be a cookbook; there needs no cookbook. He has to re-train himself to be more general and higher-order. That is the trouble.
Smerdyakov has quit ["Rumplestiltskin"]
<{[mono]}>
Notice also how there is no cookbook for OOP either, and there is a design pattern book instead, which is another to say higher-order parameterized patterns.
r2d4 has quit ["Chatzilla 0.9.68a [Firefox 1.0.4/20050511]"]
vezenchio has joined #ocaml
{[mono]} has quit ["good morning, sweet dream"]
Snark has joined #ocaml
petter_ has joined #ocaml
<joo_>
&quit
joo_ has quit ["leaving"]
smimou has joined #ocaml
_shawn has quit [Read error: 110 (Connection timed out)]
_shawn has joined #ocaml
_shawn has quit [Read error: 60 (Operation timed out)]
_shawn has joined #ocaml
jyp has joined #ocaml
_shawn has quit [Read error: 110 (Connection timed out)]
_shawn has joined #ocaml
_shawn has quit [Connection timed out]
_shawn has joined #ocaml
r2d4 has joined #ocaml
<r2d4>
What are the differences of pattern matching in functional languages and Select Case in imperative languages?
<r2d4>
or Switch.
<mauke>
sounds like homework
<r2d4>
No!
<mauke>
C's switch is limited to integers
<mauke>
pattern matching can work with about any data type
<Snark>
C's switch is int and char
<mauke>
no, it works with all integer types
<TeXitoi>
Snark: char is a type of int ;-)
<r2d4>
Is data type the only difference?
<mauke>
oh, and it can match on the structure of the value, not just its value. uh.
<r2d4>
I notice that you can specify head and cons.
<mauke>
pattern matching can bind variables
<Snark>
TeXitoi: uh...
<mauke>
integer types: char, unsigned char, signed char, short, unsigned short, int, unsigned int, long, unsigned long, and all enums
<Snark>
well, then yes if you mean that *g*
<TeXitoi>
in C of course
<r2d4>
mauke: "Structure, not just Value". That seems to sum up whatever I saw.
<mauke>
and the binding of variables
<r2d4>
mauke: Thanks. That claries a lot.
<mauke>
writing something like ('1' : s@(_ : _)) in C would be a lot uglier, I think
<r2d4>
At the first glance, pattern matching seemed mysterious.
<r2d4>
Any of you use Python?
<r2d4>
What advantages do you notice from OCaml apart from speed?
<smimou>
the strong type system
<r2d4>
I keep hearing that.
<r2d4>
How is it stronger than something, say, Ada.
<Snark>
it makes writing code much easier
<TeXitoi>
the functionnal/iterative/module/object models
<r2d4>
What is iterative models? Lazy evaluation?
<r2d4>
I am assuming strong means strict here.
<r2d4>
Wrong assumption perhaps?
<Snark>
r2d4: very strict
<mauke>
I don't know Ada
<r2d4>
Do you have an example? Something other than C.
<mauke>
on the other hand, python is stronly typed too
<r2d4>
yes. the obvious difference is static vs dynamic.
<r2d4>
dynamic typing is supposed to be a productivity feature.
<mauke>
dunno, I like implicit static typing
<mauke>
type inference rocks
<r2d4>
mauke: I like it too./
<r2d4>
I am currently using Python for almost everything.
<r2d4>
So the natural question is how will the new language benefit me compared to the old.
<r2d4>
I don't mostly take advantage of dynamism in Python.
<r2d4>
apart from not having to manually specify a type.
<TeXitoi>
r2d4: you don't in ocaml too
<TeXitoi>
iterative is like C : succession of actions
<TeXitoi>
oposed to functionnal
<r2d4>
TeXitoi: iterative - isn't that same as functional?
<r2d4>
cancel that
<r2d4>
TeXitoi: iterative - isn't that same as imperative?
<TeXitoi>
yep
<TeXitoi>
it's possible I don't use the good word ;-)
r2d4 has quit ["Chatzilla 0.9.68a [Firefox 1.0.4/20050511]"]
Skal has joined #ocaml
mlh_ has quit [Client Quit]
jyp has left #ocaml []
Skal has quit ["Client exiting"]
Skal has joined #ocaml
dan2_ is now known as dan2
Skal has quit [kornbluth.freenode.net irc.freenode.net]
Herrchen has quit [kornbluth.freenode.net irc.freenode.net]
joeymonster has quit [kornbluth.freenode.net irc.freenode.net]
det has quit [kornbluth.freenode.net irc.freenode.net]
Amorphous has quit [kornbluth.freenode.net irc.freenode.net]
Herrchen has joined #ocaml
joeymonster has joined #ocaml
det has joined #ocaml
Amorphous has joined #ocaml
Skal has joined #ocaml
bk_ has joined #ocaml
bk_ has left #ocaml []
cmeme has joined #ocaml
cmeme has quit [Remote closed the connection]
cmeme has joined #ocaml
pango_ has joined #ocaml
pango has quit [Read error: 60 (Operation timed out)]
pango_ is now known as pango
_JusSx_ has joined #ocaml
angagon has joined #ocaml
angagon has left #ocaml []
vezenchio has quit ["\o/ in mochintin namocniuh \o/"]
petter_ has quit [Read error: 110 (Connection timed out)]