[Haskell] Initialisation without unsafePerformIO

Chung-chieh Shan ccshan at post.harvard.edu
Wed Jun 2 03:35:54 EDT 2004


On 2004-06-01T18:06:36+0200, George Russell wrote:
> The most common use of unsafePerformIO, for me at least, is initialisation.
> There *surely* must be a better way of doing this, but I haven't really
> seen much discussion of the topic.  Here is my back-of-the-envelope
> suggestion for a new interface, can anyone do better?

Oleg and I summarize the existing solutions to the configuration problem
in Section 2 of our draft paper at

    http://www.eecs.harvard.edu/~ccshan/prepose/

We then propose a new solution.

    Implicit configuration -- or, type classes reflect the value of types

    The _configuration problem_ is to propagate run-time preferences
    throughout a program, allowing multiple concurrent configuration
    sets to coexist safely under staticly guaranteed separation.  This
    problem is common in all software systems, but particularly acute in
    Haskell, where currently the most popular solution relies on unsafe
    operations and compiler pragmas.

    We solve the configuration problem in Haskell using only widely
    implemented and stable language features like the type class
    system.  In our approach, a term expression can refer to run-time
    configuration parameters just as it refers to compile-time constants
    in global scope.  Besides supporting such intuitive term notation,
    our solution also helps improve the program's performance by
    transparently dispatching to specialized code at run-time.  We can
    propagate any type of configuration data -- numbers, strings, IO
    actions, polymorphic functions, closures, and abstract data types.

    The enabling technique behind our solution is to propagate values
    via types (literally), with the help of polymorphic recursion and
    higher-ranked polymorphism.  The technique essentially emulates
    local type-class instance declarations.  Configuration parameters
    are propagated throughout the code implicitly as part of type
    inference rather than explicitly by the programmer.

We are thinking of submitting this paper to the Haskell workshop.  Any
comments would be appreciated, especially before Friday. (:

	Ken

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
2004-06-05: World Environment Day http://www.unep.org/wed/2004/

1 000 000 Europeans demand the exit of nuclear power www.atomstopp.at/1million/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell/attachments/20040602/5b60b807/attachment.bin


More information about the Haskell mailing list