home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacHaskell 2.2 / progs / lib / hbc / README < prev    next >
Encoding:
Text File  |  1994-09-27  |  4.1 KB  |  115 lines  |  [TEXT/ttxt]

  1. These libraries are adapted from the lml library.  Also included are a number
  2. of Common Lisp functions.
  3.  
  4. The hbc library contains the following modules and functions:
  5.  
  6. * module Either
  7.     ** Now part of Prelude **
  8.  
  9. * module Option
  10.     type for success or failure
  11.     data Option a = None | Some a
  12.     thenO :: Option a -> (a -> Option b) -> Option b    apply a function that may fail
  13.  
  14.  
  15. * module ListUtil
  16.     Various useful functions involving lists that are missing from the Prelude
  17.     assoc :: (Eq c) => (a -> b) -> b -> [(c, a)] -> c -> b
  18.         assoc f d l k looks for k in the association list l, if it is found f is applied to the value, otherwise d is returned
  19.     concatMap :: (a -> [b]) -> [a] -> [b]
  20.         flattening map (LMLs concmap)
  21.     unfoldr :: (a -> (b, a)) -> (a -> Bool) -> a -> [b]
  22.         unfoldr f p x repeatedly applies f to x until (p x) holds. (f x) should give a list element and a new x
  23.     mapAccuml :: (a -> b -> (a, c)) -> a -> [b] -> (a, [c])
  24.         mapAccuml f s l  maps f over l, but also threads the state s though (LMLs mapstate)
  25.     union :: (Eq a) => [a] -> [a] -> [a]
  26.         unions of two lists
  27.     intersection :: (Eq a) => [a] -> [a] -> [a]
  28.         intersection of two lists
  29.     chopList :: ([a] -> (b, [a])) -> [a] -> [b]
  30.         LMLs choplist
  31.     assocDef :: (Eq a) => [(a, b)] -> b -> a -> b
  32.         LMLs assocdef
  33.     lookup :: (Eq a) => [(a, b)] -> a -> Option b
  34.         lookup l k looks for the key k in the association list l and returns an optional value
  35.  
  36. * module Pretty
  37.     John Hughes pretty printing library.    
  38.     type Context = (Bool, Int, Int, Int)
  39.     type IText = Context -> [String]
  40.     text :: String -> IText                just text
  41.     (~.) :: IText -> IText -> IText            horizontal composition
  42.     (^.) :: IText -> IText -> IText            vertical composition
  43.     separate :: [IText] -> IText            separate by spaces
  44.     nest :: Int -> IText -> IText            indent
  45.     pretty :: Int -> Int -> IText -> String        format it
  46.  
  47. * module QSort
  48.     Sort function using quicksort.
  49.     sortLe :: (a -> a -> Bool) -> [a] -> [a]    sort le l  sorts l with le as less than predicate
  50.     sort :: (Ord a) => [a] -> [a]            sort l  sorts l using the Ord class
  51.  
  52. * module Random
  53.     Random numbers.
  54.     randomInts :: Int -> Int -> [Int]        given two seeds gives a list of random Int
  55.     randomDoubles :: Int -> Int -> [Double]        given two seeds gives a list of random Double
  56.  
  57. * module RunDialogue
  58.     Test run programs of type Dialogue.
  59.     Only a few Requests are implemented, unfortunately not ReadChannel.
  60.     run :: Dialogue -> String            just run the program, showing the output
  61.     runTrace :: Dialogue -> String            run the program, showing each Request and Response
  62.  
  63. * module Miranda
  64.     Functions found in the Miranda(tm) library.
  65.  
  66. * module Printf
  67.     C printf style formatting.  Handles same types as printf in C, but requires the arguments
  68.     to be tagged.  Useful for formatting of floating point values.
  69.     data UPrintf = UChar Char | UString String | UInt Int | UInteger Integer | UFloat Float | UDouble Double
  70.     printf :: String -> [UPrintf] -> String        convert arguments in the list according to the formatting string
  71.  
  72.  
  73. * module Time
  74.     Manipulate time values (a Double with seconds since 1970).
  75.     --               year mon  day  hour min  sec  dec-sec  weekday
  76.     data Time = Time Int  Int  Int  Int  Int  Int  Double  Int
  77.     dblToTime :: Double -> Time            convert a Double to a Time
  78.     timeToDbl :: Time -> Double            convert a Time to a Double
  79.     timeToString :: Time -> String            convert a Time to a readable String
  80.  
  81.  
  82. * module Native
  83.     Conversion between native machine representations and byte streams,
  84.     and binary I/O operations.
  85.  
  86.     Similar (but not identical to) the hbc extension of the same name.
  87.     The main difference is that Bytes are not Chars and cannot be written
  88.     to ordinary files.  You must use the primitives defined in this module
  89.     to manipulate ByteFiles instead.  Plus, it's more efficient to read
  90.     and write objects directly to ByteFiles than to convert to Bytes first.
  91.  
  92.     See Native.hs for the exported functions.  Also, NativeTest.hs has
  93.     some examples.
  94.  
  95.     NOTE:  This module currently only works in CMUCL-based Haskell.
  96.  
  97.  
  98.  
  99.  
  100. -----  To add:
  101.  
  102. Bytes
  103. IO Library
  104. Word oprtations
  105. Time clock stuff
  106. Lisp stuff: symbols
  107.             hashtables
  108.             strings
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.