<dylan>
type 'a t = 'a list * 'a list is like an alias.
<dylan>
so, say you have:
<dylan>
val print_thing : 'a list * 'a list -> unit
<dylan>
that is then equivalent to val print_thing : 'a t -> unit
<ski_>
"t" is an abstract type, that in the implementation (inside the structure) is known to be synonymous with that pair type
<ski_>
right, that is equivalent *inside* the structure
<ski_>
(outside it's unknown what the type really is .. it's abstract)
<dmn>
well i got complaints of type mismatches and by now i switched to using a named constructor..
<dmn>
i mean mismatches between the sig and the struct
<dmn>
oops, i read the error messages wrong, the problem was elsewhere i think...
<dmn>
right. it works.
<ski_>
fine
<dylan>
ski_: it's an assumption (and a good one) that the implementation of the datatype is hidden in the signature.
<dylan>
from wha dmn said, I couldn't know. :)
<qknight>
can i do casts somehow?
<ski_>
um
<ski_>
what do you mean ?
moea has joined #ocaml
<qknight>
typecasts
<qknight>
we have a type of int list and we want to cast it to be just an int list
<ski_>
there are particular *conversions* you can do, like from int to real, or from int to string
<ski_>
hm, sorry ?
<ski_>
you want to "cast" 'int list' to 'int list' ?
<qknight>
let print_clashes ls =
<qknight>
List.iter (fun a -> match a with
<qknight>
Clash_formals i -> ...
<qknight>
| Clash_fields i -> ... ;;
<qknight>
and Clash_formals is of type int list
<ski_>
do you use same definition of type 'clash' as before
<ski_>
?
<qknight>
and now ocamls say it wants a Clash_formals type for this function
<qknight>
type clash =
<qknight>
Clash_formals of formal list
<qknight>
| Clash_fields of field list
<ski_>
(ok .. rather 'Clash_formals' takes an 'int list' argument and gives a 'clash')
<ski_>
ok
<ski_>
so, first 'i' above has type 'formal list', and second 'i' has type 'field list'
<ski_>
is 'formal' and 'field' type-synonyms for 'int' ?
<qknight>
no, i just said int for simplification :)
<qknight>
hey
<qknight>
i think it's to hard to explain
<qknight>
again as before ..
<qknight>
*argh*
<qknight>
ski_: thanks anyway
<ski_>
ok
<ski_>
anyway
<ski_>
since those are lists
<ski_>
and you want to print them
<ski_>
you could use List.iter to do that
<ski_>
val List.iter : ('a -> unit) -> 'a list -> unit
<ski_>
so, you need to pass a function that can print a 'formal' to first 'List'iter' call
<ski_>
and, mutatis mutandis, for the other
<ski_>
ok ?
<moea>
it would be really cool if ocaml printed out stack traces when exceptions are raised
<qknight>
ski_: hehe
<pango>
moea: it does for unhandled exceptions, when compiled to bytecode and OCAMLRUNPARAM="b"
<pango>
moea: there's a patch floating around to do the same in native mode
<moea>
pango: thanks a lot
<moea>
it is always interesting using ocaml after a day of programming in python
dmn has left #ocaml []
<pango>
moea: ocamlc needs -g flag (debugging infos) too
quamaretto has joined #ocaml
<moea>
if i have an expression of the form "if condition then something else something1; something2", how do i go about telling ocaml that the "something2" is part of the else condition?
<moea>
i.e i want something1 and something2 to be done in the case the condition is not true, not in both cases
<moea>
i mean, not something2 to be done in both cases