buluca has quit [Read error: 113 (No route to host)]
darinm has joined #ocaml
robozni has quit ["leaving"]
unfo- has quit [zelazny.freenode.net irc.freenode.net]
unfo- has joined #ocaml
unfo-ninja has joined #ocaml
unfo- has quit [zelazny.freenode.net irc.freenode.net]
unfo- has joined #ocaml
unfo- has quit [zelazny.freenode.net irc.freenode.net]
mordaunt has quit [Read error: 104 (Connection reset by peer)]
wy has quit ["Leaving"]
unfo- has joined #ocaml
unfo- has quit [Connection timed out]
thesoko has quit [Remote closed the connection]
thesoko has joined #ocaml
screwt898 has quit [Remote closed the connection]
Abo-Marwan91 has quit [Remote closed the connection]
Abo-Marwan91 has joined #ocaml
screwt898 has joined #ocaml
thesoko has quit [Remote closed the connection]
thesoko has joined #ocaml
darinm has quit []
thesoko has quit [Remote closed the connection]
p_a_u_l has quit [Read error: 110 (Connection timed out)]
mrsolo has joined #ocaml
darinm has joined #ocaml
asmanur has joined #ocaml
buluca has joined #ocaml
vpalle has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
Le-Chuck_ITA has joined #ocaml
<Le-Chuck_ITA>
Hi all
<Le-Chuck_ITA>
I would like to model categories into ocaml, and I am looking for advice on how to model functors
love-pingoo has joined #ocaml
darinm_ has joined #ocaml
darinm has quit [Read error: 104 (Connection reset by peer)]
darinm_ has quit [Client Quit]
Tetsuo has joined #ocaml
Le-Chuck_ITA has left #ocaml []
schme has joined #ocaml
Yoric[DT] has joined #ocaml
darinm has joined #ocaml
resuser has joined #ocaml
<resuser>
hi
<resuser>
I have a beginner's question
<resuser>
I want to declare something like
bluestorm_ has joined #ocaml
<resuser>
type t1 = t2 of t3 * t4 | t5 of t2 * t6
<resuser>
that is using t2 defined in the same declaration in next type
<resuser>
but ocaml won't let.
<bluestorm_>
hm
<bluestorm_>
actually the "foo of bar" form can't allow that
<bluestorm_>
because foo must be a constructor, wich is not a type
<resuser>
okey
<resuser>
so how to do?
<bluestorm_>
hm
<bluestorm_>
what are you trying to do ?
<bluestorm_>
type foo = A of int | B of foo * int
<bluestorm_>
would work
<resuser>
stop compiler warning about unmatched subtypes of t5
<bluestorm_>
t5 isn't a type
<resuser>
constructor that is,
<resuser>
Hmm. I see the point.
<resuser>
So it's kind of 'union' as in C?
<asmanur>
yes
<resuser>
thanks. lemme retry something
<pango>
but safe ;)
schme has quit [Read error: 110 (Connection timed out)]
<resuser>
btw, which editor is good for caml?
<resuser>
I use eclipse with Ocaml extension
<resuser>
but it won't do deep printing while debugging
<resuser>
camelia is crashy and rough
<asmanur>
emacs.
<resuser>
It has debugging integration?
<Yoric[DT]>
OcaIDE is nice.
<resuser>
OcalIDE won't do debugging I think
mrsolo has quit ["Leaving"]
<asmanur>
resuser: you can code without debugging integration :)
<resuser>
The page says it does, but It didn't work for me
<resuser>
asmanur: I am modifying ben pier's code :)
<resuser>
So I spend time debugging for understanding it, make a change and then try to understand what I have changed :)
<asmanur>
ok
Yoric[DT] has quit ["Ex-Chat"]
<resuser>
Ill' try xemacs some of these days.
schme has joined #ocaml
<resuser>
Yoric[DT]: Just for note, it was odt that did not support debugging. my bad. ocalide requires 3.3 And I need to keep 3.2 that's why I let it go.
resuser has left #ocaml []
schme` has joined #ocaml
schme has quit [Read error: 110 (Connection timed out)]
<Yoric[DT]>
List.concat is meant for concatenating an arbitrary number of lists at once.
* Yoric[DT]
seconds bluestorm_.
<Yoric[DT]>
mmmhhh...
<rektide>
thanks, its hard for me as a newbie to know what resources are quality. ocaml-tutorial.org was the first one i found but for all i know there could've been something 100x better
* Yoric[DT]
assumes that some of his fonts were just uninstalled. The resulting display is, well, surprising.
<Yoric[DT]>
rektide: also take a look at "Developing applications with Objective Caml".
<bluestorm_>
rektide: i haven't read ocaml-tutorial
<rektide>
Yoric[DT]: I will do that, thank you.
<bluestorm_>
(as it kind of didn't existed when i was learning ocaml)
<bluestorm_>
"Developing applications with Objective Caml" is a very complete book
<bluestorm_>
but it's not really "easy"
<Yoric[DT]>
Well, it probably depends on rektide's level with other languages.
* Yoric[DT]
considers contributing to the OCaml tutorial at some point.
<rektide>
i'm fairly new to ML but otherwise i'm a competent programmer in most declaratives
<rektide>
does this make sense to anyone: val it : (('a -> 'b option) -> 'a list -> 'b list)
<rektide>
i dont understand what this function expects
<SmerdyLaptop>
What have you been reading to learn OCaml?
<rektide>
i only just just got to page 29 on polymorphism & type constraints
<SmerdyLaptop>
Page 29 of what?
<rektide>
Developing applications in OCaml
<SmerdyLaptop>
I think that's the book I've heard bad things about.
<SmerdyLaptop>
Might want to try the tutorial in the manual instead.
<rektide>
its an oreilly book
<SmerdyLaptop>
Oh, the bad one was APress.
<rektide>
this one has come recommended by two channel denziens
<SmerdyLaptop>
At any rate, if the book is any good, it either already introduced all the concepts you need, or the context makes it clear that you don't need to understand that type.
<rektide>
i havent seen anything else comprable online
kelaouchi has quit ["leaving"]
<rektide>
i thought i understood, but its not working as i expected
<SmerdyLaptop>
What did you expect?
<rektide>
thisfun fun x->x*2 listofints should be valid
<SmerdyLaptop>
How did you decide that by reading the type?
<rektide>
(('a -> 'b option) -> 'a list -> 'b list), first param is a fun going from a -> b, second param is a list of a
<SmerdyLaptop>
No, you ignored the identifier [option].
<rektide>
i certainly did
<SmerdyLaptop>
You can't do that kind of thing and expect to arrive at valid conclusions.
<rektide>
i'm not seeing option described in this ocaml book
<rektide>
i have no idea what it means
<SmerdyLaptop>
How did you come to encounter it?
<rektide>
its in this function i'm trying to use
<rektide>
or trying to understand rther
Yoric[DT] has joined #ocaml
<SmerdyLaptop>
And how did you come upon that function?
<rektide>
a documentation page with a big list of functions and explanations for what the functions do
<rektide>
i figured i'd ditz around and run the functinos and look at the output
<rektide>
but i cant even figure out how to execute this one. X/
<rektide>
its a Type for optional values
<rektide>
"option"
<SmerdyLaptop>
You shouldn't try to read the standard library documentation until you're further into the book.
<rektide>
i dont even understand what the syntax means
<rektide>
('a -> 'b [some type])
<SmerdyLaptop>
Yup. Keep reading and you'll learn what that syntax means.
<rektide>
unfortunately their explanation does not appear to be written in english
* Yoric[DT]
is now installing godi for OCaml 3.10 .
<Yoric[DT]>
rektide: what's the problem ?
<rektide>
this function is using a syntax i dont understand and cannot find decent documentation on
<rektide>
(('a -> 'b option) -> 'a list -> 'b list)
<rektide>
i dont really know how those polymorphics are working
<Yoric[DT]>
Give me a few minutes and I'll teach this to you.
* Yoric[DT]
goes and prepare some tea first :)
* rektide
follows suit
<rektide>
thank you!
<pango_>
there's definitely some weirdness about 'a option in the book; the link to 'a option documentation points no some infinitely void space between Array module and Printf module
<pango_>
the only mention about 'a option is in Weak module description, but it's short (and not the most likely place one would search explanation for it)
<SmerdyLaptop>
You have to know to look at the Pervasives page.
<SmerdyLaptop>
But that wouldn't help rektide, as it defines [option] using a general mechanism that rektide doesn't know about yet.
<bluestorm_>
rektide: where are you in the book ?
<pango_>
there's nothing at that place in the french version either, so it's not a problem of translation
<rektide>
page 32
<bluestorm_>
rektide: "Iteration of composition" ?
<rektide>
yes
<rektide>
i kept thinking the answer was somewhere in the type restriction section
<Yoric[DT]>
rektide: ok, infusion in progress, explanation may start.
<Yoric[DT]>
Do you understand what aaa -> bbb means if aaa and bbb are types ?
<rektide>
important q: green, black, or oolong?
<Yoric[DT]>
Actually not real tea but I don't know the term in English.
<rektide>
yes, but i havent made it to types yet
<bluestorm_>
depends on your timezone
<rektide>
i know that aaa and bbb are types
<Yoric[DT]>
If aaa and bbb are types, then aaa -> bbb is the type of functions that tahe one argument of type aaa and return a value of type bbb.
<rektide>
and that the function maps from aaa to a bbb value
<Yoric[DT]>
s/tahe/take.
<Yoric[DT]>
Exactly.
<rektide>
right
<Yoric[DT]>
'a, 'b and 'anything are polymorphic types
ita has joined #ocaml
<Yoric[DT]>
In the world of .Net or Java, they're called "generics".
<rektide>
they represent "some type"
<Yoric[DT]>
So a type 'a must actually be understood (for any 'a, 'a).
<Yoric[DT]>
The type of the identity function is 'a -> 'a (that is, for any 'a, 'a -> 'a).
<rektide>
right
<Yoric[DT]>
Do you follow me to this point ?
<rektide>
yes, i follow.
<Yoric[DT]>
ok
<Yoric[DT]>
Now, some types are parametrized.
<Yoric[DT]>
In OCaml, the name of the parameter is written before the name of the type.
<Yoric[DT]>
So a list of elements of type x is written x list.
<Yoric[DT]>
So a list of elements of type x is written x list .
<Yoric[DT]>
(just removing the dot)
<Yoric[DT]>
In .Net/Java, this would be List<x>
* rektide
nods
<rektide>
not there yet in my reading but i think i grasp that
<Yoric[DT]>
The last element in the type expression you mention earlier is the "option".
<Yoric[DT]>
Do tell me if the .Net/Java comparisons help you.
<Yoric[DT]>
If they don't, I'll just drop them :)
<rektide>
thusfar they've been unnecessary, but in the future who knows
<rektide>
everything so far has been simple
<Yoric[DT]>
(anyway, .Net/Java generics are essentially an inferior rip-off of ML polymorphism)
<Yoric[DT]>
ok
<rektide>
i see option is: type Option<'a>
<Yoric[DT]>
The type option is a sum type, which is the more powerful counterpart of enums+unions in C or enums in Java.
<Yoric[DT]>
It is defined as
<Yoric[DT]>
type 'a option = Some
<Yoric[DT]>
Sorry,
<Yoric[DT]>
type 'a option = Some of 'a | None
<Yoric[DT]>
In other words, a value of type 'a option may have two possible structures:
<Yoric[DT]>
* either it's Some(x) , for some x of type 'a
<Yoric[DT]>
* or it's the constant None .
<bluestorm_>
hm
<rektide>
is None a language keyword?
<bluestorm_>
Yoric[DT]:
<bluestorm_>
maybe you could just skip option
<Yoric[DT]>
No, it's a constant defined in type 'a option = Some of 'a | None .
<bluestorm_>
and wait for him to read the next part of the chapter
<bluestorm_>
(type declarations and pattern matching)
<Yoric[DT]>
bluestorm_: fair enough.
<Yoric[DT]>
Just one more word.
<bluestorm_>
:p
<bluestorm_>
afk
<Yoric[DT]>
rektide: you can consider this "type 'a option = ..." as the definition of a Java enum.
<Yoric[DT]>
When you figure it out, you may be interested to learn that there's a new (optional) syntax you can use instead of the original one.
<Yoric[DT]>
It looks slightly less surprising for people who come from the world of imperative programming, plus it relies less on subtleties.
screwt898 has quit [Remote closed the connection]
Abo-Marwan91 has quit [Remote closed the connection]
EliasAmaral has quit [Remote closed the connection]
love-pingoo has quit [Read error: 110 (Connection timed out)]
<Yoric[DT]>
Good night everyone.
screwt898 has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
Lena has joined #ocaml
kelaouchi has joined #ocaml
<rektide>
soo... This expression has type (int -> int) option but is here used with type 'a -> 'b option.... why isnt this polymorphizing from int->int to 'a -> `b
ygrek has quit [Remote closed the connection]
<Tetsuo>
maybe 'a -> 'b option is the same as 'a -> ('b option)
<Tetsuo>
and thus, not compatible with foo option
<rektide>
ahhhhh ok
<rektide>
now you're thinking with portals^H^H^H^H^H^H^Hocaml
<rektide>
why does let f = fun (a:int) -> Some a*2;; realize a has to be an int, why does it throw "use of the overloaded operator '( * )'"
<rektide>
*doesnt
<pango_>
because * is not overloaded
<pango_>
ocaml doesn't support overloading
<rektide>
why would i be overloading?
<rektide>
let l = 2*2;; works
<rektide>
a has to be an int so why would some a*2 be overloading anything?
<pango_>
you just have a problem of priorities then, try let f = fun (a:int) -> Some (a*2);;
<pango_>
or let f = fun a -> Some (a*2) or let f a = Some (a*2)
<rektide>
ahh excellent
<rektide>
i'm sorry i'm so stupid. :/
<rektide>
thank you for your assistance
<pango_>
np... Here "Some a" is underlined when the error is displayed, that's as important as the error message ;)
Tetsuo has quit ["Leaving"]
Lena has quit [Read error: 110 (Connection timed out)]
Demitar has joined #ocaml
yminsky has joined #ocaml
filp has quit ["Bye"]
kelaouchi has quit [Read error: 104 (Connection reset by peer)]
kelaouchi has joined #ocaml
crathman has joined #ocaml
univac is now known as ee
ee is now known as eesti
eesti is now known as univac
rektide has quit ["go rockies"]
Abo-Marwan91 has joined #ocaml
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
bluestorm_ has quit [Remote closed the connection]