Browse thread
Missing something in getting C and Ocaml to Work Together
-
Steve Stevenson
-
Xavier Leroy
-
Sven LUTHER
- Mattias Waldau
-
Sven LUTHER
- Wolfgang Lux
-
Xavier Leroy
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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? /mattias P.s. I like to type, since I think it is belongs to the documentation of the code. P.P.s. How to type arguments is not very well described in the documentation. I found one example, twice.