* [Caml-list] Multiparameter functors?
@ 2003-12-22 0:30 Brian Hurt
2003-12-22 10:17 ` Julien Signoles
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Brian Hurt @ 2003-12-22 0:30 UTC (permalink / raw)
To: Ocaml Mailing List
Is it possible to do multi-parameter functors? What I want to be able to
so is something like:
module Make(Key: Map.OrderedType, Pri: Map.OrderedType) = struct
type key = Key.t;;
type pri = Pri.t;;
...
end;;
Am I being stupid and just missing something obvious, or is there some
subtle reason why I shouldn't be doing this?
--
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
- Gene Spafford
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] 7+ messages in thread
* Re: [Caml-list] Multiparameter functors?
2003-12-22 0:30 [Caml-list] Multiparameter functors? Brian Hurt
@ 2003-12-22 10:17 ` Julien Signoles
2003-12-23 1:16 ` Brian Hurt
2003-12-22 12:36 ` Julien Demouth
2003-12-22 23:04 ` Matt Gushee
2 siblings, 1 reply; 7+ messages in thread
From: Julien Signoles @ 2003-12-22 10:17 UTC (permalink / raw)
To: Brian Hurt; +Cc: Ocaml Mailing List
> Is it possible to do multi-parameter functors? What I want to be able to
> so is something like:
>
> module Make(Key: Map.OrderedType, Pri: Map.OrderedType) = struct
> type key = Key.t;;
> type pri = Pri.t;;
> ...
> end;;
module Make(Key: Map.OrderedType)(Pri: Map.OrderedType) = struct
type key = Key.t
type pri = Pri.t
(* ... *)
end
Julien Signoles
--
mailto:Julien.Signoles@lri.fr ; http://www.lri.fr/~signoles
"In theory, practice and theory are the same,
but in practice they are different" (Larry McVoy)
-------------------
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] 7+ messages in thread
* Re: [Caml-list] Multiparameter functors?
2003-12-22 0:30 [Caml-list] Multiparameter functors? Brian Hurt
2003-12-22 10:17 ` Julien Signoles
@ 2003-12-22 12:36 ` Julien Demouth
2003-12-22 23:04 ` Matt Gushee
2 siblings, 0 replies; 7+ messages in thread
From: Julien Demouth @ 2003-12-22 12:36 UTC (permalink / raw)
To: Brian Hurt, Caml List
Hi,
Brian Hurt wrote:
> Is it possible to do multi-parameter functors? What I want to be able to
> so is something like:
>
> module Make(Key: Map.OrderedType, Pri: Map.OrderedType) = struct
> type key = Key.t;;
> type pri = Pri.t;;
> ...
> end;;
Of course it's possible but you mustn't use the comma. A functor is just
a function. The only difference is that it deals with structure whereas
"normal" functions deal with values. Consider the following example:
module type M = sig type t end
module type N = sig type t end
module type R = sig type u and v end
module Make (U:M) (V:N) : R with type u = U.t and type v = V.t
> Am I being stupid and just missing something obvious, or is there some
> subtle reason why I shouldn't be doing this?
Every question is good to be asked ;)
Regards,
Julien
-------------------
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] 7+ messages in thread
* Re: [Caml-list] Multiparameter functors?
2003-12-22 0:30 [Caml-list] Multiparameter functors? Brian Hurt
2003-12-22 10:17 ` Julien Signoles
2003-12-22 12:36 ` Julien Demouth
@ 2003-12-22 23:04 ` Matt Gushee
2003-12-22 23:56 ` David Brown
2003-12-22 23:58 ` David Brown
2 siblings, 2 replies; 7+ messages in thread
From: Matt Gushee @ 2003-12-22 23:04 UTC (permalink / raw)
To: caml-list; +Cc: Ocaml Mailing List
On Sun, Dec 21, 2003 at 07:30:27PM -0500, Brian Hurt wrote:
>
> Is it possible to do multi-parameter functors? What I want to be able to
> so is something like:
>
> module Make(Key: Map.OrderedType, Pri: Map.OrderedType) = struct
> type key = Key.t;;
> type pri = Pri.t;;
> ...
> end;;
>
> Am I being stupid and just missing something obvious,
Is there anything obvious about functors? ;-)
I've found the following syntax to work:
module Make =
functor (Key:Map.OrderedType) -> functor (Pri:Map.OrderedType) ->
struct
....
end;;
... though I'm not qualified to comment on the merits of doing or not
doing this.
--
Matt Gushee When a nation follows the Way,
Englewood, Colorado, USA Horses bear manure through
mgushee@havenrock.com its fields;
http://www.havenrock.com/ When a nation ignores the Way,
Horses bear soldiers through
its streets.
--Lao Tzu (Peter Merel, trans.)
-------------------
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] 7+ messages in thread
* Re: [Caml-list] Multiparameter functors?
2003-12-22 23:04 ` Matt Gushee
@ 2003-12-22 23:56 ` David Brown
2003-12-22 23:58 ` David Brown
1 sibling, 0 replies; 7+ messages in thread
From: David Brown @ 2003-12-22 23:56 UTC (permalink / raw)
To: Ocaml Mailing List
On Mon, Dec 22, 2003 at 04:04:15PM -0700, Matt Gushee wrote:
> Is there anything obvious about functors? ;-)
>
> I've found the following syntax to work:
>
> module Make =
> functor (Key:Map.OrderedType) -> functor (Pri:Map.OrderedType) ->
> struct
> ....
> end;;
This is very similar to currying of functions, except that Ocaml doesn't
give you nice convenient syntax for defining curried functors. The
application is similar to currying, though.
module Mine = Make (Keytype) (Pritype)
Dave.
-------------------
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] 7+ messages in thread
* Re: [Caml-list] Multiparameter functors?
2003-12-22 23:04 ` Matt Gushee
2003-12-22 23:56 ` David Brown
@ 2003-12-22 23:58 ` David Brown
1 sibling, 0 replies; 7+ messages in thread
From: David Brown @ 2003-12-22 23:58 UTC (permalink / raw)
To: Ocaml Mailing List
> On Mon, Dec 22, 2003 at 04:04:15PM -0700, Matt Gushee wrote:
>
> > Is there anything obvious about functors? ;-)
> >
> > I've found the following syntax to work:
> >
> > module Make =
> > functor (Key:Map.OrderedType) -> functor (Pri:Map.OrderedType) ->
> > struct
> > ....
> > end;;
>
> This is very similar to currying of functions, except that Ocaml doesn't
> give you nice convenient syntax for defining curried functors. The
> application is similar to currying, though.
>
> module Mine = Make (Keytype) (Pritype)
And, I'm not even right. Module definitions can also be curried:
module Make (Key : Map.OrderedType) (Pri : Map.OrderedType) =
struct
...
end
Dave
-------------------
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] 7+ messages in thread
end of thread, other threads:[~2003-12-23 1:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-22 0:30 [Caml-list] Multiparameter functors? Brian Hurt
2003-12-22 10:17 ` Julien Signoles
2003-12-23 1:16 ` Brian Hurt
2003-12-22 12:36 ` Julien Demouth
2003-12-22 23:04 ` Matt Gushee
2003-12-22 23:56 ` David Brown
2003-12-22 23:58 ` David Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox