Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Missing something in getting C and Ocaml to Work Together
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-11-25 (15:55)
From: Mattias Waldau <mattias.waldau@a...>
Subject: Typing the result of a function
I know how to type the arguments, and I like to do it, since I will get the
compile errors directly, not first when I use the function.

Thus, I typical write a function like

(* return the column called name *)
let find (columns:columns) (name:column_type) =
  List.find ( fun column -> column.data_type = name ) columns.columns

which has typing

val find : columns -> column_type -> column = <fun>

If I use the interactive environment, I see that I get the expected result
column. I needed to see this, since this is my first use of List.find, and I
wanted to be sure that it returned the column.

However, I would have liked to say this already in the definition of find,
that the result of my function find should be a column. How is this done?


P.s. I like to type, since I think it is belongs to the documentation of the

P.P.s. How to type arguments is not very well described in the
documentation. I found one example, twice.