caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Sharing the code between Monad and MonadState?
@ 2012-06-23 14:32 bob zhang
  2012-06-25  6:43 ` Arnaud Spiwack
  0 siblings, 1 reply; 2+ messages in thread
From: bob zhang @ 2012-06-23 14:32 UTC (permalink / raw)
  To: Caml List

[-- Attachment #1: Type: text/plain, Size: 312 bytes --]

Hi List,
   Given the syntax of first class module is improved a lot. I try to
encode Monad and MonadState,  http://ideone.com/HgG4M
Unfortunately I found it's still impossible to share the code between
differrent Monad Instances. Is it theoretically impossible or I missed
something?
   Many thanks

-- 
-- Bob

[-- Attachment #2: Type: text/html, Size: 425 bytes --]

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

* Re: [Caml-list] Sharing the code between Monad and MonadState?
  2012-06-23 14:32 [Caml-list] Sharing the code between Monad and MonadState? bob zhang
@ 2012-06-25  6:43 ` Arnaud Spiwack
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaud Spiwack @ 2012-06-25  6:43 UTC (permalink / raw)
  To: bob zhang; +Cc: Caml List

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

I fail to see why you would use first class modules for that. What you are
"really" trying to use are just functors. Granted the syntax for functors
is awful. But if you are not willing to bear with it, then you would expect
to have some boilerplate. That said, your types monad and monad_state are
the types of a particular monad and a particular state monad (which have
certain initiality property). There is no reason for them to be related,
which may also be the cause of code duplication.


Arnaud Spiwack


On 23 June 2012 16:32, bob zhang <bobzhang1988@gmail.com> wrote:

> Hi List,
>    Given the syntax of first class module is improved a lot. I try to
> encode Monad and MonadState,  http://ideone.com/HgG4M
> Unfortunately I found it's still impossible to share the code between
> differrent Monad Instances. Is it theoretically impossible or I missed
> something?
>    Many thanks
>
> --
> -- Bob
>

[-- Attachment #2: Type: text/html, Size: 1365 bytes --]

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

end of thread, other threads:[~2012-06-25  6:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-23 14:32 [Caml-list] Sharing the code between Monad and MonadState? bob zhang
2012-06-25  6:43 ` Arnaud Spiwack

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).