<mutew>
I am having this weird issue involving types in ocaml.
<mutew>
I currently have a nullable type (type 'a nullable = null | notnull of 'a;;)
<Smerdyakov>
Why not use [option]?
<thelema>
mutew: which is identical to 'a option
<mutew>
and I am trying to extend this to create a tree type
<Smerdyakov>
Also, the type definition you gave doesn't parse.
<Smerdyakov>
Constructor names must be capitalized.
<thelema>
mutew: type 'a tree = Empty | Tree of 'a * 'a tree * 'a tree
<mutew>
thelema: That's what I have been doing for binary trees..
<thelema>
mutew: type 'a list_tree = 'a list_tree list
<mutew>
I just figured that it'd be interesting if I could incorporate my nullable type into the tree.
<Smerdyakov>
mutew, you should stop using your nullable type and use [option] instead.
<thelema>
type 'a nullable_tree = 'a nullable tree
<mutew>
thelema: Current nullable looks something like : type 'a nullable = Null | NotNull of 'a;;
<Smerdyakov>
mutew, please be aware that many of us here are going to stop helping you unless you at least acknowledge that your [nullable] type is a confusing duplication of standard functionality.
<mutew>
thelema: My tree type was : type 'a node = Null | Node of 'a * 'a node * 'a node;;
<thelema>
mutew: or did you want something where the empty tree = a null type?
<thelema>
type 'a tree = ('a * 'a tree * 'a tree) nullable ??
<mutew>
Smerdyakov: I started learning ocaml 2 hours ago, I am not even sure what you mean by the [nullable] type.
<Smerdyakov>
mutew, I'm just using brackets to quote code.
<Smerdyakov>
mutew, I'm talking about the type you started out telling us about.
<Smerdyakov>
mutew, i.e., the one named "nullable".
<thelema>
mutew: ocaml has defined a type [option] which is the same as your "nullable" type, just different names.
<mutew>
Smerdyakov: ahh, my bad. I was going through a tutorial and they were showing how to declare new types.
<mutew>
Smerdyakov: and they started with the [nullable] example.
tmaedaZ is now known as tmaeda
<Smerdyakov>
So, since there might be different people around since I last asked, does anyone want to help me test something I'm working on with my ML-like web application language? If so, join #ur!
<Smerdyakov>
mutew, OK. In "real" code, you wouldn't define that yourself, since it's in the standard library by different names.
<mutew>
Smerdyakov: Right..
<Smerdyakov>
As for your original question, I have to confess that I still don't understand what you're trying to do.
<mutew>
So would something like : type 'a tree = Tree of ('a * 'a tree * 'a tree) nullable;; work?
<Smerdyakov>
That looks like it would be accepted by the type-checker.
<mutew>
Smerdyakov: Ok, here's the scene - the nullable type was used as an example for user-created types.
<Smerdyakov>
I don't know what you're trying to accomplish, but I wouldn't be surprised if this does it. :)
<mutew>
Smerdyakov: and then this was extended to trees since it would require null/notnull for child nodes.
<Smerdyakov>
Well, you still haven't said what you're trying to do, but I think you came up with your own answer.
valross has joined #ocaml
<mutew>
Smerdyakov: So the final type I want is a binary tree, catch is integrating the nullable type into my type definition.
<Smerdyakov>
And it looks like you did that above.
<mutew>
Trouble is my match no longer works..
<Smerdyakov>
Which shouldn't be surprising at all, if you understand how datatypes work in OCaml]
<mutew>
I mean I match Null and NotNull, but not Node.
<thelema>
correct - you'll have to match Null -> ... | Not_null (v,l,r) -> ...
<Smerdyakov>
thelema, not quote, given his definition.
<Smerdyakov>
s/quote/quite
<thelema>
correct - you'll have to match Tree Null -> ... | Tree (Not_null (v,l,r)) -> ...
<derdon>
I've just started with OOP in ocaml
<mutew>
thelema: Then using this definition would this be a valid tree - Node(1,NotNull(Node(2, Null, Null), NotNull(3, Null, Null)));;
<derdon>
do I see it right that I must use getters ans setters like in Java if I want to access instance variables?
tmaeda is now known as tmaedaZ
mutew has quit [Ping timeout: 265 seconds]
Associat0r has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
vpalle__ has joined #ocaml
<gildor>
test
vpalle_ has quit [Ping timeout: 240 seconds]
orbitz has joined #ocaml
vpalle__ has quit [Ping timeout: 252 seconds]
Submarine has quit [Read error: Operation timed out]
<derdon>
gildor: passed
<gildor>
I see
derdon has quit [Quit: derdon]
ulfdoz has quit [Ping timeout: 248 seconds]
tmaedaZ is now known as tmaeda
m3ga has joined #ocaml
slash_ has quit [Quit: Lost terminal]
poet has joined #ocaml
<poet>
lets say I have a list of tuples and I dont know what is going to be in the tuples. Can anyone suggest a way to find all strings within the list of tuples at any depth?
travisbrady has quit [Quit: travisbrady]
<Smerdyakov>
I'm not quite sure what you mean, but it's probably not possible.