caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] labels in records?
@ 2003-11-07 22:27 Chris GauthierDickey
  2003-11-07 23:34 ` Brian Hurt
  0 siblings, 1 reply; 2+ messages in thread
From: Chris GauthierDickey @ 2003-11-07 22:27 UTC (permalink / raw)
  To: caml-list

Is it possible to use a labelled function as a member of a record?

In other words:

let f ~x = x + 1

type { g: ~x:int -> int }
               ^
         syntax error

I get a syntax error when trying to specify the type for the record. I'd 
like the above to work so I can do this:

let r = { g = f }

Thanks,
Chris G.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] labels in records?
  2003-11-07 22:27 [Caml-list] labels in records? Chris GauthierDickey
@ 2003-11-07 23:34 ` Brian Hurt
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Hurt @ 2003-11-07 23:34 UTC (permalink / raw)
  To: Chris GauthierDickey; +Cc: caml-list

On Fri, 7 Nov 2003, Chris GauthierDickey wrote:

> Is it possible to use a labelled function as a member of a record?
> 
> In other words:
> 
> let f ~x = x + 1
> 
> type { g: ~x:int -> int }
>                ^
>          syntax error

No tilde.  Try:
type t = { g: x:int -> int }

One nice thing about ocaml, is that the top level prints out 
syntax-correct types.  So, you see: 

# let f ~x = x + 3 ;;
val f : x:int -> int = <fun>
#

Note that lack of a tilde on the type definition.  I just mention this 
because it's how *I* remember when a tilde is needed and when it isn't 
:-).

Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-07 22:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-07 22:27 [Caml-list] labels in records? Chris GauthierDickey
2003-11-07 23:34 ` Brian Hurt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).