<Oejet>
ketty: Athletics, you know, Christian Olson, Johan Wissman, etc.
<holo>
it eats things till it finds a "."
* ketty
don't know anything about athletics ^^
<holo>
and then sends the string to the ident_of_dot_field
<holo>
match stream_of_string str with
<ketty>
and if it never finds a dot?
<holo>
at this point it knows its a string too
<holo>
ketty, it *has* dot
<holo>
becouse of previous conditions
<holo>
these are only aux functions
<ketty>
it could be good to be paranoid in this case i think...
<holo>
ketty, this code wont be reused
<ketty>
but then i dont know about the previous conditions :)
<ketty>
mm...
<holo>
the previous conditions assure the dot, only if this functions were to be used by other functions not with the same conditions, that would be a problem
<ketty>
the string passed to ident_of_dot_field...
<holo>
yes
<ketty>
hmm
<holo>
its a string
<ketty>
how should it look?
<holo>
nth_char str x
<holo>
this assures it sends a string
<ketty>
should it be the same string as passed to second_field?
<holo>
yes
<holo>
ha
<holo>
no
<holo>
no
<holo>
ooops
<holo>
oh god
<holo>
i just need something to actualy eat the string
<holo>
index_char
<holo>
ahaha
Oejet has quit ["#haskell Just five minutes...zzzZZZZ"]
dark_light has joined #ocaml
descender has quit [Remote closed the connection]
neax has quit [Remote closed the connection]
coumbes has joined #ocaml
<holo>
This function is applied to too many arguments.
<ketty>
and it should look like this btw: stream_of_string (string_of_char (nth_char str x)
<ketty>
with a space :)
Smerdyakov has quit ["Leaving"]
<ketty>
since nth_char str x is evaluated first
<ketty>
when you reach the end of the string
<ketty>
it will try to get a char that doesnt exists
<ketty>
you see?
<ketty>
well it doesnt really depend on it being evaluated first
<ketty>
but that way we can just ignore the rest
<holo>
oh
<ketty>
so you know the problem now?
<holo>
nth_char str x in some point returns a char that doesn't exist
<ketty>
well it doesnt even return
<holo>
becouse it surpassed the string
<holo>
yea
<ketty>
it just throws an exception
<holo>
yea
<ketty>
so you have a solution in mind? :)
<holo>
ok if statement
<ketty>
yes, that sounds like a good idea :)
<holo>
what is type unit?
<ketty>
it looks like this: ()
<holo>
hu
<ketty>
it is sort of a "dummy-value"
<ketty>
since a function has to take some argument (so caml know it is not a value)
<ketty>
we somtimes need a dummy-value
<ketty>
when the function should only return stuff
<ketty>
so thats where "unit" comes in
<ketty>
let f () = 5;;
<ketty>
this is a function that allways returns 5
<holo>
oh
<holo>
ok i'll see that tomorrow
<holo>
thanks ketty
<holo>
i think i will not even wash the teeth
<ketty>
heh :)
holo has quit ["This computer has gone to sleep"]
Quinthius has quit ["Leaving"]
Tachyon76 has joined #ocaml
pango is now known as pangoafk
pangoafk is now known as pango
joshcryer has quit [Read error: 104 (Connection reset by peer)]
joshcryer has joined #ocaml
mrsolo__ has quit [Read error: 113 (No route to host)]
derpy has joined #ocaml
<derpy>
can someone please explain to me what "type matcher = fragment -> acceptor -> fragment option" means? specifically the "->" (i what it means when used with "let match | ->") and the "option" token
<ketty>
hmm
<pango>
they're totally different uses
<ketty>
yes
<pango>
in first case they're used to define a function type
<derpy>
heh thats where my trouble is
<derpy>
couldnt find naything on ocaml-tutorial.org about it
<pango>
say, string -> int means a function that takes a string and returns an int
<derpy>
but why 3 leves?
<derpy>
levels*
<derpy>
currying?
<pango>
yes
<derpy>
and the "option" token?
<pango>
it's a predefined sum type
<derpy>
?
<pango>
type 'a option = None | Some of 'a
<derpy>
what does it do when it is added to "type matcher = fragment -> acceptor -> fragment"?
<ketty>
it is only added to fragment
<derpy>
oh
<pango>
a 'fragment option' type value can be either 'None', or 'Some t', with t of type fragment
<derpy>
so it would either return a type none or some correct?
<derpy>
oh ok
<derpy>
thanks
<derpy>
all makes sense now thanks again
<pango>
np
love-pingoo has joined #ocaml
<theArthur>
in what ways dose Int32's div function differ from (/)
<pango>
it works on Int32s
<pango>
( / ) works on ints only
<theArthur>
but other than the number of bits they should be the same right?
<pango>
they aren't that many definitions for division, so I'd say yes
<pango>
from performance point of view Int32s are boxed, so it could be somewhat slower, but that's not specific to division
<flux__>
thearthur, normal ints are actually 31-bit or 63-bit
<pango>
rounding seems to be the same
<pango>
# (-3) / 5 ;;
<pango>
- : int = 0
<pango>
# Int32.div (-3l) 5l ;;
<pango>
- : int32 = 0l
<theArthur>
as far as i can tell
<theArthur>
how dose div and mod compare
<theArthur>
do they differ when dealing with negative numbers?
<theArthur>
that could be causeing myproblems
<pango>
# (-3) mod 5 ;;
<pango>
- : int = -3
<pango>
# Int32.rem (-3l) 5l ;;
<pango>
- : int32 = -3l
* theArthur
thinks he wrote his program correctly and the computer must be getting it wrong!
<pango>
they seem to match on their "common domain"
<flux__>
thearthur, your only option is to prove the program ;)
<pango>
use a functor and instanciate the same code for ints and Int32s
<flux__>
and with defunctoriser there wouldn't even be performance hit. but it's at present for 3.06, I wonder if it works with a more recent ocaml..
<derpy>
why doesn't this work as a "car" equivilant "let car l = match l with | [] -> None | x::_ -> x;;" ?
<pango>
None is of type 'a option
<derpy>
how would you fix this?
<pango>
so your function is only well typed if x is one too
<pango>
you could write x :: _ -> Some x
<pango>
or use List.hd ;)
<pango>
that one throws an exception for empty lists, however
<derpy>
is there a way to do it where it returns nothing?
<theArthur>
a wrapper around List.hd that catches the exception and replaces it with []
<derpy>
since []->[] doesnt work?
<pango>
[] is of type 'a list
<pango>
so it's well typed if the other branch(es) are or type 'a list too
<pango>
s/or/of/
<derpy>
what would be the proper was to write "car" then?
<pango>
they're more than one proper way
<derpy>
without using exceptions
<pango>
but I'd suggest sticking with using match, and explicitly handle the case when the list is empty
<pango>
that's what ocaml syntax is about, not let you forget pathological cases ;)
<derpy>
im not acutlaly using car, just making small programs to get a hang of ocaml
<pango>
then you're not getting the hang of it
<derpy>
clearly
<pango>
(at least, imho)
<derpy>
keep trying to force lisp onto ocaml
<pango>
probably
<pango>
so I can tell you right away : there's no equivalent for 'eval' either ;)
<pango>
compiled programs to not embed any interpreter
<derpy>
do not*?
<pango>
oups, correct
<theArthur>
my problem with Int32 was because of the difference between != and <> when i switched from int to int32 :0
<pango>
theArthur: sounds logical
clog has joined #ocaml
derpy has joined #ocaml
<derpy>
i want a type fragment that is a list of 'a, "type fragment = ????? list" how do i write that? please help
<derpy>
hello?
<derpy>
nm
<flux__>
you can't have a 'a list, where 'a isn't something specific
<flux__>
maybe you want type 'a fragment = 'a list
Quinthius has joined #ocaml
<derpy>
in some sample code there is a portion which has "... match accept frag with ..." i know its curryed but i fail to see what is going on, does it match accept or frag?
<pango>
functions, including partially applied, cannot be compared, so 'accept frag' *must* evaluate to something
<pango>
I suppose accept is then a function of a single parameter
<derpy>
so it matches what is (accept frag) evaluates too?
<derpy>
-is
<pango>
yes
<derpy>
let rec match_junk k frag accept = match accept frag with ..... so in this case accept must be a function
<pango>
yes
<pango>
if you wanted to match a tuple, you would have to write match accept, frag with
<pango>
or match (accept, frag) with
<derpy>
oh
<derpy>
thanks again
<pango>
you can compile with -i and get inferred types to stdout
<pango>
or compile with -dtypes to get .annot files, that emacs modes like tuareg can use to give you the type of what's under the point
<derpy>
im using ocamlbrowser though
<pango>
yes, that's another way
<derpy>
thanks for the -i tip, was looking for that earlier