Dear GHC Users,

Can anyone help with loading/saving binary files in GHC 0.29? I hear that a
call to C is necessary, but that is possibly the scariest thing I've ever
heard ;-) 

I have a data structure Library, and two tools. One tool saves a Library,
another one loads it. At the moment, Library must be "shown" by the first
tool (i.e. converted to text format). This must then be re-parsed by the
second tool.

It would be much simpler, quicker etc. just to save the data structure
directly as binary, and load it directly as binary.

So, the "saving" tool saves the data structure something like this:

>main = getArgs exit $ \as ->
>       ... ->
>       appendChan stdout the_data_structure exit done

And the "loading" tool does something like this:

>main = getArgs exit $ \as ->
>       ... ->
>       readFileWithPath path filename $ \the_data_structure ->
>       ...
>
>readFileWithPath [] _ _ = error "Can't find library file!\n"
>readFileWithPath (dir:dirs) filename succ
>       = readFile (dir++filename)
>                  (\_ -> readFileWithPath dirs filename succ) succ

What sort of thing needs to be done?

Many thanks!

Ed

P.S. The GHC manual seems to take pride in not supporting the Binary class
     :-) ("We don't do that" etc....) Is it just a portability thing?

Reply via email to