ABSTRACT
For the programmer, storage media are usually assumed to have a minimum atomic unit of transfer of one byte. However, sometimes it is useful to have an even finer storage granularity of one bit, for instance in order to compress data.This paper describes an API in the lazy functional language Haskell for treating storage media as arbitrary-length streams of bits without byte-alignment constraints. So far as possible, storage media are treated uniformly. In particular, bit-stream memory and binary files share the same API -- a new and useful abstraction over memory management and file management. This uniformity of access leads to a novel technique for lazy random-access to files in a purely functional manner. We also describe a technique for automatically deriving compressed binary representations of user-defined data structures, whose operations provide both in-heap data compression and convenient high-level binary I/O.Of many possible applications, we illustrate the processing of Huffman-encoded image data, and a bibliographic information system which uses lazy B-trees for efficient storage management.
- 1.Richard Bird. Introduction to Functional Programming using HaskeIl. Prentice Hall, second edition 1998. Google ScholarDigital Library
- 2.D. Coiner. The ubiquitous B-tree. A CM Computing Surveys, 11(2):121 .. 137, June 1979. Google ScholarDigital Library
- 3.N. RSjemo et al. nhcl3 Haskell compiler, York release, http://www, cs. york. ac. uk/fp/nhc13//, Dept. of Computer Science, University of York, UK, May 1998.Google Scholar
- 4.Jeroen Fokker. Functional specification of JPEG decompression and an implementation for free. In Veltkamp and Blake, editors, Programming Paradigms in Graphics, Proceedings of Eurographics Workshop, pages 102-120, Maastricht, NL, September 1995. Springer.Google Scholar
- 5.D. A. Hurl:man. A method for the construction of minimum-redundancy codes. Proc. IRE, 40:1098-1101, 1952.Google ScholarCross Ref
- 6.P. Jansson and J. Jeuring. Polyp - a polytypic programming language extension. In Proc. 24th ACM Symp. on Principles of Programming Language.~ (POPL'97), pages 470-482, Paris, January 1997. ACM Press. Google ScholarDigital Library
- 7.J. Jeuring. Polytypic data compression. Unpublished, 1997.Google Scholar
- 8.M. P. Jones. The implementation of the Gofer functional programming system. Technical Report YALEU/DCS/RR-1030, Department of Computer Science, Yale University, May 1994.Google Scholar
- 9.D. A. Lelewer and D. S. Hirschberg. Data compression. A CM Computing Surveys, 19(3):261-296, September 1987. Google ScholarDigital Library
- 10.S. L. Peyton Jones and J. Launchbury. Unboxed values as first class citizens in a non-strict functional language. In J. Hughes, editor, Proc. 5th A CM Conf. on Functional Programming Languages and Computer Architecture (FPCA '91), pages 636-666, Cambridge, MA, August 1991. Springer LNCS 523. Google ScholarDigital Library
- 11.Simon Peyton Jones, Thomas Nordm, and Alastair Reid. GreenCard: a foreign-language interface for Haskell. In J. Launchbury, editor, 2nd Haskell Workshop, Amsterdam, NL, June 1997.Google Scholar
- 12.S.L. Peyton Jones and P.L. Wadler. Imperative functional programming. In 20th A CM Symposium on Principles o/ Programming Languages (POPL'93), pages 71-84, Charleston, AL, January 1993. ACM Press. Google ScholarDigital Library
- 13.M. Pil. First class file I/O. in W. Kluge, editor, Proc. 8th Intl. Workshop on Implementation o/Functional Languages (IFL'96), pages 233-246, Bad Godesberg, Germany, September 1996. Springer LNCS 1268. Google ScholarDigital Library
- 14.Alastair Reid. Malloc pointers and stable pointers: improving Haskell's foreign language interface. In Glasgow Functional Programming Workshop Draft Proceedings, Ayr, Scotland, September 1994.Google Scholar
- 15.N. RSjemo. Highlights from nhc - a space efficient Haskell compiler. In Proc. 7th Intl. Conf. on Functional Programming Languages and Computer Architecture (FPCA '95), pages 282-292, La Jolla, June 1995. ACM Press. Google ScholarDigital Library
- 16.C. Runciman and N. RSjemo. Heap profiling for space efficiency. In J. Launchbury, E. Meijer, and T. Sheard, editors, 2nd Intl. School on Advanced Functional Programming, pages 159-183, Olympia, WA, August 1996. Springer LNCS Vol. 1129. Google Scholar
- 17.Olin Shivers. Automatic management of operating system resources. In 2rd International Conference on Functional Programming (ICFP'97), pages 274-279, Amsterdam, NL, June 1997. ACM Press. Google ScholarDigital Library
- 18.J. Sparud and C. Runciman. Tracing lazy functional computations using redex trails. In Proc. of the 9th Intl. Symp. on Programming Languages: Implementations, Logics, and Programs (PLILP'97), pages 291- 308, Southampton, September 1997. Springer LNCS 1292. Google ScholarDigital Library
- 19.Simon Thompson. Haskell: The Craft of Functional Programming. Addison-Wesley, 1996. Google ScholarDigital Library
- 20.D. Wakeling. The dynamic compilation of lazy functional programs. Journal of Functional Programming, 8(1):61-82~ January 1998. Google ScholarDigital Library
- 21.M. Wallace and C. Runciman. Heap compression and binary I/O in Haskell. In J. Launchbury, editor, 2nd Haskell Workshop, Amsterdam, NL, June 1997.Google Scholar
- 22.D.A. Ziff, S.P. Spackman, and K. Waclena. Funser: a functional server for textual information retrieval. Journal of Functional Programming, 5(3):317-343, July 1995.Google ScholarCross Ref
Index Terms
- The bits between the lambdas: binary data in a lazy functional language
Recommendations
The bits between the lambdas: binary data in a lazy functional language
For the programmer, storage media are usually assumed to have a minimum atomic unit of transfer of one byte. However, sometimes it is useful to have an even finer storage granularity of one bit, for instance in order to compress data.This paper ...
Stealing bits from a quantized source
We consider "bit stealing" scenarios where the rate of a source code must be reduced without prior planning. We first investigate the efficiency of source requantization to reduce rate, which we term successive degradation. We focus on finite-alphabet ...
Image Compression Algorithm Based on Decreasing Bits Coding
IAS '09: Proceedings of the 2009 Fifth International Conference on Information Assurance and Security - Volume 01In this paper, a new image compression algorithm based on decreasing bits coding, a conception of compression cell, and compression operator about a number of consecutive Z are put forward. The basic idea is as follows. First, wavelet coefficients, with ...
Comments