[Haskell] Initialisation without unsafePerformIO

Jorge Adriano Aires jadrian at mat.uc.pt
Fri Jun 4 16:59:21 EDT 2004

> What ideas do people have for getting rid of unsafePerformIO?

Hope my suggestion is not too naive. 
I get along quite fine using implicit parameters in many cases, it's just 
tedious explicitly typing them in every function context. I'd be pretty happy 
if it was possible to define the 'scope' of some implicit parameters in a 
module and/or define their scope as being a whole module. The 2nd option 
would be something like:

> module (?par :: Parameter) => A where 
> ...

Functions in A could have ?par in their context without having it explicitly 
typed. Now the import of A could be done with:

> module B where 
> import A                      -- simple, ?par unbound
> import A as Ak where ?par = k -- ?par bound to k
> import A as Am where ?par = m -- ?par bound to m
> ...
> k :: Parameter
> k = ...
> m :: Parameter
> m = ...
> ...


> module (?par :: Parameter) => C where 
> import A  -- both A and C paremeterised by ?par

Since both modules share the same parameter, instantiation on ?par in the 
import of C would propagate to the import of A.

At first glance it seems simple syntactic sugar and therefore doable. 
Along with some options in the interpreter to hide/show (this kind of) 
implicit parameters when displaying signatures, check module context, etc. 
probably also quite usable.


More information about the Haskell mailing list