<tsuyoshi>
Array.set returns unit, which you can't pass to Array.to_list
<Smerdyakov>
tsuyoshi, I have a strong feeling that the best advice you could give Anusien is "PLEASE, go READ about OCaml before you try using it."
<tsuyoshi>
what is he supposed to read that explains this kind of thing?
<Smerdyakov>
I think there are good books on SML programming, at least.
<tsuyoshi>
so recommend one
<Smerdyakov>
It's pretty clear that he has no functional programming experience, so even SICP would probably be good.
<tsuyoshi>
ok.. yeah
<Smerdyakov>
I would recommend starting with the OCaml tutorial in the manual, at least.
<Anusien>
Smerdyakov: Probably. All the tutorials I found were pretty unhelpful, in that they said "here is how you match a list" but not "Here's how you do anything useful beyond that"
<Smerdyakov>
Anusien, did you read the tutorial in the manual?
<Anusien>
I believe so. I read a few, actually
<Smerdyakov>
Did you read one that actually encouraged the reader to use loops?
<tsuyoshi>
anusien: sicp is a book "structure and interpretation of computer programs" which uses scheme to explain functional programming
<tsuyoshi>
it will explain the best way to iterate over lists and other various things
shawn_ is now known as shawn
<sponge45>
A good exercise would be to implement your own version of the List module with the same interface as the standard one, and then compare with list.ml from the std lib.
<Anusien>
Anyway, thanks. I can imagine you all having to constantly deal with people that are very strongly set in their imperative ways. Gonna go get some work done
Smerdyakov has quit ["Leaving"]
piggybox has joined #ocaml
piggybox has quit [Connection timed out]
piggybox has joined #ocaml
Z4rd0Z has joined #ocaml
Z4rd0Z has left #ocaml []
Anusien has quit []
levi_home has quit [Read error: 104 (Connection reset by peer)]
ppsmimou has quit [Read error: 104 (Connection reset by peer)]
pstickne has joined #ocaml
smimp has joined #ocaml
gim has quit [Read error: 110 (Connection timed out)]
ludwig- has joined #ocaml
pstickne has quit [Remote closed the connection]
pangon8 is now known as pango
shawn has quit ["This computer has gone to sleep"]
shawn has joined #ocaml
piggybox has quit [Read error: 110 (Connection timed out)]
piggybox has joined #ocaml
brainly-green has joined #ocaml
lmbdwr has quit [Remote closed the connection]
<brainly-green>
programming languages may be functional, but right now the actual _writing_ of programs is a very imperative process
<brainly-green>
it proceeds solely in terms of destructive deletions and insertions on a string
<brainly-green>
using a text editor
pstickne has joined #ocaml
<brainly-green>
how could a program be written so that every addition to the program is a well-defined function of a previous version of the program
<pango>
brainly-green: short of undo function, that reveals that editors internals are either functional, or emulate that
<pango>
brainly-green: by using version management
sponge45 has quit ["zzzzzzzzzz"]
<brainly-green>
even if the internals are functional the process is at odds with the functional paradigm, amounting to do-notation
<brainly-green>
but yes version management is what I was thinking of
<brainly-green>
except that version management still isn't enough, it's still very imperative in style even with a good versioning system
<brainly-green>
if you want to change some aspect of the behavior of your program, you dig right into the code and delete some letters and add some new ones
<brainly-green>
so in a certain sense no function is "well defined" over multiple versions because you could change its internals
<pango>
I don't see what you suggest as an alternative
<pstickne>
does "well-defined" describe the interface only?
<pstickne>
*doesn't
<pango>
open a new frame each time you press a key ? :)
<brainly-green>
I'm not suggesting anything, I don't have an answer
<zagzig>
if the intent of the function stays the same, how do the internals matter
<brainly-green>
you might change the behavior of the function by changing the internals
<brainly-green>
which is very similar to the behavior of the function changing at runtime due to a side effect
<zagzig>
that's not really an editor issue, though
<zagzig>
more of a documentation issue
<zagzig>
shouldn't there not be side-effects?
<brainly-green>
yes there should not be side effects
<zagzig>
i should add that i'm no expert in ocaml, or any other language; so i'm not exactly qualified to talk about it :p
<zagzig>
fighting with yourself about what language you want to commit to learning is not fun.
<zagzig>
or learning first, rather
<pango>
ocaml is not about banning side effects
<pango>
many ocaml's programmers/code seem to be on the "observationally functional" camp
<zagzig>
functional where it makes sense, imperative where it makes sense
<zagzig>
right?
<pango>
at least, for code that's not blatantly imperative ;)
<pango>
zagzig: as in "functions with purely functional behavior may have imperative internals"
<zagzig>
heh, it's fun thinking about the distinctions
<zagzig>
for someone who already finds it a pain to deal with c's annoyances, would it only get worse after becoming proficient in a language like ocaml?
<flux->
unfortunately, that is very possible :(
<zagzig>
the only semi-real programming i've done is with ruby, so which isn't useful for a lot of things because of speed and lack of library support
<zagzig>
-so
<flux->
however, some knowledge might be transferable back to C too
<flux->
for example ocaml innovated me to write a currying-hack (non-typesafe of course) for C, which was beneficial in one application
<zagzig>
oh i know, but knowing that there's a lot less pain in other languages would only make me more bitter about it, i think :p
<flux->
so due to work-reasons, you must write in C too?
<zagzig>
heh not work, this would mostly be for recreation
<zagzig>
c would be the path of least resistance, in a lot of ways
<zagzig>
all the libraries are there, speed is there, platform support is there
<flux->
for certain tasks C certainly is appropriate
<flux->
but most of the time it isn't ;)
<pango>
people start thinking it's not even fit anymore for system programming ;)
<zagzig>
is there any work being done on an ocaml-based OS?
<zagzig>
iirc there's a lisp one in progress
<zagzig>
movitz
<pango>
at least 2, but dead in their tracks... desert spring and funk
<pango>
desert spring-time even
<zagzig>
that's an awful name :p
<pango>
mmh last updates to dst are dated 2006, so maybe it's not that dead
<zagzig>
would that be the same cairo that's being used in gtk, etc.?
<zagzig>
on second thought, that's a stupid question
<zagzig>
i mean why would that be in or even near the kernel :p
batdog|gone has quit [Read error: 104 (Connection reset by peer)]
batdog131 has joined #ocaml
batdog131 is now known as batdog
pango has quit [Remote closed the connection]
<zagzig>
oh, it is the same cairo i was thinking of
<zagzig>
that's pretty neat
pango has joined #ocaml
<zagzig>
is the book "developing applications with objective caml" good as a text on programming itself, or would i need to work through SICP too?
bluestorm has joined #ocaml
<pango>
zagzig: if you've already used another functional language, you can start writing ocaml code with just the former;
<pango>
But either way, SICP will probably help you really get what the functional paradigm is about, and better use the different paradigms available
<pango>
(which reminds me I should finish reading it... So few hours in a day... :/)
<pango>
"Concepts, Techniques, and Models of Computer Programming" is said to be "an updated SICP"...
<zagzig>
oh i'd plan to read through it later on, after i brush up on my maths :p
<zagzig>
but i've quit half-way through too many books because they don't explain the concepts and reasoning for certain (usually important) things well enough
<zagzig>
it's hard to learn when you're having to accept so many things just because the authors say so
<zagzig>
and it's not just limited to the <language> in 24hours/21days books, either
<pango>
if you like books explaining the concepts, the SICP is for you
<zagzig>
bit of a sicp advocate, huh? :p
benny has joined #ocaml
slipstream has joined #ocaml
slipstream-- has quit [Read error: 60 (Operation timed out)]
jlouis has quit ["Leaving"]
smimou has joined #ocaml
pstickne has quit [Remote closed the connection]
whatsup103 has joined #ocaml
<ulfdoz>
Are there approaches to "dynamically plugin" code. E.g. I have parsed some data and want to run some tests on it. Is there a way to load the test definitions as some kind of plugin?
<flux->
ulfdoz, you can load code with the Dynlink-module, but it works only with bytecode
shawn has quit [Read error: 110 (Connection timed out)]
_JusSx_ has joined #ocaml
love-pingoo has joined #ocaml
b00t has joined #ocaml
ikaros has quit [Read error: 110 (Connection timed out)]
ikaros has joined #ocaml
b00t has quit [Read error: 145 (Connection timed out)]
swater has joined #ocaml
piggybox has quit [Connection timed out]
buluca has quit ["Leaving."]
_JusSx__ has joined #ocaml
Smerdyakov has joined #ocaml
JarJarBinks|meta has joined #ocaml
_JusSx_ has quit [Read error: 110 (Connection timed out)]
brainly-green has quit [Read error: 110 (Connection timed out)]
love-pingoo has quit ["Connection reset by pear"]
ulfdoz has quit [zelazny.freenode.net irc.freenode.net]
benny has quit [zelazny.freenode.net irc.freenode.net]
romanoffi has quit ["Leaving."]
benny has joined #ocaml
ulfdoz has joined #ocaml
smimp has quit [Read error: 110 (Connection timed out)]
postalchris has joined #ocaml
postalchris has left #ocaml []
Submarine has joined #ocaml
Submarine_ has joined #ocaml
Submarine has left #ocaml []
Submarine_ has quit [Connection reset by peer]
Submarine has joined #ocaml
Submarine_ has joined #ocaml
Submarine has quit [Read error: 104 (Connection reset by peer)]
Submarine_ has quit [Read error: 104 (Connection reset by peer)]
Submarine has joined #ocaml
Submarine has quit [Remote closed the connection]
Submarine has joined #ocaml
joshcryer has quit [Connection timed out]
shawn has joined #ocaml
_JusSx_ has joined #ocaml
Submarine has quit [Remote closed the connection]
_JusSx__ has quit [Connection timed out]
Submarine has joined #ocaml
* Smerdyakov
applies for a job at Jane Street Capital.
pango has quit [Remote closed the connection]
pango has joined #ocaml
piggybox has joined #ocaml
descender has quit ["Elegance has the disadvantage that hard work is needed to achieve it and a good education to appreciate it. - E. W. Dijkstra"]
descender has joined #ocaml
benny_ has joined #ocaml
benny has quit [Read error: 110 (Connection timed out)]
pstickne has joined #ocaml
jajs has joined #ocaml
Shi_ has joined #ocaml
Submarine has quit [Remote closed the connection]
pango has quit [Remote closed the connection]
pango has joined #ocaml
_JusSx__ has joined #ocaml
Shimei has quit [Read error: 110 (Connection timed out)]
_JusSx_ has quit [Connection timed out]
jlouis has joined #ocaml
pango has quit [Remote closed the connection]
jajs has quit ["Quitte"]
_JusSx__ has quit [Client Quit]
sponge45 has joined #ocaml
pango has joined #ocaml
Submarine has joined #ocaml
Oxylin has joined #ocaml
<Oxylin>
hello everybody
<Smerdyakov>
Oh, hellooooooo, Oxylin.
<Oxylin>
I have a very newbie question... How to "convert a 'b option type to 'b type?
<Oxylin>
because a function returns me a 'b option type and I need a 'b type for the next of operations...
<Smerdyakov>
Do you understand what the 'option' type family is?
levi_home has joined #ocaml
<Oxylin>
I think ... it's a type which can be None or 'b ?
<Smerdyakov>
Sort of. Either None or Some x where x : 'b.
<Oxylin>
ok
<Smerdyakov>
So you can see that there isn't always a 'b available to extract.
<Oxylin>
ok and in the hypothesis of my variable hac type Some 'b
<Oxylin>
i can extract it by Some (n) -> myfunction n in a match with?
<Smerdyakov>
Yes, but that's a nasty way of doing things, as you will get a nondescript match exception if it is really None.
<Oxylin>
Ok how can I do it than?
<Oxylin>
Ok I do match v with Some n -> myfunction n | _ -> ()
<Oxylin>
is it right?
<jlouis>
You, generally, match and handle both cases. SML defines an Option.valOf function which raises an exception if the None case matches
<jlouis>
it may be the right thing to raise an exception in some cases
<Smerdyakov>
Oxylin, it's type-correct if myfunction returns unit.
<Smerdyakov>
Oxylin, who knows if it's the correct behavior for your application.
<jlouis>
Oxylin, and in your example your function implies myfunction : 'b -> unit
<Oxylin>
yes it does
<jlouis>
Smerdyakov++
<jlouis>
Oxylin, if you find yourself matching a lot of option 'a's in your code, you should seriously consider rethinking it
<Oxylin>
:p ok
<Oxylin>
it's not a good guidline to put a lot of option 'a ,
<Oxylin>
?
<Smerdyakov>
Oxylin, no, jlouis's advice is a little strange; it's not a good idea to use options if you're always going to discard Nones.
<Oxylin>
ok
<jlouis>
Ah, Smerdyakov clarified it
<Oxylin>
;)
<Oxylin>
thx for advices
<Oxylin>
*advice
brainly-green has joined #ocaml
mbishop has joined #ocaml
ookk has joined #ocaml
<ookk>
Array.of_list [(fun x -> x)] doesnt work?
ulfdoz has quit [Connection reset by peer]
<ookk>
cant arrays contain functions?
<Smerdyakov>
What error message do you get?
<ookk>
The type of this expression, ('_a -> '_a) array,
<ookk>
contains type variables that cannot be generalized
swater has quit ["Quat"]
<ookk>
do i have to add some kind of type declartion?
<mattam>
like ('a -> 'a) array yes
Oxylin has quit [Client Quit]
<mattam>
note that id is polymorphic and arrays are monomorphic, so you'll have to put only 'a -> 'a functions in this array. (id is (almost) the only one)
<ookk>
i just use that function as an example
<ookk>
i want to put another kind of funciton in the array?
<ookk>
how do i add such a type declearation in ocaml?
<mbishop>
Do I have to use Random.self_init () if I want a new random number for every instance of the program?
<mattam>
ookk: actually it's more complicated than what i said, but nm. use (object : type)
<ookk>
let a = Array.of_list [(fun x -> x)] : (int -> int) array?
<mattam>
something like this
<mattam>
you might need to put the cast inside the [], or just write fun x : int -> x
<ookk>
ok that works
<ookk>
thx
<ookk>
mattam, "This expression is not a function, it cannot be applied"
<ookk>
a = Array.of_list [(fun (x : int) -> x)]
<ookk>
a.(0) 1
<pango>
# let a = Array.of_list [(fun (x:int) -> x)] ;;
<pango>
val a : (int -> int) array = [|<fun>|]
<pango>
# a.(0) 1 ;;
<pango>
- : int = 1
<pango>
btw Array.of_list [(fun x -> x)] seems to work for me too (ocaml 3.09.2)
<pango>
# Array.of_list [(fun x -> x)] ;;
<pango>
- : ('_a -> '_a) array = [|<fun>|]
mrpingoo has joined #ocaml
<ookk>
not with ocamlopt
<pango>
not with ocamlopt, if a is not used in the same module
<ookk>
ocamlopt says a.(0) is not a function
<ookk>
print_int (a.(0) 1)
<pango>
because weak types need to be solved in the same compilation unit
<ookk>
"This expression is not a function, it cannot be applied"
<ookk>
how do i use the functions in the array then?