new Library Infrastructure spec.

Arie Peterson ariep at xs4all.nl
Wed Jun 16 10:43:16 EDT 2004


Dear Isaac,

My apologies for my lack of responsiveness. There are end of term duties to 
attend to.

At 16:21 2004-06-07 -0400, you wrote:
>Can you please explain on libraries@, if Angela provides a "Setup
>structure", how does the installer import that structure?  How does
>Angela specify the IO action that her setup script needs to perform?
>
>If the answer is, she writes haskell code to do it, then how does that
>code get imported and executed?  For instance, she has an action:
>
>myAction :: (String, IO ())
>myAction = ("move the executable into place", do ...)
>
>Where does this IO action go (in a Setup.lhs file?), and what
>mechanism interprets it?

As you say, Angela writes haskell code to specify what needs to done.
This haskell code is actually a haskell value of a specific type ("Setup 
()", say).

In order to include myAction in the value, you apply a function to it 
(namely "ioTask :: IO () -> String -> Setup ()") and include it in the 
Setup monad:

setup :: Setup ()
setup = do
   output "Beginning installation."
   ioTask (snd myAction) (fst myAction)
   output "Installation complete."

This haskell value "setup", together with other information about the 
package, can be distributed as source code in a simple .hs file (Setup.lhs, 
if that's what you like to call it).
(In a more complex environment, this haskell value might be distributed 
using other means of passing haskell values.)

Now, if Bob wants to install this package, he fires up GHCi (or Hugs), 
loads his favourite installer "Installer" (which is in essence a haskell 
module containing a function "install :: Setup () -> IO ()"), loads the 
setup module (as given to him by Angela) and evaluates "install setup". The 
mechanism that interprets the IO action is the haskell interpreter (e.g. GHCi).

Note 1.: I didn't choose the names of the different functions very well. I 
hope they are not confusing.
Note 2.: Moving an executable into place is a task that should typically be 
one of the predefined installation actions; it should not be necessary to 
use ioTask for it.

I hope this explains my idea.



Regards,

Arie



More information about the Libraries mailing list