Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Mattias Waldau" <mattias.waldau@abc.se>
To: <caml-list@inria.fr>
Subject: Typing the result of a function
Date: Thu, 23 Nov 2000 23:25:32 +0100	[thread overview]
Message-ID: <HDEEKOMJILGEIHIMAPCDKEMJDKAA.mattias.waldau@abc.se> (raw)
In-Reply-To: <20001123135625.A19531@lambda.u-strasbg.fr>

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.




  reply	other threads:[~2000-11-25 15:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-20 21:05 Missing something in getting C and Ocaml to Work Together Steve Stevenson
2000-11-22 10:06 ` Wolfgang Lux
2000-11-22 20:29 ` Xavier Leroy
2000-11-23 12:56   ` Sven LUTHER
2000-11-23 22:25     ` Mattias Waldau [this message]
2000-11-25 15:54       ` Typing the result of a function Pierre Weis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=HDEEKOMJILGEIHIMAPCDKEMJDKAA.mattias.waldau@abc.se \
    --to=mattias.waldau@abc.se \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox