vegai has quit [sterling.freenode.net irc.freenode.net]
docelic has quit [sterling.freenode.net irc.freenode.net]
pattern_ has quit [sterling.freenode.net irc.freenode.net]
async has quit [sterling.freenode.net irc.freenode.net]
seth_ has quit [sterling.freenode.net irc.freenode.net]
emu has quit [sterling.freenode.net irc.freenode.net]
xtrm has quit [sterling.freenode.net irc.freenode.net]
systems has joined #ocaml
vegai has joined #ocaml
docelic has joined #ocaml
xtrm has joined #ocaml
async has joined #ocaml
seth_ has joined #ocaml
emu has joined #ocaml
pattern_ has joined #ocaml
pattern_ has quit [sterling.freenode.net irc.freenode.net]
async has quit [sterling.freenode.net irc.freenode.net]
vegai has quit [sterling.freenode.net irc.freenode.net]
seth_ has quit [sterling.freenode.net irc.freenode.net]
emu has quit [sterling.freenode.net irc.freenode.net]
xtrm has quit [sterling.freenode.net irc.freenode.net]
docelic has quit [sterling.freenode.net irc.freenode.net]
vegai has joined #ocaml
docelic has joined #ocaml
xtrm has joined #ocaml
async has joined #ocaml
seth_ has joined #ocaml
emu has joined #ocaml
pattern_ has joined #ocaml
lament has joined #ocaml
tmilford_ has joined #ocaml
systems has quit [Remote closed the connection]
asqui has joined #ocaml
Riastrad1 has joined #ocaml
Riastradh has quit [Connection timed out]
tmilford_ has quit [Remote closed the connection]
<seth_>
lus|wazze: I was reading your earlier discussion. A purely functional language can be Turing complete, meaning that all programs can be coded. That only speaks to the possibility, of course, not the practicality.
<seth_>
Anyone about?
<lus|wazze>
um i guess no one was questioning the turing completeness of any programming language in that discussion ... as a non-turing complete pl would be pretty useless
<seth_>
lus|wazze: true, I just meant that everything, including a GUI with state, can be coded some way or other.
<seth_>
Question for you and/or whoever is listening. I'm having a problem figuring out how to use the Queue data structure.
<seth_>
When I create an empty queue, and then try to add to the queue, I get a type error.
<seth_>
Queue.create returns an empty queue of type 'a Queue.t. Adding to it gets a type error because whatever you are adding requires a concrete type.
<lus|wazze>
actually I think Queue.create returns an '_a Queue.t
<seth_>
For example, if I add a string, I get a type error, saying the queue is type 'a Queue.t but the infered type is string Queue.t
<seth_>
lus|wazze: well, ocaml shows it is 'a Queue.t, but I don't think that matters here, does it?
<lus|wazze>
what exactly statements did you use for creatign the queue and adding elements?
<seth_>
lus|wazze: To create the queue:
<Kinners>
you can only use one type
<Kinners>
are you adding say an integer and then a string?
<seth_>
Kinners: yes, I know, but it won't let me use _any_ type.
<seth_>
Kinners: no, just strings.
<lus|wazze>
# let q = Queue.create ();;
<lus|wazze>
val q : '_a Queue.t = <abstr>
<lus|wazze>
# Queue.add "hello" q;;
<lus|wazze>
- : unit = ()
<lus|wazze>
seems to work nicely
<seth_>
lus|wazze: I mean in a compiled program.
<lus|wazze>
well you probably did it in a way that it could not infer the type of what you were adding
<seth_>
lus|wazze: no, if that were the case, it wouldn't correctly state the queue type that I'm using.
<lus|wazze>
as i said, Queue.create returns an '_a Queue.t not a 'a Queue.t
<seth_>
lus|wazze: I think I see something, though...
<seth_>
lus|wazze: Let me check...
<seth_>
lus|wazze: I see my mistake. I did let q = Queue.create;; (without the () )
<lus|wazze>
well then the type error would have been something like it needing an '_a Queue.t and getting an unit -> '_a Queue.t, which was not what you SAID it was giving you :)
<lus|wazze>
so give us the EXACT error message next time :)
<seth_>
lus|wazze: I just ran it both ways, and what I said is exactly what it does, indeed, say.
<seth_>
lus|wazze: but to see the error, you have to define a function that takes a Queue as an argument.
<seth_>
that is, to see _that_ error message.
<lus|wazze>
if you do a let q = Queue.create;; and give q as an argument to something expecting a queue (as you apparently have done) it will complain exactly in that way - because q is a function returning a q
<seth_>
lus|wazze: correct. Now I understand.
<lus|wazze>
if you don't use it in functions taking queues you can't really do anything with q so you wouldn't be getting any error messages at all
<seth_>
lus|wazze: no, you can use it in a statement. ocaml lets you write imperative statements.
<lus|wazze>
those are still just expressions, and in basically all cases function applications
<lus|wazze>
in fact the ONLY thing you can do with a queue is apply a function to it
<lus|wazze>
the only datatypes used directly by statements are unit (by all block/loop statements) and bool
<seth_>
lus|wazze: no, I have a short test program here where I add things to the queue, and then print them out, and I never apply a function to the queue.
<lus|wazze>
how do you do that? I mean, add things to the queue without applying functions to it :)
<lus|wazze>
usually you add things to a queue by applying the Queue.add function to it
<seth_>
Yes, that's true. What I meant before is that the q is an argument to a function that I define, not an argument to a function in the Queue module. The point being that the error message is different.
<lus|wazze>
why should it be? both functions would take 'a Queue.t as its argument
<seth_>
lus|wazze: I don't know. I think, however, it is because the function definition (and thus the type inference) occurs before I use the (incorrect) queue object, so I see a different error message. Not important, I was just explaining why I see the message that you said can't occur.
<lus|wazze>
then your function definition is wrong which is an entirely different topic
<lus|wazze>
anyway I'm off to sleep now in a few minutes
<seth_>
no, my function definition is correct. When I fix the error in create(), it works.
<lus|wazze>
does your function use q directly?
<seth_>
Yes, it adds to the queue and removes entries from the queue.
<lus|wazze>
well that explains it
<lus|wazze>
when you said function I thought you meant you had written your own function operating on an arbitrary queue
<seth_>
Yes, I just didn't explain it well.
<lus|wazze>
and the error occurred when calling that function with q as an argument
<lus|wazze>
well be that as it may -- I'm off to bed now :)