* [Caml-list] Definition of module synonyms
@ 2011-02-18 8:30 forum
2011-02-18 9:10 ` Jacques Garrigue
0 siblings, 1 reply; 4+ messages in thread
From: forum @ 2011-02-18 8:30 UTC (permalink / raw)
To: caml-list users; +Cc: forum
Dear list,
Following the goal of providing module synonyms (e. g. abbreviations for lazy
developers), it seemed natural to do something along the following lines:
module M : sig
type t = A
val x : t
end = struct
type t = A
let x = A
end
module S : sig
type t = M.t = A
include module type of M with type t := M.t
end = M
However, this is rejected with the following message:
include module type of M with type t := M.t
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type t = M.t
is not included in
type t = A
Their kinds differ.
The very same problem arise when defining type "t" as a record, but not when
defining it as either an arrow type, or a polymorphic variant type. So my guess
is that I am missing something obvious about name scoping, but cannot just
get my finger on it.
Any insight would be greatly appreciated.
Regards,
Xavier Clerc
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Definition of module synonyms
2011-02-18 8:30 [Caml-list] Definition of module synonyms forum
@ 2011-02-18 9:10 ` Jacques Garrigue
2011-02-18 9:18 ` forum
2011-02-18 21:34 ` Norman Hardy
0 siblings, 2 replies; 4+ messages in thread
From: Jacques Garrigue @ 2011-02-18 9:10 UTC (permalink / raw)
To: forum; +Cc: caml-list users
On 2011/02/18, at 17:30, forum@x9c.fr wrote:
> Dear list,
>
> Following the goal of providing module synonyms (e. g. abbreviations for lazy
> developers), it seemed natural to do something along the following lines:
>
> module M : sig
> type t = A
> val x : t
> end = struct
> type t = A
> let x = A
> end
> module S : sig
> type t = M.t = A
> include module type of M with type t := M.t
> end = M
>
> However, this is rejected with the following message:
[...]
This was just a bug (or a misfeature) in 3.12.0.
This has been fixed long ago in the 3.12 branch, and will work in 3.12.1.
Jacques Garrigue
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Definition of module synonyms
2011-02-18 9:10 ` Jacques Garrigue
@ 2011-02-18 9:18 ` forum
2011-02-18 21:34 ` Norman Hardy
1 sibling, 0 replies; 4+ messages in thread
From: forum @ 2011-02-18 9:18 UTC (permalink / raw)
To: caml-list users; +Cc: x9c
Le 18 févr. 2011 à 10:10, Jacques Garrigue a écrit :
> On 2011/02/18, at 17:30, forum@x9c.fr wrote:
>
>> Dear list,
>>
>> Following the goal of providing module synonyms (e. g. abbreviations for lazy
>> developers), it seemed natural to do something along the following lines:
>>
>> module M : sig
>> type t = A
>> val x : t
>> end = struct
>> type t = A
>> let x = A
>> end
>> module S : sig
>> type t = M.t = A
>> include module type of M with type t := M.t
>> end = M
>>
>> However, this is rejected with the following message:
> [...]
>
> This was just a bug (or a misfeature) in 3.12.0.
> This has been fixed long ago in the 3.12 branch, and will work in 3.12.1.
Thanks for your quick answer, and sorry for noise.
I have so many versions of Caml installed that I easily mixup things and
forget to test with one given version...
Xavier Clerc
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Definition of module synonyms
2011-02-18 9:10 ` Jacques Garrigue
2011-02-18 9:18 ` forum
@ 2011-02-18 21:34 ` Norman Hardy
1 sibling, 0 replies; 4+ messages in thread
From: Norman Hardy @ 2011-02-18 21:34 UTC (permalink / raw)
To: caml-list users
I think that OCaml lacks recursive functors but my page at:
http://cap-lore.com/MathPhys/Algebras/ocaml/
builds the quaternions from the reals thus:
module Quaternion = G(G(Reals));;
G is a functor which does the 19th century “Cayley–Dickson construction”
( http://en.wikipedia.org/wiki/Cayley-Dickson_construction )
and other candidate division algebras as well.
In Scheme I could loop building higher algebras until division failed.
It was only slightly clunkier in OCaml, but in other ways better in OCaml.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-18 21:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-18 8:30 [Caml-list] Definition of module synonyms forum
2011-02-18 9:10 ` Jacques Garrigue
2011-02-18 9:18 ` forum
2011-02-18 21:34 ` Norman Hardy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox