Re: How to use modules in place of Type Classes

Vesa A Norrman <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
I think this part of SML has not enough features. However, is there any 
problem if a user of your library does

structure MyGetopt = Getopt (MyDict)

and uses his own MyGetopt after that?

If that is not possible I agree that there can be threading of functors.

BTW, A very interesting article I red about this problem is

Xavier Leroy: Applicative functors and fully transparent higher-order 
modules

and I also posted a question about this in comp.lang.ml earlier.

  - Vesa

On Wed, 27 Dec 2006, David Eger wrote:

> I'm writing a library to do command line parsing in SML much like
> the C getopt() function.  I take a dictionary of expected arguments
> and their types and a command line string.  I return a dictionary of
> parsed arguments.
>
> I don't really care what sort of dictionary I'm passed.
>
> In order for me to make a generalized GETOPT that accepts any sort of
> dictionary, it seems that I have to write my module as a functor, taking
> a structure argument and that each of my callers has to explicitly
> evaluate the functor.  This means that the implementation information
> about the underlying representation of a particular dictionary needs to
> be threaded through any code base that uses my library all the way down
> to the invocation of getopt().
>
> This seems to add a lot of programmer overhead.  Is there a better way?
> Is there any equivalence to the type class sugar of Haskell that I could use?
>
> In practice, do SML users just accept a very specific dictionary and have
> the caller do the manual conversions?  Do they functorize everything?
>
> -David
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Smlnj-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/smlnj-list
>

-- 
                                     /`---*\
                                    = ^ o ^ =
                                     `-----'

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.