Neros_ has quit [Remote host closed the connection]
zpe has quit [Ping timeout: 256 seconds]
Neros_ has joined #ocaml
clintnewsom has quit [Quit: clintnewsom]
ollehar1 has quit [Ping timeout: 245 seconds]
BiDOrD_ has quit [Ping timeout: 255 seconds]
BiDOrD has joined #ocaml
paddymahoney has quit [Remote host closed the connection]
ollehar1 has joined #ocaml
stevej has joined #ocaml
clintnewsom has joined #ocaml
zpe has joined #ocaml
ttamttam has left #ocaml []
ttamttam has joined #ocaml
ttamttam has left #ocaml []
clintnewsom has left #ocaml []
clintnewsom has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
ollehar1 has quit [Ping timeout: 256 seconds]
anderse has quit [Quit: anderse]
stevej has quit [Quit: Computer has gone to sleep.]
tane has quit [Quit: Verlassend]
eikke has quit [Ping timeout: 252 seconds]
troydm has quit [Read error: Operation timed out]
troydm has joined #ocaml
mye has quit [Ping timeout: 252 seconds]
Kakadu has quit []
ollehar1 has joined #ocaml
stevej has joined #ocaml
yacks has quit [Quit: Leaving]
eikke has joined #ocaml
heidi-ann has joined #ocaml
ollehar has quit [Ping timeout: 255 seconds]
ollehar1 has quit [Ping timeout: 276 seconds]
eikke has quit [Ping timeout: 252 seconds]
ousado has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
ousado is now known as ousado_
ousado_ is now known as ousado
stevej has quit [Quit: Computer has gone to sleep.]
ttamttam has joined #ocaml
ttamttam has quit [Remote host closed the connection]
eikke has joined #ocaml
Snark has quit [Quit: Quitte]
<Leonidas>
is there a way to define something to be a "stricter" type than something is?
<zorun>
a subtype, you mean?
<Leonidas>
like, if I have a handle to a file, I want to open that handle and make it a stricter type by saying "opened_handle" as type
<zorun>
maybe through variant types
<Leonidas>
I don't know how this is called in OCaml, that's why I am asking
<zorun>
it looks more like object or class inheritance
<zorun>
I don't think the type system easily allows this kind of things (but I might be wrong)
<Leonidas>
I am reading Appendix B.1 Variant types but I am not really sure I want this
<Leonidas>
"Thus, they allow values of different types to be mixed together in a collection by tagging them with variant labels; the values may be retrieved from the collection by inspecting their tags using pattern matching."
<Leonidas>
that doesn't really sound like what I want
<zorun>
hmm, true
<def-lkb>
Leonidas: if what you mean is changing the type of an existing value, it's not possible
<Leonidas>
from the example, maybe I could emulate `Opened_file or something
<Leonidas>
def-lkb: it doesn't need to destructively change it. it can also wrap it.
<Armael>
you may want subtyping with objects
<def-lkb>
Using subtyping relation of polymorphic variants in a phantom parameter is a common way to do that
<Leonidas>
from the text, it sounds quite like what I am up to
<def-lkb>
Leonidas: yes, some variants of these tricks are definitely a solution to your problem
<Leonidas>
it is not exactly a problem, I'd just like to introduce more type safety by encoding the state of my variables into the type :)
clintnewsom has quit [Quit: clintnewsom]
maufred_ has joined #ocaml
<zorun>
oh, nice, I'd never heard of phantom types :)
notk0 has quit [Quit: Leaving]
tensai_cirno has joined #ocaml
<tensai_cirno>
Hello, what's the difference between "type c = C of int * bool" and "type c = C of (int * bool)"?
eikke has quit [Read error: Operation timed out]
eikke has joined #ocaml
tensai_cirno has left #ocaml []
tensai_cirno has joined #ocaml
<def-lkb>
tensai_cirno: an indirection
<tensai_cirno>
indirection? Can you elaborate?
<def-lkb>
"C of int * bool" means a block with tag 0 (C being the first and only constructor) and 2 fields, of type int and bool
<def-lkb>
"C of (int * bool)" means a block with tag 0 and 1 field, of type "a pair of an int and a bool"
<tensai_cirno>
So "C of int * bool" doesn't mean passing tuple (pair) to constructor?
<def-lkb>
Yes
<def-lkb>
This is also why you have to match both values during pattern matching and not directly extracting a tuple
<def-lkb>
Using C pseudocode : struct C { int field1; bool field2; };
<def-lkb>
vs struct int_bool_pair { int field1; bool field2; }; struct C { int_bool_pair* field1; }
<tensai_cirno>
hmm
<tensai_cirno>
thanks :-)
<tensai_cirno>
I'll try some expressions in REPL
<def-lkb>
np :)
<tensai_cirno>
def-lkb: Yeah, I think I got it. But what means "block with tag 0"? What is tag?
stevej has joined #ocaml
<def-lkb>
tensai_cirno: as you probably know, ocaml sum types are disjoint union, that is you can test which constructor was used to build the value when matching it.
<def-lkb>
to do so, a tag is added to each value, and constructors are numbered starting from 0.
<def-lkb>
type a = A of int | B of int
<def-lkb>
values constructed from A are tagged 0, those constructed from B are tagged 1
<tensai_cirno>
Oh, I understand. thx. :)
<Leonidas>
I am trying to convert a .ml file with plain definitions into a module but when I wrap it around "module Archive = struct (previous content) end", the other files complain they cannot find the functions. What did I do wrong?
<Leonidas>
Error: Unbound value Archive.version_string
<bernardofpc>
def-lkb: the numbering of constructors is unique until which level ?
<def-lkb>
bernardofpc: what do you mean by unique? this is done type by type
<def-lkb>
separate type definitions share the same tags, but thanks to the typer there can be no confusion at that level
<bernardofpc>
ok
<bernardofpc>
so I can have two constructors named A for two different types, this is a different thing each time ?
<bernardofpc>
type foo = A of int | B of string ;;
<bernardofpc>
type bar = A of int | C of float ;;
<def-lkb>
internally, both A will have tag 0, B and C will have tag 1.
<def-lkb>
but at the source level, the A from bar will shadow A from foo, so you can no longer use the first A.
<Leonidas>
is there a way to avoid having the file name in the name for the module? I have a module Archive in a file called Archive, so I have to call Archive.Archive.version_string which I'd like to avoid.
<Leonidas>
Apart from just using "open", that is.
<def-lkb>
I don't think so.
beckerb has quit [Quit: Konversation terminated!]
Yoric has quit [Ping timeout: 246 seconds]
maufred_ has quit [Quit: leaving]
BiDOrD has quit [Ping timeout: 245 seconds]
BiDOrD has joined #ocaml
clintnewsom has joined #ocaml
heidi-ann has quit [Quit: Page closed]
troydm has quit [Ping timeout: 256 seconds]
R has joined #ocaml
R is now known as Guest1384
Guest1384 has quit [Client Quit]
stevej has quit [Read error: Connection reset by peer]