From: rrt Date: Wed, 12 Jan 2000 18:05:49 +0000 (+0000) Subject: [project @ 2000-01-12 18:05:49 by rrt] X-Git-Tag: Approximately_9120_patches~5305 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=404513d3a2fb573e4fde65051f0e6c9fc000a34e;p=ghc-hetmet.git [project @ 2000-01-12 18:05:49 by rrt] Libraries documentation moved to hslibs tree. --- diff --git a/ghc/docs/users_guide/4-04-notes.sgml b/ghc/docs/users_guide/4-04-notes.sgml index e8e6792..69ac428 100644 --- a/ghc/docs/users_guide/4-04-notes.sgml +++ b/ghc/docs/users_guide/4-04-notes.sgml @@ -204,7 +204,7 @@ Assertion failures now raise an AssertionFailed exception. -Added simple high-level interface to the Regex library, see . +Added simple high-level interface to the Regex library, see the libraries manual. diff --git a/ghc/docs/users_guide/ByteArray.sgml b/ghc/docs/users_guide/ByteArray.sgml deleted file mode 100644 index b82f1ef..0000000 --- a/ghc/docs/users_guide/ByteArray.sgml +++ /dev/null @@ -1,77 +0,0 @@ - -The ByteArray -<IndexTerm><Primary>ByteArray</Primary></IndexTerm> -interface - - - -ByteArray interface (GHC extensions) - - - -ByteArrays are chunks of immutable Haskell heap: - - - - - -data ByteArray ix -- abstract - -- instance of: Eq, CCallable. - -newByteArray :: Ix ix => (ix,ix) -> ST s (ByteArray ix) - -indexCharArray :: Ix ix => ByteArray ix -> ix -> Char -indexIntArray :: Ix ix => ByteArray ix -> ix -> Int -indexAddrArray :: Ix ix => ByteArray ix -> ix -> Addr -indexFloatArray :: Ix ix => ByteArray ix -> ix -> Float -indexDoubleArray :: Ix ix => ByteArray ix -> ix -> Double - -sizeofByteArray :: Ix ix => ByteArray ix -> Int - - -newByteArray -indexCharArray -indexIntArray -indexAddrArray -indexFloatArray -indexDoubleArray -indexDoubleArray -sizeofByteArray - - - -Remarks: - - - - - - - - -The operation newByteArray creates a byte array of length -equal to the range of its indices in bytes. - - - - - -sizeofByteArray returns the size of the byte array, in bytes. - - - - - - -Equality on byte arrays is value equality, not pointer equality (as is -the case for its mutable variant.) Two byte arrays are equal if -they're of the same length and they're pairwise equal. - - - - - - - - - diff --git a/ghc/docs/users_guide/MutableArray.sgml b/ghc/docs/users_guide/MutableArray.sgml deleted file mode 100644 index 4335497..0000000 --- a/ghc/docs/users_guide/MutableArray.sgml +++ /dev/null @@ -1,270 +0,0 @@ - -MutableArray -<IndexTerm><Primary>MutableArray</Primary></IndexTerm> - - - -The MutableArray interface provide operations for reading and -writing values to mutable arrays. There's two kinds of -mutable arrays, the mutatable version of Haskell Arrays -and mutable byte arrays, chunks of memory containing -values of some basic type. - - - -Mutable arrays -<IndexTerm><Primary>Mutable arrays</Primary></IndexTerm> - - - -The mutable array section of the API provides the following -operations: - - - - - --- mutable arrays: -newArray :: Ix ix -> (ix,ix) -> elt -> ST s (MutableArray s ix elt) -boundsOfArray :: Ix ix => MutableArray s ix elt -> (ix, ix) -readArray :: Ix ix => MutableArray s ix elt -> ix -> ST s elt -writeArray :: Ix ix => MutableArray s ix elt -> ix -> elt -> ST s () -freezeArray :: Ix ix => MutableArray s ix elt -> ST s (Array ix elt) -thawArray :: Ix ix => Array ix elt -> ST s (MutableArray s ix elt) - -unsafeFreezeArray :: Ix ix => MutableArray s ix elt -> ST s (Array ix elt) -unsafeThawArray :: Ix ix => Array ix elt -> ST s (MutableArray s ix elt) - - -newArray -boundsOfArray -readArray -writeArray -freezeArray -thawArray -unsafeFreezeArray -unsafeThawArray - - - -Remarks: - - - - - - - - -The freezeArray action converts a mutable array into an -immutable one by copying, whereas unsafeFreezeArray returns -an immutable array that is effectively just the type cast version -of the mutable array. Should you write to the mutable array after -it has been (unsafely) frozen, you'll side-effect the immutable -array in the process. Please don't :-) - - - - - - -The operation thawArray goes the other way, converting -an immutable Array into a mutable one. This is done by -copying. The operation unsafeThawArray is also provided, -which places the same kind of proof obligation on the programmer -as unsafeFreezeArray does. - - - - - - - - - - -Mutable byte arrays -<IndexTerm><Primary>Mutable byte arrays</Primary></IndexTerm> - - - - --- creators: -newCharArray :: Ix ix => (ix,ix) -> ST s (MutableByteArray s ix) -newAddrArray :: Ix ix => (ix,ix) -> ST s (MutableByteArray s ix) -newIntArray :: Ix ix => (ix,ix) -> ST s (MutableByteArray s ix) -newWordArray :: Ix ix => (ix,ix) -> ST s (MutableByteArray s ix) -newFloatArray :: Ix ix => (ix,ix) -> ST s (MutableByteArray s ix) -newDoubleArray :: Ix ix => (ix,ix) -> ST s (MutableByteArray s ix) -newStablePtrArray :: Ix ix => (ix,ix) -> ST s (MutableByteArray s ix) - -boundsOfMutableByteArray - :: Ix ix => MutableByteArray s ix -> (ix, ix) - -readCharArray :: Ix ix => MutableByteArray s ix -> ix -> ST s Char -readIntArray :: Ix ix => MutableByteArray s ix -> ix -> ST s Int -readAddrArray :: Ix ix => MutableByteArray s ix -> ix -> ST s Addr -readFloatArray :: Ix ix => MutableByteArray s ix -> ix -> ST s Float -readDoubleArray :: Ix ix => MutableByteArray s ix -> ix -> ST s Double -readStablePtrArray :: Ix ix => MutableByteArray s ix -> ix -> ST s (StablePtr a) -readWord8Array :: Ix ix => MutableByteArray s ix -> ix -> ST s Word8 -readWord16Array :: Ix ix => MutableByteArray s ix -> ix -> ST s Word16 -readWord32Array :: Ix ix => MutableByteArray s ix -> ix -> ST s Word32 -readWord64Array :: Ix ix => MutableByteArray s ix -> ix -> ST s Word64 -readInt8Array :: Ix ix => MutableByteArray s ix -> ix -> ST s Int8 -readInt16Array :: Ix ix => MutableByteArray s ix -> ix -> ST s Int16 -readInt32Array :: Ix ix => MutableByteArray s ix -> ix -> ST s Int32 -readInt64Array :: Ix ix => MutableByteArray s ix -> ix -> ST s Int64 - -writeCharArray :: Ix ix => MutableByteArray s ix -> ix -> Char -> ST s () -writeIntArray :: Ix ix => MutableByteArray s ix -> ix -> Int -> ST s () -writeAddrArray :: Ix ix => MutableByteArray s ix -> ix -> Addr -> ST s () -writeFloatArray :: Ix ix => MutableByteArray s ix -> ix -> Float -> ST s () -writeDoubleArray :: Ix ix => MutableByteArray s ix -> ix -> Double -> ST s () -writeStablePtrArray :: Ix ix => MutableByteArray s ix -> ix -> StablePtr a -> ST s () -writeWord8Array :: Ix ix => MutableByteArray s ix -> ix -> Word8 -> ST s () -writeWord16Array :: Ix ix => MutableByteArray s ix -> ix -> Word16 -> ST s () -writeWord32Array :: Ix ix => MutableByteArray s ix -> ix -> Word32 -> ST s () -writeWord64Array :: Ix ix => MutableByteArray s ix -> ix -> Word64 -> ST s () -writeInt8Array :: Ix ix => MutableByteArray s ix -> ix -> Int8 -> ST s () -writeInt16Array :: Ix ix => MutableByteArray s ix -> ix -> Int16 -> ST s () -writeInt32Array :: Ix ix => MutableByteArray s ix -> ix -> Int32 -> ST s () -writeInt64Array :: Ix ix => MutableByteArray s ix -> ix -> Int64 -> ST s () - -freezeCharArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix) -freezeIntArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix) -freezeAddrArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix) -freezeFloatArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix) -freezeDoubleArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix) -freezeStablePtrArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix) - -unsafeFreezeByteArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix) - -sizeofMutableByteArray :: Ix ix => MutableByteArray s ix -> Int - -thawByteArray :: Ix ix => ByteArray ixt -> ST s (MutableByteArray s ix) -unsafeThawByteArray :: Ix ix => ByteArray ixt -> ST s (MutableByteArray s ix) - - -newCharArray -newAddrArray -newIntArray -newFloatArray -newDoubleArray -boundsOfMutableByteArray -readCharArray -readIntArray -readAddrArray -readFloatArray -readDoubleArray -readWord8Array -readWord16Array -readWord32Array -readWord64Array -readInt8Array -readInt16Array -readInt32Array -readInt64Array -writeCharArray -writeIntArray -writeAddrArray -writeFloatArray -writeDoubleArray -writeWord8Array -writeWord16Array -writeWord32Array -writeWord64Array -writeInt8Array -writeInt16Array -writeInt32Array -writeInt64Array -freezeCharArray -freezeIntArray -freezeAddrArray -freezeFloatArray -freezeDoubleArray -unsafeFreezeByteArray -unsafeThawByteArray -thawByteArray - - - -Remarks: - - - - - -A Mutable byte array is created by specifying its size in units of -some basic type. For example, - - - -mkPair :: ST s (MutableByteArray s Int) -mkPair = newIntArray (0,1) - - - -creates a mutable array capable of storing two Ints. Notice -that the range size is not in bytes, but in units of the -basic type. - - - - - - -A mutable byte array is not parameterised over the kind of values -it contains. A consequence of this is that it is possible to -have byte arrays containing a mix of basic types, or even read -a value from the array at a different type from which it was -written, e.g., - - -isLitteEndian :: IO Bool -isLitteEndian = stToIO $ do - x <- newIntArray (0,1) - writeIntArray x 1 - v <- readCharArray x 0 - return (v == chr 1) - - - -It's left as an exercise for the reader to determine whether having -byte arrays not be parameterised over the type of values they -contain is a bug or a feature.. - - - - - -As for mutable arrays, operations for turning mutable byte arrays -into immutable byte arrays are also provided by the freeze* -class of actions. There's also the non-copying -unsafeFreezeByteArray. - - - - - -Operations for going the other way, where an immutable byte -array is 'thawed' are also provided. thawByteArray does -this by copying, whereas unsafeThawByteArray does not - - - - - - -The operation sizeofMutableByteArray returns the size of -the array, in bytes. - - - - - - - - - - diff --git a/ghc/docs/users_guide/libmisc.sgml b/ghc/docs/users_guide/libmisc.sgml deleted file mode 100644 index ba928bd..0000000 --- a/ghc/docs/users_guide/libmisc.sgml +++ /dev/null @@ -1,1046 +0,0 @@ - -Miscellaneous libraries - - - -libraries, miscellaneous -misc, syslib - - - -This section describes a collection of Haskell libraries we've -collected over the years. Access to any of these modules is provided -by giving the -syslib misc option. - - - -The <Literal>Bag</Literal> type - - - -Bag module (misc syslib) - - - -A bag is an unordered collection of elements which may contain -duplicates. To use, import Bag. - - - - - -data Bag elt -- abstract - -emptyBag :: Bag elt -unitBag :: elt -> Bag elt - -consBag :: elt -> Bag elt -> Bag elt -snocBag :: Bag elt -> elt -> Bag elt - -unionBags :: Bag elt -> Bag elt -> Bag elt -unionManyBags :: [Bag elt] -> Bag elt - -isEmptyBag :: Bag elt -> Bool -elemBag :: Eq elt => elt -> Bag elt -> Bool - -filterBag :: (elt -> Bool) -> Bag elt -> Bag elt -partitionBag :: (elt -> Bool) -> Bag elt-> (Bag elt, Bag elt) - -- returns the elements that do/don't satisfy the predicate - -concatBag :: Bag (Bag a) -> Bag a -foldBag :: (r -> r -> r) -> (a -> r) -> r -> Bag a -> r -mapBag :: (a -> b) -> Bag a -> Bag b - -listToBag :: [elt] -> Bag elt -bagToList :: Bag elt -> [elt] - - - - - - - -The <Literal>FiniteMap</Literal> type - - - -FiniteMap module (misc syslib) - - - -What functional programmers call a finite map, everyone else -calls a lookup table. - - - -Out code is derived from that in this paper: -S Adams -"Efficient sets: a balancing act" -Journal of functional programming 3(4) Oct 1993, pages 553-562 -Guess what? The implementation uses balanced trees. - - - - - -data FiniteMap key elt -- abstract - --- BUILDING -emptyFM :: FiniteMap key elt -unitFM :: key -> elt -> FiniteMap key elt -listToFM :: Ord key => [(key,elt)] -> FiniteMap key elt - -- In the case of duplicates, the last is taken - --- ADDING AND DELETING - -- Throws away any previous binding - -- In the list case, the items are added starting with the - -- first one in the list -addToFM :: Ord key => FiniteMap key elt -> key -> elt -> FiniteMap key elt -addListToFM :: Ord key => FiniteMap key elt -> [(key,elt)] -> FiniteMap key elt - - -- Combines with previous binding - -- In the combining function, the first argument is - -- the "old" element, while the second is the "new" one. -addToFM_C :: Ord key => (elt -> elt -> elt) - -> FiniteMap key elt -> key -> elt - -> FiniteMap key elt -addListToFM_C :: Ord key => (elt -> elt -> elt) - -> FiniteMap key elt -> [(key,elt)] - -> FiniteMap key elt - - -- Deletion doesn't complain if you try to delete something - -- which isn't there -delFromFM :: Ord key => FiniteMap key elt -> key -> FiniteMap key elt -delListFromFM :: Ord key => FiniteMap key elt -> [key] -> FiniteMap key elt - --- COMBINING - -- Bindings in right argument shadow those in the left -plusFM :: Ord key => FiniteMap key elt -> FiniteMap key elt - -> FiniteMap key elt - - -- Combines bindings for the same thing with the given function -plusFM_C :: Ord key => (elt -> elt -> elt) - -> FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt - -minusFM :: Ord key => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt - -- (minusFM a1 a2) deletes from a1 any bindings which are bound in a2 - -intersectFM :: Ord key => FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt -intersectFM_C :: Ord key => (elt -> elt -> elt) - -> FiniteMap key elt -> FiniteMap key elt -> FiniteMap key elt - --- MAPPING, FOLDING, FILTERING -foldFM :: (key -> elt -> a -> a) -> a -> FiniteMap key elt -> a -mapFM :: (key -> elt1 -> elt2) -> FiniteMap key elt1 -> FiniteMap key elt2 -filterFM :: Ord key => (key -> elt -> Bool) - -> FiniteMap key elt -> FiniteMap key elt - --- INTERROGATING -sizeFM :: FiniteMap key elt -> Int -isEmptyFM :: FiniteMap key elt -> Bool - -elemFM :: Ord key => key -> FiniteMap key elt -> Bool -lookupFM :: Ord key => FiniteMap key elt -> key -> Maybe elt -lookupWithDefaultFM - :: Ord key => FiniteMap key elt -> elt -> key -> elt - -- lookupWithDefaultFM supplies a "default" elt - -- to return for an unmapped key - --- LISTIFYING -fmToList :: FiniteMap key elt -> [(key,elt)] -keysFM :: FiniteMap key elt -> [key] -eltsFM :: FiniteMap key elt -> [elt] - - - - - - - -The <Literal>ListSetOps</Literal> type - - - -ListSetOps module (misc syslib) - - - -Just a few set-sounding operations on lists. If you want sets, use -the Set module. - - - - - -unionLists :: Eq a => [a] -> [a] -> [a] -intersectLists :: Eq a => [a] -> [a] -> [a] -minusList :: Eq a => [a] -> [a] -> [a] -disjointLists :: Eq a => [a] -> [a] -> Bool -intersectingLists :: Eq a => [a] -> [a] -> Bool - - - - - - - -The <Literal>Maybes</Literal> type - - - -Maybes module (misc syslib) - - - -The Maybe type is in the Haskell 1.4 prelude. Moreover, the -required Maybe library provides many useful functions on -Maybes. This (pre-1.3) module provides some more: - - - -An Either-like type called MaybeErr: - - -data MaybeErr val err = Succeeded val | Failed err - - - - - -Some operations to do with Maybe (some commentary follows): - - -maybeToBool :: Maybe a -> Bool -- Nothing => False; Just => True -allMaybes :: [Maybe a] -> Maybe [a] -firstJust :: [Maybe a] -> Maybe a -findJust :: (a -> Maybe b) -> [a] -> Maybe b - -assocMaybe :: Eq a => [(a,b)] -> a -> Maybe b -mkLookupFun :: (key -> key -> Bool) -- Equality predicate - -> [(key,val)] -- The assoc list - -> (key -> Maybe val) -- A lookup fun to use -mkLookupFunDef :: (key -> key -> Bool) -- Equality predicate - -> [(key,val)] -- The assoc list - -> val -- Value to return on failure - -> key -- The key - -> val -- The corresponding value - - -- a monad thing -thenMaybe :: Maybe a -> (a -> Maybe b) -> Maybe b -returnMaybe :: a -> Maybe a -failMaybe :: Maybe a -mapMaybe :: (a -> Maybe b) -> [a] -> Maybe [b] - - - - - -NB: catMaybes which used to be here, is now available via the -standard Maybe interface (Maybe is an instance of MonadPlus). - - - -allMaybes collects a list of Justs into a single Just, returning -Nothing if there are any Nothings. - - - -firstJust takes a list of Maybes and returns the -first Just if there is one, or Nothing otherwise. - - - -assocMaybe looks up in an association list, returning -Nothing if it fails. - - - -Now, some operations to do with MaybeErr (comments follow): - - - -- a monad thing (surprise, surprise) -thenMaB :: MaybeErr a err -> (a -> MaybeErr b err) -> MaybeErr b err -returnMaB :: val -> MaybeErr val err -failMaB :: err -> MaybeErr val err - -listMaybeErrs :: [MaybeErr val err] -> MaybeErr [val] [err] -foldlMaybeErrs :: (acc -> input -> MaybeErr acc err) - -> acc - -> [input] - -> MaybeErr acc [err] - - - - - -listMaybeErrs takes a list of MaybeErrs and, if they all succeed, -returns a Succeeded of a list of their values. If any fail, it -returns a Failed of the list of all the errors in the list. - - - -foldlMaybeErrs works along a list, carrying an accumulator; it -applies the given function to the accumulator and the next list item, -accumulating any errors that occur. - - - - - -The <Literal>Memo</Literal> library - - - -Memo (misc syslib) - - - -The Memo library provides fast polymorphic memo functions using hash -tables. The interface is: - - - - - -memo :: (a -> b) -> a -> b - - - - - -So, for example, memo f is a version of f that caches the results -of previous calls. - - - -The searching is very fast, being based on pointer equality. One -consequence of this is that the caching will only be effective if -exactly the same argument is passed again to the memoised -function. This means not just a copy of a previous argument, but the -same instance. It's not useful to memoise integer functions using -this interface, because integers are generally copied a lot and two -instances of '27' are unlikely to refer to the same object. - - - -This memoisation library works well when the keys are large (or even -infinite). - - - -The memo table implementation uses weak pointers and stable names (see -the GHC/Hugs library document) to avoid space leaks and allow hashing -for arbitrary Haskell objects. NOTE: while individual memo table -entries will be garbage collected if the associated key becomes -garbage, the memo table itself will not be collected if the function -becomes garbage. We plan to fix this in a future version. - - - -There's another version of memo if you want to explicitly give a -size for the hash table (the default size is 1001 buckets): - - - - - -memo_sized :: Int -> (a -> b) -> a -> b - - - - - - - -The <Literal>PackedString</Literal> type - - - -PackedString module (misc syslib) - - - -You need to import PackedString and heave in your - to use PackedStrings. - - - -The basic type and functions available are: - - -data PackedString -- abstract - -packString :: [Char] -> PackedString -packStringST :: [Char] -> ST s PackedString -packCBytesST :: Int -> Addr -> ST s PackedString -packBytesForCST :: [Char] -> ST s (ByteArray Int) -byteArrayToPS :: ByteArray Int -> PackedString -unsafeByteArrayToPS :: ByteArray a -> Int -> PackedString -psToByteArray :: PackedString -> ByteArray Int -psToByteArrayST :: PackedString -> ST s (ByteArray Int) - -unpackPS :: PackedString -> [Char] - - - - - -We also provide a wad of list-manipulation-like functions: - - -nilPS :: PackedString -consPS :: Char -> PackedString -> PackedString - -headPS :: PackedString -> Char -tailPS :: PackedString -> PackedString -nullPS :: PackedString -> Bool -appendPS :: PackedString -> PackedString -> PackedString -lengthPS :: PackedString -> Int -indexPS :: PackedString -> Int -> Char - -- 0-origin indexing into the string -mapPS :: (Char -> Char) -> PackedString -> PackedString -filterPS :: (Char -> Bool) -> PackedString -> PackedString -foldlPS :: (a -> Char -> a) -> a -> PackedString -> a -foldrPS :: (Char -> a -> a) -> a -> PackedString -> a -takePS :: Int -> PackedString -> PackedString -dropPS :: Int -> PackedString -> PackedString -splitAtPS :: Int -> PackedString -> (PackedString, PackedString) -takeWhilePS :: (Char -> Bool) -> PackedString -> PackedString -dropWhilePS :: (Char -> Bool) -> PackedString -> PackedString -spanPS :: (Char -> Bool) -> PackedString -> (PackedString, PackedString) -breakPS :: (Char -> Bool) -> PackedString -> (PackedString, PackedString) -linesPS :: PackedString -> [PackedString] -wordsPS :: PackedString -> [PackedString] -reversePS :: PackedString -> PackedString -concatPS :: [PackedString] -> PackedString -elemPS :: Char -> PackedString -> Bool - -- Perl-style split&join -splitPS :: Char -> PackedString -> [PackedString] -splitWithPS :: (Char -> Bool) -> PackedString -> [PackedString] -joinPS :: PackedString -> [PackedString] -> PackedString - -substrPS :: PackedString -> Int -> Int -> PackedString - -- pluck out a piece of a PackedString - -- start and end chars you want; both 0-origin-specified - - - - - - - -The <Literal>Set</Literal> type - - - -Set module (misc syslib) - - - -Our implementation of sets (key property: no duplicates) is just -a variant of the FiniteMap module. - - - - - -data Set -- abstract - -- instance of: Eq - -emptySet :: Set a -mkSet :: Ord a => [a] -> Set a -setToList :: Set a -> [a] -unitSet :: a -> Set a -singletonSet :: a -> Set a -- deprecated, use unitSet. - -union :: Ord a => Set a -> Set a -> Set a -unionManySets :: Ord a => [Set a] -> Set a -minusSet :: Ord a => Set a -> Set a -> Set a -mapSet :: Ord a => (b -> a) -> Set b -> Set a -intersect :: Ord a => Set a -> Set a -> Set a - -elementOf :: Ord a => a -> Set a -> Bool -isEmptySet :: Set a -> Bool - -cardinality :: Set a -> Int - - - - - - - -The <Literal>BitSet</Literal> interface - - - -Bitset interface (misc syslib) - - - -Bit sets are a fast implementation of sets of integers ranging from 0 -to one less than the number of bits in a machine word (typically 31). -If any element exceeds the maximum value for a particular machine -architecture, the results of these operations are undefined. You have -been warned. - - - - - -data BitSet -- abstract - -- instance of: - -emptyBS :: BitSet -mkBS :: [Int] -> BitSet -unitBS :: Int -> BitSet -unionBS :: BitSet -> BitSet -> BitSet -minusBS :: BitSet -> BitSet -> BitSet -isEmptyBS :: BitSet -> Bool -intersectBS :: BitSet -> BitSet -> BitSet -elementBS :: Int -> BitSet -> Bool -listBS :: BitSet -> [Int] - - - - - - - -The <Literal>Util</Literal> type - - - -Util module (misc syslib) - - - -Stuff that has been generally useful to use in writing the compiler. -Don't be too surprised if this stuff moves/gets-renamed/etc. - - - - - --- general list processing -forall :: (a -> Bool) -> [a] -> Bool -exists :: (a -> Bool) -> [a] -> Bool - -nOfThem :: Int -> a -> [a] -lengthExceeds :: [a] -> Int -> Bool -isSingleton :: [a] -> Bool - ---paranoid zip'ing (equal length lists) -zipEqual :: [a] -> [b] -> [(a,b)] -zipWithEqual :: String -> (a->b->c) -> [a]->[b]->[c] -zipWith3Equal :: String -> (a->b->c->d) -> [a]->[b]->[c]->[d] -zipWith4Equal :: String -> (a->b->c->d->e) -> [a]->[b]->[c]->[d]->[e] --- lazy in second argument -zipLazy :: [a] -> [b] -> [(a,b)] - -mapAndUnzip :: (a -> (b, c)) -> [a] -> ([b], [c]) -mapAndUnzip3 :: (a -> (b, c, d)) -> [a] -> ([b], [c], [d]) - --- prefix and suffix matching on lists of characters. -startsWith :: {-prefix-}String -> String -> Maybe String -endsWith :: {-suffix-}String -> String -> Maybe String - --- association lists -assoc :: Eq a => String -> [(a, b)] -> a -> b - --- duplicate handling -hasNoDups :: Eq a => [a] -> Bool -equivClasses :: (a -> a -> Ordering) -> [a] -> [[a]] -runs :: (a -> a -> Bool) -> [a] -> [[a]] -removeDups :: (a -> a -> Ordering) -> [a] -> ([a], [[a]]) - --- sorting (don't complain of no choice...) -quicksort :: (a -> a -> Bool) -> [a] -> [a] -sortLt :: (a -> a -> Bool) -> [a] -> [a] -stableSortLt :: (a -> a -> Bool) -> [a] -> [a] -mergesort :: (a -> a -> _CMP_TAG) -> [a] -> [a] -mergeSort :: Ord a => [a] -> [a] -naturalMergeSort :: Ord a => [a] -> [a] -mergeSortLe :: Ord a => [a] -> [a] -naturalMergeSortLe :: Ord a => [a] -> [a] - --- transitive closures -transitiveClosure :: (a -> [a]) -- Successor function - -> (a -> a -> Bool) -- Equality predicate - -> [a] - -> [a] -- The transitive closure - --- accumulating (Left, Right, Bi-directional) -mapAccumL :: (acc -> x -> (acc, y)) - -- Function of elt of input list and - -- accumulator, returning new accumulator and - -- elt of result list - -> acc -- Initial accumulator - -> [x] -- Input list - -> (acc, [y]) -- Final accumulator and result list - -mapAccumR :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y]) - -mapAccumB :: (accl -> accr -> x -> (accl, accr,y)) - -> accl -> accr -> [x] - -> (accl, accr, [y]) - ---list comparison with explicit element comparer. -cmpList :: (a -> a -> Ordering) -> [a] -> [a] -> Ordering - --- pairs -applyToPair :: ((a -> c), (b -> d)) -> (a, b) -> (c, d) -applyToFst :: (a -> c) -> (a, b) -> (c, b) -applyToSnd :: (b -> d) -> (a, b) -> (a, d) -foldPair :: (a->a->a, b->b->b) -> (a, b) -> [(a, b)] -> (a, b) -unzipWith :: (a -> b -> c) -> [(a, b)] -> [c] - - - - - - - - - -Interfaces to C libraries - - - -C library interfaces -interfaces, C library - - - -The GHC system library () also provides interfaces to -several useful C libraries, mostly from the GNU project. - - - -The <Literal>Readline</Literal> interface - - - -Readline library (misc syslib) -command-line editing library - - - -(Darren Moffat supplied the Readline interface.) - - - -The Readline module is a straightforward interface to the GNU -Readline library. As such, you will need to look at the GNU -documentation (and have a libreadline.a file around somewhere…) - - - -You'll need to link any Readlining program with , -besides the usual (and ). - - - -The main function you'll use is: - - -readline :: String{-the prompt-} -> IO String - - - - - -If you want to mess around with Full Readline G(l)ory, we also -provide: - - -rlInitialize, addHistory, - -rlBindKey, rlAddDefun, RlCallbackFunction(..), - -rlGetLineBuffer, rlSetLineBuffer, rlGetPoint, rlSetPoint, rlGetEnd, -rlSetEnd, rlGetMark, rlSetMark, rlSetDone, rlPendingInput, - -rlPrompt, rlTerminalName, rlSetReadlineName, rlGetReadlineName - - -(All those names are just Haskellised versions of what you -will see in the GNU readline documentation.) - - - - - -The <Literal>Regex</Literal> and <Literal>MatchPS</Literal> interfaces - - - -Regex library (misc syslib) -MatchPS library (misc syslib) -regular-expressions library - - - -(Sigbjorn Finne supplied the regular-expressions interface.) - - - -The Regex library provides quite direct interface to the GNU -regular-expression library, for doing manipulation on PackedStrings. -You probably need to see the GNU documentation if you are operating at -this level. Alternatively, you can use the simpler and higher-level -RegexString interface. - - - -The datatypes and functions that Regex provides are: - - -data PatBuffer # just a bunch of bytes (mutable) - -data REmatch - = REmatch (Array Int GroupBounds) -- for $1, ... $n - GroupBounds -- for $` (everything before match) - GroupBounds -- for $& (entire matched string) - GroupBounds -- for $' (everything after) - GroupBounds -- for $+ (matched by last bracket) - --- GroupBounds hold the interval where a group --- matched inside a string, e.g. --- --- matching "reg(exp)" "a regexp" returns the pair (5,7) for the --- (exp) group. (PackedString indices start from 0) - -type GroupBounds = (Int, Int) - -re_compile_pattern - :: PackedString -- pattern to compile - -> Bool -- True <=> assume single-line mode - -> Bool -- True <=> case-insensitive - -> PrimIO PatBuffer - -re_match :: PatBuffer -- compiled regexp - -> PackedString -- string to match - -> Int -- start position - -> Bool -- True <=> record results in registers - -> PrimIO (Maybe REmatch) - --- Matching on 2 strings is useful when you're dealing with multiple --- buffers, which is something that could prove useful for --- PackedStrings, as we don't want to stuff the contents of a file --- into one massive heap chunk, but load (smaller chunks) on demand. - -re_match2 :: PatBuffer -- 2-string version - -> PackedString - -> PackedString - -> Int - -> Int - -> Bool - -> PrimIO (Maybe REmatch) - -re_search :: PatBuffer -- compiled regexp - -> PackedString -- string to search - -> Int -- start index - -> Int -- stop index - -> Bool -- True <=> record results in registers - -> PrimIO (Maybe REmatch) - -re_search2 :: PatBuffer -- Double buffer search - -> PackedString - -> PackedString - -> Int -- start index - -> Int -- range (?) - -> Int -- stop index - -> Bool -- True <=> results in registers - -> PrimIO (Maybe REmatch) - - - - - -The MatchPS module provides Perl-like ``higher-level'' facilities -to operate on PackedStrings. The regular expressions in -question are in Perl syntax. The ``flags'' on various functions can -include: for case-insensitive, for single-line mode, and - for global. (It's probably worth your time to peruse the -source code…) - - - - - -matchPS :: PackedString -- regexp - -> PackedString -- string to match - -> [Char] -- flags - -> Maybe REmatch -- info about what matched and where - -searchPS :: PackedString -- regexp - -> PackedString -- string to match - -> [Char] -- flags - -> Maybe REmatch - --- Perl-like match-and-substitute: -substPS :: PackedString -- regexp - -> PackedString -- replacement - -> [Char] -- flags - -> PackedString -- string - -> PackedString - --- same as substPS, but no prefix and suffix: -replacePS :: PackedString -- regexp - -> PackedString -- replacement - -> [Char] -- flags - -> PackedString -- string - -> PackedString - -match2PS :: PackedString -- regexp - -> PackedString -- string1 to match - -> PackedString -- string2 to match - -> [Char] -- flags - -> Maybe REmatch - -search2PS :: PackedString -- regexp - -> PackedString -- string to match - -> PackedString -- string to match - -> [Char] -- flags - -> Maybe REmatch - --- functions to pull the matched pieces out of an REmatch: - -getMatchesNo :: REmatch -> Int -getMatchedGroup :: REmatch -> Int -> PackedString -> PackedString -getWholeMatch :: REmatch -> PackedString -> PackedString -getLastMatch :: REmatch -> PackedString -> PackedString -getAfterMatch :: REmatch -> PackedString -> PackedString - --- (reverse) brute-force string matching; --- Perl equivalent is index/rindex: -findPS, rfindPS :: PackedString -> PackedString -> Maybe Int - --- Equivalent to Perl "chop" (off the last character, if any): -chopPS :: PackedString -> PackedString - --- matchPrefixPS: tries to match as much as possible of strA starting --- from the beginning of strB (handy when matching fancy literals in --- parsers): -matchPrefixPS :: PackedString -> PackedString -> Int - - - - - - - -The <Literal>RegexString</Literal> interface - - - -RegexString library (misc syslib) -regular-expressions library - - - -(Simon Marlow supplied the String Regex wrapper.) - - - -For simple regular expression operations, the Regex library is a -little heavyweight. RegexString permits regex matching on ordinary -Haskell Strings. - - - -The datatypes and functions that RegexString provides are: - - -data Regex -- a compiled regular expression - -mkRegex - :: String -- regexp to compile - -> Regex -- compiled regexp - -matchRegex - :: Regex -- compiled regexp - -> String -- string to match - -> Maybe [String] -- text of $1, $2, ... (if matched) - - - - - - - -Network-interface toolkit—<Literal>Socket</Literal> and <Literal>SocketPrim</Literal> - - - -SocketPrim interface (misc syslib) -Socket interface (misc syslib) -network-interface library -sockets library -BSD sockets library -(Darren Moffat supplied the initial version of this library.) - - - -Your best bet for documentation is to look at the code—really!— -normally in -fptools/ghc/lib/misc/{BSD,Socket,SocketPrim.lhs}. - - - -The BSD module provides functions to get at -system-database info; pretty straightforward if you're into this sort of -thing: - - -getHostName :: IO String - -getServiceByName :: ServiceName -> IO ServiceEntry -getServicePortNumber:: ServiceName -> IO PortNumber -getServiceEntry :: IO ServiceEntry -setServiceEntry :: Bool -> IO () -endServiceEntry :: IO () - -getProtocolByName :: ProtocolName -> IO ProtocolEntry -getProtocolByNumber :: ProtocolNumber -> IO ProtcolEntry -getProtocolNumber :: ProtocolName -> ProtocolNumber -getProtocolEntry :: IO ProtocolEntry -setProtocolEntry :: Bool -> IO () -endProtocolEntry :: IO () - -getHostByName :: HostName -> IO HostEntry -getHostByAddr :: Family -> HostAddress -> IO HostEntry -getHostEntry :: IO HostEntry -setHostEntry :: Bool -> IO () -endHostEntry :: IO () - - - - -The SocketPrim interface provides quite direct access to -the socket facilities in a BSD Unix system, including all the -complications. We hope you don't need to use it! See the source if -needed… - - - -The Socket interface is a ``higher-level'' interface to -sockets, and it is what we recommend. Please tell us if the facilities it -offers are inadequate to your task! - - - -The interface is relatively modest: - - -connectTo :: Hostname -> PortID -> IO Handle -listenOn :: PortID -> IO Socket - -accept :: Socket -> IO (Handle, HostName) -sendTo :: Hostname -> PortID -> String -> IO () - -recvFrom :: Hostname -> PortID -> IO String -socketPort :: Socket -> IO PortID - -data PortID -- PortID is a non-abstract type - = Service String -- Service Name eg "ftp" - | PortNumber PortNumber -- User defined Port Number - | UnixSocket String -- Unix family socket in file system - -type Hostname = String - - -- 16-bit value (stored in network byte order). -data PortNumber - -- instance of: Eq, Num, Show. - -mkPortNumber :: Int -> PortNumber - - - - -Various examples of networking Haskell code are provided in - - - - - -The <Literal>Select</Literal> interface - - - -Select interface (misc syslib) - - - -The Select interface provides a Haskell wrapper for the select() -OS call supplied by many modern UNIX variants. Select exports the -following: - - - - - -type TimeOut = Maybe Int - -- Nothing => wait indefinitely. - -- Just x | x >= 0 => block waiting for 'x' micro seconds. - -- | otherwise => block waiting for '-x' micro seconds. - -hSelect :: [Handle] - -> [Handle] - -> [Handle] - -> TimeOut - -> IO SelectResult - -type SelectResult - = ( [Handle] -- input handles ready - , [Handle] -- output handles ready - , [Handle] -- exc. handles ready - ) - - - - - -Here's an example of how it could be used: - - - - - -module Main(main) where - -import Select -import IO - -main :: IO () -main = do - hSetBuffering stdin NoBuffering - putStrLn "waiting for input to appear" - hSelect [stdin] [] [] Nothing - putStrLn "input ready, let's try reading" - x <- getChar - print x - - - - - -where the call to hSelect makes the process go to sleep -until there's input available on stdin. - - - -Notice that this particular use of hSelect is now really a no-op -with GHC compiled code, as its implementation of IO will take care to -avoid blocking the process (i.e., all running Haskell threads), and -call select() for you, if needs be. However, hSelect exposes -functionality that is useful in other contexts (e.g., you want to -wait for input on two Handles for 3 seconds, but no longer.) - - - - - diff --git a/ghc/docs/users_guide/libraries.sgml b/ghc/docs/users_guide/libraries.sgml index 7fe9cfa..1463301 100644 --- a/ghc/docs/users_guide/libraries.sgml +++ b/ghc/docs/users_guide/libraries.sgml @@ -91,17 +91,6 @@ flag). - -GHC/Hugs Extension Libraries - - -The extension libraries provided by both GHC and Hugs are described in -the -GHC/Hugs Extension Library Document - - - GHC-only Extension Libraries @@ -120,73 +109,11 @@ Haskell report says (modulo a few minor issues, see . - - - - - -The <Literal>GlaExts</Literal> interface - - -GlaExts interface (GHC extensions) - - - -The GlaExts interface provides access to extensions that only GHC -implements. These currently are: unboxed types, including the -representations of the primitive types (Int, Float, etc.), and the -GHC primitive operations (+#, ==#, etc.). - - - -This module used to provide access to all the Glasgow extensions, but -these have since been moved into separate libraries for compatibility -with Hugs (version 2.09: in fact, you can still get at this stuff via -GlaExts for compatibility, but this facility will likely be removed -in the future). - - - - - --- the representation of some basic types: -data Char = C# Char# -data Int = I# Int# -data Addr = A# Addr# -data Word = W# Word# -data Float = F# Float# -data Double = D# Double# -data Integer = S# Int# -- small integers - | J# Int# ByteArray# -- large integers - -module GHC -- all primops and primitive types. - - - - - - @@ -337,9 +264,6 @@ allocation during sequences of operations. numeric types, primitive integer types, primitive floating point types, primitive - - - There are the following obvious primitive types: @@ -989,16 +913,12 @@ realWorld# :: State# RealWorld - + Mutable arrays - mutable arrays arrays, mutable - - - Corresponding to Array# and ByteArray#, we have the types of mutable versions of each. In each case, the representation is a pointer to a suitable block of (mutable) heap-allocated storage. @@ -1153,119 +1073,6 @@ unsafeFreezeByteArray# :: MutableByteArray# s -> State# s -> (# State# s -Stable pointers - - -stable pointers -pointers, stable - - - -A stable pointer is a name for a Haskell object which can be passed to -the external world. It is ``stable'' in the sense that the name does -not change when the Haskell garbage collector runs—in contrast to -the address of the object which may well change. - - - -The stable pointer type is parameterised by the type of the thing -which is named. - - - - - -type StablePtr# a - - -StablePtr# - - - -A stable pointer is represented by an index into the (static) -StablePointerTable. The Haskell garbage collector treats the -StablePointerTable as a source of roots for GC. - - - -The makeStablePointer function converts a value into a stable -pointer. It is part of the IO monad, because we want to be sure -we don't allocate one twice by accident, and then only free one of the -copies. - - - - - -makeStablePointer# :: a -> State# RealWorld -> (# State# RealWord, StablePtr# a #) -freeStablePointer# :: StablePtr# a -> State# RealWorld -> State# RealWorld -deRefStablePointer# :: StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) - - -makeStablePointer# -freeStablePointer# -deRefStablePointer# - - - -There is also a C procedure FreeStablePtr which frees a stable pointer. - - - - - -Foreign objects - - -Foreign objects - - - -A ForeignObj# is a reference to an object outside the Haskell world -(i.e., from the C world, or a reference to an object on another -machine completely.), where the Haskell world has been told ``Let me -know when you're finished with this…''. - - - - - -type ForeignObj# - - -ForeignObj# - - - -GHC provides two primitives on ForeignObj#: - - - - - -makeForeignObj# - :: Addr# -- foreign reference - -> Addr# -- pointer to finalisation routine - -> (# State# RealWorld, ForeignObj# ) -writeForeignObj - :: ForeignObj# -- foreign object - -> Addr# -- datum - -> State# RealWorld - -> State# RealWorld - - -makeForeignObj# -writeForeignObj# - - - -The module Foreign (see library documentation) provides a more -programmer-friendly interface to foreign objects. - - - - - Synchronizing variables (M-vars) @@ -1299,7 +1106,4 @@ putMVar# :: SynchVar# s elt -> State# s -> State# s -&posix -&libmisc - diff --git a/ghc/docs/users_guide/posix.sgml b/ghc/docs/users_guide/posix.sgml deleted file mode 100644 index 8fc8994..0000000 --- a/ghc/docs/users_guide/posix.sgml +++ /dev/null @@ -1,2368 +0,0 @@ - -The Posix library - - - -Posix library -libraries, Posix - - - -The Posix interface gives you access to the set of OS -services standardised by POSIX 1003.1b (or the IEEE Portable -Operating System Interface for Computing Environments - IEEE Std. -1003.1). The interface is accessed by import Posix and -adding on your command-line. - - - -Posix data types - - - -Posix, data types - - - - - -data ByteCount -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A ByteCount is a primitive of type unsigned. At a minimum, -an conforming implementation must support values in the range -[0, UINT_MAX]. - - - - - -data ClockTick -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A ClockTick is a primitive of type clock_t, which -is used to measure intervals of time in fractions of a second. The -resolution is determined by getSysVar ClockTick. - - - - - -data DeviceID -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A DeviceID is a primitive of type dev_t. It must -be an arithmetic type. - - - - - -data EpochTime -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A EpochTime is a primitive of type time_t, which is -used to measure seconds since the Epoch. At a minimum, the implementation -must support values in the range [0, INT_MAX]. - - - - - -data FileID -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A FileID is a primitive of type ino_t. It must -be an arithmetic type. - - - - - -data FileMode -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A FileMode is a primitive of type mode_t. -It must be an arithmetic type. - - - - - -data FileOffset -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A FileOffset is a primitive of type off_t. It must -be an arithmetic type. - - - - - -data GroupID -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A GroupID is a primitive of type gid_t. It must -be an arithmetic type. - - -data Limit -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A Limit is a primitive of type long. -At a minimum, the implementation must support values in the range -[LONG_MIN, LONG_MAX]. - - - - - -data LinkCount -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A LinkCount is a primitive of type nlink_t. It must -be an arithmetic type. - - - - - -data ProcessID -- instances of : Eq Ord Num Real Integral Ix Enum Show -type ProcessGroupID = ProcessID - - - - - -A ProcessID is a primitive of type pid_t. It -must be a signed arithmetic type. - - -data UserID -- instances of : Eq Ord Num Real Integral Ix Enum Show - - - - - -A UserID is a primitive of type uid_t. It -must be an arithmetic type. - - - - - -data DirStream - - -A DirStream is a primitive of type DIR *. - - - - - -data FileStatus - - -A FileStatus is a primitive of type struct stat. - - - - - -data GroupEntry - - - - - -A GroupEntry is a primitive of type struct group. - - -data ProcessTimes - - - - - -ProcessTimes is a primitive structure containing a -clock_t and a struct tms. - - - - - -data SignalSet - - - - - -An SignalSet is a primitive of type sigset_t. - - - - - -data SystemID - - - - - -A SystemID is a primitive of type struct utsname. - - - - - -data TerminalAttributes - - -TerminalAttributes is a primitive of type struct termios. - - - - - -data UserEntry - - - - - -A UserEntry is a primitive of type struct passwd. - - - - - -data BaudRate = B0 | B50 | B75 | B110 | B134 | B150 | B200 | B300 | B600 - | B1200 | B1800 | B2400 | B4800 | B9600 | B19200 | B38400 - deriving (Eq, Show) - -data Fd - -intToFd :: Int -> Fd -- use with care. - -data FdOption = AppendOnWrite - | CloseOnExec - | NonBlockingRead - -data ControlCharacter = EndOfFile - | EndOfLine - | Erase - | Interrupt - | Kill - | Quit - | Suspend - | Start - | Stop - -type ErrorCode = Int - -type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset) --- whence start length - -data FlowAction = SuspendOutput | RestartOutput | TransmitStop | TransmitStart - -data Handler = Default | Ignore | Catch (IO ()) - -data LockRequest = ReadLock | WriteLock | Unlock - deriving (Eq, Show) - -data OpenMode = ReadOnly | WriteOnly | ReadWrite - -data PathVar = LinkLimit - | InputLineLimit - | InputQueueLimit - | FileNameLimit - | PathNameLimit - | PipeBufferLimit - | SetOwnerAndGroupIsRestricted - | FileNamesAreNotTruncated - -data QueueSelector = InputQueue | OutputQueue | BothQueues - -type Signal = Int - -data SysVar = ArgumentLimit - | ChildLimit - | ClockTick - | GroupLimit - | OpenFileLimit - | PosixVersion - | HasSavedIDs - | HasJobControl - -data TerminalMode = InterruptOnBreak -- BRKINT - | MapCRtoLF -- ICRNL - | IgnoreBreak -- IGNBRK - | IgnoreCR -- IGNCR - | IgnoreParityErrors -- IGNPAR - | MapLFtoCR -- INLCR - | CheckParity -- INPCK - | StripHighBit -- ISTRIP - | StartStopInput -- IXOFF - | StartStopOutput -- IXON - | MarkParityErrors -- PARMRK - | ProcessOutput -- OPOST - | LocalMode -- CLOCAL - | ReadEnable -- CREAD - | TwoStopBits -- CSTOPB - | HangupOnClose -- HUPCL - | EnableParity -- PARENB - | OddParity -- PARODD - | EnableEcho -- ECHO - | EchoErase -- ECHOE - | EchoKill -- ECHOK - | EchoLF -- ECHONL - | ProcessInput -- ICANON - | ExtendedFunctions -- IEXTEN - | KeyboardInterrupts -- ISIG - | NoFlushOnInterrupt -- NOFLSH - | BackgroundWriteInterrupt -- TOSTOP - -data TerminalState = Immediately | WhenDrained | WhenFlushed - -data ProcessStatus = Exited ExitCode - | Terminated Signal - | Stopped Signal - deriving (Eq, Show) - - - - - - - -Posix Process Primitives - - - - - -forkProcess :: IO (Maybe ProcessID) - - - - - -forkProcess calls fork, returning -Just pid to the parent, where pid is the -ProcessID of the child, and returning Nothing to the -child. - - - - - -executeFile :: FilePath -- Command - -> Bool -- Search PATH? - -> [String] -- Arguments - -> Maybe [(String, String)] -- Environment - -> IO () - - - - - -executeFile cmd args env calls one of the -execv* family, depending on whether or not the current -PATH is to be searched for the command, and whether or not an -environment is provided to supersede the process's current -environment. The basename (leading directory names suppressed) of -the command is passed to execv* as arg[0]; -the argument list passed to executeFile therefore begins with arg[1]. - - - - - -Search PATH? Supersede environ? Call -~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~ -False False execv -False True execve -True False execvp -True True execvpe* - - - - - -Note that execvpe is not provided by the POSIX standard, and must -be written by hand. Care must be taken to ensure that the search path -is extracted from the original environment, and not from the -environment to be passed on to the new image. - - - -NOTE: In general, sharing open files between parent and child -processes is potential bug farm, and should be avoided unless you -really depend on this `feature' of POSIX' fork() semantics. Using -Haskell, there's the extra complication that arguments to -executeFile might come from files that are read lazily (using -hGetContents, or some such.) If this is the case, then for your own -sanity, please ensure that the arguments to executeFile have been -fully evaluated before calling forkProcess (followed by -executeFile.) Consider yourself warned :-) - - - -A successful executeFile overlays the current process image with -a new one, so it only returns on failure. - - - - - -runProcess :: FilePath -- Command - -> [String] -- Arguments - -> Maybe [(String, String)] -- Environment (Nothing -> Inherited) - -> Maybe FilePath -- Working directory (Nothing -> inherited) - -> Maybe Handle -- stdin (Nothing -> inherited) - -> Maybe Handle -- stdout (Nothing -> inherited) - -> Maybe Handle -- stderr (Nothing -> inherited) - -> IO () - - - - - -runProcess is our candidate for the high-level OS-independent -primitive. - - - -runProcess cmd args env wd inhdl outhdl errhdl runs cmd -(searching the current PATH) with arguments args. If -env is Just pairs, the command is executed with the -environment specified by pairs of variables and values; -otherwise, the command is executed with the current environment. If -wd is Just dir, the command is executed with working -directory dir; otherwise, the command is executed in the current -working directory. If {in,out,errhdl} is Just handle, the -command is executed with the Fd for std{in,out,err} -attached to the specified handle; otherwise, the Fd for -std{in,out,err} is left unchanged. - - - - - -getProcessStatus :: Bool -- Block? - -> Bool -- Stopped processes? - -> ProcessID - -> IO (Maybe ProcessStatus) - - - - - -getProcessStatus blk stopped pid calls waitpid, returning -Just tc, the ProcessStatus for process pid if it is -available, Nothing otherwise. If blk is False, then -WNOHANG is set in the options for waitpid, otherwise not. -If stopped is True, then WUNTRACED is set in the -options for waitpid, otherwise not. - - - - - -getGroupProcessStatus :: Bool -- Block? - -> Bool -- Stopped processes? - -> ProcessGroupID - -> IO (Maybe (ProcessID, ProcessStatus)) - - - - - -getGroupProcessStatus blk stopped pgid calls waitpid, -returning Just (pid, tc), the ProcessID and -ProcessStatus for any process in group pgid if one is -available, Nothing otherwise. If blk is False, then -WNOHANG is set in the options for waitpid, otherwise not. -If stopped is True, then WUNTRACED is set in the -options for waitpid, otherwise not. - - - - - -getAnyProcessStatus :: Bool -- Block? - -> Bool -- Stopped processes? - -> IO (Maybe (ProcessID, ProcessStatus)) - - - - - -getAnyProcessStatus blk stopped calls waitpid, returning -Just (pid, tc), the ProcessID and ProcessStatus for any -child process if one is available, Nothing otherwise. If -blk is False, then WNOHANG is set in the options for -waitpid, otherwise not. If stopped is True, then -WUNTRACED is set in the options for waitpid, otherwise not. - - - - - -exitImmediately :: ExitCode -> IO () - - - - - -exitImmediately status calls _exit to terminate the process -with the indicated exit status. -The operation never returns. - - - - - -getEnvironment :: IO [(String, String)] - - - - - -getEnvironment parses the environment variable mapping provided by -environ, returning (variable, value) pairs. -The operation never fails. - - - - - -setEnvironment :: [(String, String)] -> IO () - - - - - -setEnvironment replaces the process environment with the provided -mapping of (variable, value) pairs. - - - - - -getEnvVar :: String -> IO String - - - - - -getEnvVar var returns the value associated with variable var -in the current environment (identical functionality provided through -standard Haskell library function System.getEnv). - - - -The operation may fail with: - - - - - - -NoSuchThing - - -The variable has no mapping in the current environment. - - - - - - - - - -setEnvVar :: String -> String -> IO () - - - - - -setEnvVar var val sets the value associated with variable var -in the current environment to be val. Any previous mapping is -superseded. - - - - - -removeEnvVar :: String -> IO () - - - - - -removeEnvVar var removes any value associated with variable var -in the current environment. Deleting a variable for which there is no mapping -does not generate an error. - - - - - -nullSignal :: Signal -nullSignal = 0 - -backgroundRead, sigTTIN :: Signal -backgroundWrite, sigTTOU :: Signal -continueProcess, sigCONT :: Signal -floatingPointException, sigFPE :: Signal -illegalInstruction, sigILL :: Signal -internalAbort, sigABRT :: Signal -keyboardSignal, sigINT :: Signal -keyboardStop, sigTSTP :: Signal -keyboardTermination, sigQUIT :: Signal -killProcess, sigKILL :: Signal -lostConnection, sigHUP :: Signal -openEndedPipe, sigPIPE :: Signal -processStatusChanged, sigCHLD :: Signal -realTimeAlarm, sigALRM :: Signal -segmentationViolation, sigSEGV :: Signal -softwareStop, sigSTOP :: Signal -softwareTermination, sigTERM :: Signal -userDefinedSignal1, sigUSR1 :: Signal -userDefinedSignal2, sigUSR2 :: Signal - -signalProcess :: Signal -> ProcessID -> IO () - - - - - -signalProcess int pid calls kill to signal -process pid with interrupt signal int. - - - - - -raiseSignal :: Signal -> IO () - - - - - -raiseSignal int calls kill to signal the current process -with interrupt signal int. - - - - - -signalProcessGroup :: Signal -> ProcessGroupID -> IO () - - - - - -signalProcessGroup int pgid calls kill to signal -all processes in group pgid with interrupt signal int. - - - - - -setStoppedChildFlag :: Bool -> IO Bool - - - - - -setStoppedChildFlag bool sets a flag which controls whether or -not the NOCLDSTOP option will be used the next time a signal -handler is installed for SIGCHLD. If bool is True (the -default), NOCLDSTOP will not be used; otherwise it will be. The -operation never fails. - - - - - -queryStoppedChildFlag :: IO Bool - - - - - -queryStoppedChildFlag queries the flag which -controls whether or not the NOCLDSTOP option will be used -the next time a signal handler is installed for SIGCHLD. -If NOCLDSTOP will be used, it returns False; -otherwise (the default) it returns True. -The operation never fails. - - - - - -emptySignalSet :: SignalSet -fullSignalSet :: SignalSet -addSignal :: Signal -> SignalSet -> SignalSet -deleteSignal :: Signal -> SignalSet -> SignalSet -inSignalSet :: Signal -> SignalSet -> Bool - -installHandler :: Signal - -> Handler - -> Maybe SignalSet -- other signals to block - -> IO Handler -- old handler - - - - - -installHandler int handler iset calls sigaction to install an -interrupt handler for signal int. If handler is Default, -SIG_DFL is installed; if handler is Ignore, SIG_IGN is -installed; if handler is Catch action, a handler is installed -which will invoke action in a new thread when (or shortly after) the -signal is received. See for details on how to communicate between -threads. - - - -If iset is Just s, then the sa_mask of the sigaction structure -is set to s; otherwise it is cleared. The previously installed -signal handler for int is returned. - - - - - -getSignalMask :: IO SignalSet - - - - - -getSignalMask calls sigprocmask to determine the -set of interrupts which are currently being blocked. - - - - - -setSignalMask :: SignalSet -> IO SignalSet - - - - - -setSignalMask mask calls sigprocmask with -SIG_SETMASK to block all interrupts in mask. The -previous set of blocked interrupts is returned. - - - - - -blockSignals :: SignalSet -> IO SignalSet - - - - - -setSignalMask mask calls sigprocmask with -SIG_BLOCK to add all interrupts in mask to the -set of blocked interrupts. The previous set of blocked interrupts is returned. - - - - - -unBlockSignals :: SignalSet -> IO SignalSet - - - - - -setSignalMask mask calls sigprocmask with -SIG_UNBLOCK to remove all interrupts in mask from the -set of blocked interrupts. The previous set of blocked interrupts is returned. - - - - - -getPendingSignals :: IO SignalSet - - - - - -getPendingSignals calls sigpending to obtain -the set of interrupts which have been received but are currently blocked. - - - - - -awaitSignal :: Maybe SignalSet -> IO () - - - - - -awaitSignal iset suspends execution until an interrupt is received. -If iset is Just s, awaitSignal calls sigsuspend, installing -s as the new signal mask before suspending execution; otherwise, it -calls pause. awaitSignal returns on receipt of a signal. If you -have installed any signal handlers with installHandler, it may be -wise to call yield directly after awaitSignal to ensure that the -signal handler runs as promptly. - - - - - -scheduleAlarm :: Int -> IO Int - - - - - -scheduleAlarm i calls alarm to schedule a real time -alarm at least i seconds in the future. - - - - - -sleep :: Int -> IO () - - - - - -sleep i calls sleep to suspend execution of the -program until at least i seconds have elapsed or a signal is -received. - - - - - -Posix Process Environment - - - -Posix, process environment - - - - - -getProcessID :: IO ProcessID - - - - - -getProcessID calls getpid to obtain the ProcessID for -the current process. - - - - - -getParentProcessID :: IO ProcessID - - - - - -getProcessID calls getppid to obtain the ProcessID for -the parent of the current process. - - - - - -getRealUserID :: IO UserID - - - - - -getRealUserID calls getuid to obtain the real UserID -associated with the current process. - - - - - -getEffectiveUserID :: IO UserID - - - - - -getRealUserID calls geteuid to obtain the effective -UserID associated with the current process. - - - - - -setUserID :: UserID -> IO () - - - - - -setUserID uid calls setuid to set the real, effective, and -saved set-user-id associated with the current process to uid. - - - - - -getLoginName :: IO String - - - - - -getLoginName calls getlogin to obtain the login name -associated with the current process. - - - - - -getRealGroupID :: IO GroupID - - - - - -getRealGroupID calls getgid to obtain the real GroupID -associated with the current process. - - - - - -getEffectiveGroupID :: IO GroupID - - - - - -getEffectiveGroupID calls getegid to obtain the effective -GroupID associated with the current process. - - - - - -setGroupID :: GroupID -> IO () - - - - - -setGroupID gid calls setgid to set the real, effective, and -saved set-group-id associated with the current process to gid. - - - - - -getGroups :: IO [GroupID] - - - - - -getGroups calls getgroups to obtain the list of -supplementary GroupIDs associated with the current process. - - - - - -getEffectiveUserName :: IO String - - - - - -getEffectiveUserName calls cuserid to obtain a name -associated with the effective UserID of the process. - - - - - -getProcessGroupID :: IO ProcessGroupID - - - - - -getProcessGroupID calls getpgrp to obtain the -ProcessGroupID for the current process. - - - - - -createProcessGroup :: ProcessID -> IO ProcessGroupID - - - - - -createProcessGroup pid calls setpgid to make -process pid a new process group leader. - - - - - -joinProcessGroup :: ProcessGroupID -> IO ProcessGroupID - - - - - -joinProcessGroup pgid calls setpgid to set the -ProcessGroupID of the current process to pgid. - - - - - -setProcessGroupID :: ProcessID -> ProcessGroupID -> IO () - - - - - -setProcessGroupID pid pgid calls setpgid to set the -ProcessGroupID for process pid to pgid. - - - - - -createSession :: IO ProcessGroupID - - - - - -createSession calls setsid to create a new session -with the current process as session leader. - - - - - -systemName :: SystemID -> String -nodeName :: SystemID -> String -release :: SystemID -> String -version :: SystemID -> String -machine :: SystemID -> String - -getSystemID :: IO SystemID - - - - - -getSystemID calls uname to obtain information -about the current operating system. - - - - - -> epochTime :: IO EpochTime - - - - - -epochTime calls time to obtain the number of -seconds that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970). - - - - - -elapsedTime :: ProcessTimes -> ClockTick -userTime :: ProcessTimes -> ClockTick -systemTime :: ProcessTimes -> ClockTick -childUserTime :: ProcessTimes -> ClockTick -childSystemTime :: ProcessTimes -> ClockTick - -getProcessTimes :: IO ProcessTimes - - - - - -getProcessTimes calls times to obtain time-accounting -information for the current process and its children. - - - - - -getControllingTerminalName :: IO FilePath - - - - - -getControllingTerminalName calls ctermid to obtain -a name associated with the controlling terminal for the process. If a -controlling terminal exists, -getControllingTerminalName returns the name of the -controlling terminal. - - - -The operation may fail with: - - - - - - -NoSuchThing - - -There is no controlling terminal, or its name cannot be determined. - - - - -SystemError - - -Various other causes. - - - - - - - - - -getTerminalName :: Fd -> IO FilePath - - - - - -getTerminalName fd calls ttyname to obtain a name associated -with the terminal for Fd fd. If fd is associated -with a terminal, getTerminalName returns the name of the -terminal. - - - -The operation may fail with: - - - - - - -InappropriateType - - -The channel is not associated with a terminal. - - - - -NoSuchThing - - -The channel is associated with a terminal, but it has no name. - - - - -SystemError - - -Various other causes. - - - - - - - - - -queryTerminal :: Fd -> IO Bool - - - - - -queryTerminal fd calls isatty to determine whether or -not Fd fd is associated with a terminal. - - - - - -getSysVar :: SysVar -> IO Limit - - - - - -getSysVar var calls sysconf to obtain the -dynamic value of the requested configurable system limit or option. -For defined system limits, getSysVar returns the associated -value. For defined system options, the result of getSysVar -is undefined, but not failure. - - - -The operation may fail with: - - - - - - -NoSuchThing - - -The requested system limit or option is undefined. - - - - - - - - - -Posix operations on files and directories - - - -Posix, files and directories - - - - - -openDirStream :: FilePath -> IO DirStream - - - - - -openDirStream dir calls opendir to obtain a -directory stream for dir. - - - - - -readDirStream :: DirStream -> IO String - - - - - -readDirStream dp calls readdir to obtain the -next directory entry (struct dirent) for the open directory -stream dp, and returns the d_name member of that -structure. - - - -The operation may fail with: - - - - - - -EOF - - -End of file has been reached. - - - - -SystemError - - -Various other causes. - - - - - - - - - -rewindDirStream :: DirStream -> IO () - - - - - -rewindDirStream dp calls rewinddir to reposition -the directory stream dp at the beginning of the directory. - - - - - -closeDirStream :: DirStream -> IO () - - - - - -closeDirStream dp calls closedir to close -the directory stream dp. - - - - - -getWorkingDirectory :: IO FilePath - - - - - -getWorkingDirectory calls getcwd to obtain the name -of the current working directory. - - - - - -changeWorkingDirectory :: FilePath -> IO () - - - - - -changeWorkingDirectory dir calls chdir to change -the current working directory to dir. - - - - -nullFileMode :: FileMode -- --------- -ownerReadMode :: FileMode -- r-------- -ownerWriteMode :: FileMode -- -w------- -ownerExecuteMode :: FileMode -- --x------ -groupReadMode :: FileMode -- ---r----- -groupWriteMode :: FileMode -- ----w---- -groupExecuteMode :: FileMode -- -----x--- -otherReadMode :: FileMode -- ------r-- -otherWriteMode :: FileMode -- -------w- -otherExecuteMode :: FileMode -- --------x -setUserIDMode :: FileMode -- --S------ -setGroupIDMode :: FileMode -- -----S--- - -stdFileMode :: FileMode -- rw-rw-rw- - -ownerModes :: FileMode -- rwx------ -groupModes :: FileMode -- ---rwx--- -otherModes :: FileMode -- ------rwx -accessModes :: FileMode -- rwxrwxrwx - -unionFileModes :: FileMode -> FileMode -> FileMode -intersectFileModes :: FileMode -> FileMode -> FileMode - -stdInput :: Fd -stdInput = intToFd 0 - -stdOutput :: Fd -stdOutput = intToFd 1 - -stdError :: Fd -stdError = intToFd 2 - -data OpenFileFlags = - OpenFileFlags { - append :: Bool, - exclusive :: Bool, - noctty :: Bool, - nonBlock :: Bool, - trunc :: Bool - } - -openFd :: FilePath - -> OpenMode - -> Maybe FileMode -- Just x => O_CREAT, Nothing => must exist - -> OpenFileFlags - -> IO Fd - - - - -openFd path acc mode (OpenFileFlags app excl noctty nonblock trunc) calls -open to obtain a Fd for the file path with access -mode acc. If mode is Just m, the O_CREAT flag is -set and the file's permissions will be based on m if it does not -already exist; otherwise, the O_CREAT flag is not set. The -arguments app, excl, noctty, nonblock, and -trunc control whether or not the flags O_APPEND, -O_EXCL, O_NOCTTY, O_NONBLOCK, and O_TRUNC are set, -respectively. - - - - - -createFile :: FilePath -> FileMode -> IO Fd - - - - - -createFile path mode calls creat to obtain a Fd -for file path, which will be created with permissions based on -mode if it does not already exist. - - - - - -setFileCreationMask :: FileMode -> IO FileMode - - - - - -setFileCreationMask mode calls umask to set -the process's file creation mask to mode. The previous file -creation mask is returned. - - - - - -createLink :: FilePath -> FilePath -> IO () - - - - - -createLink old new calls link to create a -new path, new, linked to an existing file, old. - - -createDirectory :: FilePath -> FileMode -> IO () - - - - - -createDirectory dir mode calls mkdir to -create a new directory, dir, with permissions based on -mode. - - - - - -createNamedPipe :: FilePath -> FileMode -> IO () - - - - - -createNamedPipe fifo mode calls mkfifo to -create a new named pipe, fifo, with permissions based on -mode. - - - - - -removeLink :: FilePath -> IO () - - - - - -removeLink path calls unlink to remove the link -named path. - - - - - -removeDirectory :: FilePath -> IO () - - - - - -removeDirectory dir calls rmdir to remove the -directory named dir. - - - - - -rename :: FilePath -> FilePath -> IO () - - - - - -rename old new calls rename to rename a -file or directory from old to new. - - - - - -fileMode :: FileStatus -> FileMode - -fileID :: FileStatus -> FileID -deviceID :: FileStatus -> DeviceID - -linkCount :: FileStatus -> LinkCount - -fileOwner :: FileStatus -> UserID -fileGroup :: FileStatus -> GroupID -fileSize :: FileStatus -> FileOffset - -accessTime :: FileStatus -> EpochTime -modificationTime :: FileStatus -> EpochTime -statusChangeTime :: FileStatus -> EpochTime - -isDirectory :: FileStatus -> Bool -isCharacterDevice :: FileStatus -> Bool -isBlockDevice :: FileStatus -> Bool -isRegularFile :: FileStatus -> Bool -isNamedPipe :: FileStatus -> Bool - -getFileStatus :: FilePath -> IO FileStatus - - - - - -getFileStatus path calls stat to get the -FileStatus information for the file path. - - - - - -getFdStatus :: Fd -> IO FileStatus - - - - - -getFdStatus fd calls fstat to get the -FileStatus information for the file associated with -Fd fd. - - - - - -queryAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool - - - - - -queryAccess path r w x calls access to test the access -permissions for file path. The three arguments, r, w, -and x control whether or not access is called with -R_OK, W_OK, and X_OK respectively. - - - - - -queryFile :: FilePath -> IO Bool - - - - - -queryFile path calls access with F_OK to test for the -existence for file path. - - - - - -setFileMode :: FilePath -> FileMode -> IO () - - - - - -setFileMode path mode calls chmod to set the -permission bits associated with file path to mode. - - - - - -setOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO () - - - - - -setOwnerAndGroup path uid gid calls chown to -set the UserID and GroupID associated with file -path to uid and gid, respectively. - - - - - -setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO () - - - - - -setFileTimes path atime mtime calls utime to -set the access and modification times associated with file -path to atime and mtime, respectively. - - - - - -touchFile :: FilePath -> IO () - - - - - -touchFile path calls utime to -set the access and modification times associated with file -path to the current time. - - - - - -getPathVar :: PathVar -> FilePath -> IO Limit - - - - - -getPathVar var path calls pathconf to obtain the -dynamic value of the requested configurable file limit or option associated -with file or directory path. For -defined file limits, getPathVar returns the associated -value. For defined file options, the result of getPathVar -is undefined, but not failure. -The operation may fail with: - - - -NoSuchThing - - -The requested file limit or option is undefined. - - - - -SystemError - - -Various other causes. - - - - - - - - - -getFdVar :: PathVar -> Fd -> IO Limit - - - - - -getFdVar var fd calls fpathconf to obtain the -dynamic value of the requested configurable file limit or option associated -with the file or directory attached to the open channel fd. -For defined file limits, getFdVar returns the associated -value. For defined file options, the result of getFdVar -is undefined, but not failure. - - - -The operation may fail with: - - - - - - -NoSuchThing - - -The requested file limit or option is undefined. - - - - -SystemError - - -Various other causes. - - - - - - - - - -Posix Input and Output Primitives - - - -Posix, input/output - - - - - -createPipe :: IO (Fd, Fd) - - - - - -createPipe calls pipe to create a pipe and returns a pair of -Fds, the first for reading and the second for writing. - - - - - -dup :: Fd -> IO Fd - - - - - -dup fd calls dup to duplicate Fd fd to -another Fd. - - - - - -dupTo :: Fd -> Fd -> IO () - - - - - -dupTo src dst calls dup2 to duplicate Fd -src to Fd dst. - - - - - -fdClose :: Fd -> IO () - - - - - -fdClose fd calls close to close Fd fd. - - - - - -fdRead :: Fd -> ByteCount -> IO (String, ByteCount) - - - - - -fdRead fd nbytes calls read to read at most nbytes -bytes from Fd fd, and returns the result as a string -paired with the number of bytes actually read. - - - -The operation may fail with: - - - - - - -EOF - - -End of file has been reached. - - - - -SystemError - - -Various other causes. - - - - - - - - - -fdWrite :: Fd -> String -> IO ByteCount - - - - - -fdWrite fd s calls write to write -the string s to Fd fd as a -contiguous sequence of bytes. It returns the number of bytes successfully -written. - - - - - -queryFdOption :: FdOption -> Fd -> IO Bool - - - - - -getFdOption opt fd calls fcntl to determine whether or -not the flag associated with FdOption opt is set for -Fd fd. - - - - - -setFdOption :: Fd -> FdOption -> Bool -> IO () - - - - - -setFdOption fd opt val calls fcntl to set the flag -associated with FdOption opt on Fd fd to -val. - - - - - -getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock)) - - - - - -getLock fd lock calls fcntl to get the first FileLock -for Fd fd which blocks the FileLock lock. If -no such FileLock exists, getLock returns Nothing. -Otherwise, it returns Just (pid, block), where block is the -blocking FileLock and pid is the ProcessID of the -process holding the blocking FileLock. - - - - - -setLock :: Fd -> FileLock -> IO () - - - - - -setLock fd lock calls fcntl with F_SETLK to set or -clear a lock segment for Fd fd as indicated by the -FileLock lock. setLock does not block, but fails with -SystemError if the request cannot be satisfied immediately. - - - - - -waitToSetLock :: Fd -> FileLock -> IO () - - - - - -waitToSetLock fd lock calls fcntl with F_SETLKW to set -or clear a lock segment for Fd fd as indicated by the -FileLock lock. If the request cannot be satisfied -immediately, waitToSetLock blocks until the request can be -satisfied. - - - - - -fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset - - - - - -fdSeek fd whence offset calls lseek to position the -Fd fd at the given offset from the starting location -indicated by whence. It returns the resulting offset from the -start of the file in bytes. - - - - - -Posix, Device- and Class-Specific Functions - - - -Posix, device and class-specific functions - - - - - -terminalMode :: TerminalMode -> TerminalAttributes -> Bool -withMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes -withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes - -bitsPerByte :: TerminalAttributes -> Int -withBits :: TerminalAttributes -> Int -> TerminalAttributes - -controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char -withCC :: TerminalAttributes - -> (ControlCharacter, Char) - -> TerminalAttributes -withoutCC :: TerminalAttributes - -> ControlCharacter - -> TerminalAttributes - -inputTime :: TerminalAttributes -> Int -withTime :: TerminalAttributes -> Int -> TerminalAttributes - -minInput :: TerminalAttributes -> Int -withMinInput :: TerminalAttributes -> Int -> TerminalAttributes - -inputSpeed :: TerminalAttributes -> BaudRate -withInputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes - -outputSpeed :: TerminalAttributes -> BaudRate -withOutputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes - -getTerminalAttributes :: Fd -> IO TerminalAttributes - - - - - -getTerminalAttributes fd calls tcgetattr to obtain -the TerminalAttributes associated with Fd fd. - - - - - -setTerminalAttributes :: Fd - -> TerminalAttributes - -> TerminalState - -> IO () - - - - - -setTerminalAttributes fd attr ts calls tcsetattr to change -the TerminalAttributes associated with Fd fd to -attr, when the terminal is in the state indicated by ts. - - - - - -sendBreak :: Fd -> Int -> IO () - - - - - -sendBreak fd duration calls tcsendbreak to transmit a -continuous stream of zero-valued bits on Fd fd for the -specified implementation-dependent duration. - - - - - -drainOutput :: Fd -> IO () - - - - - -drainOutput fd calls tcdrain to block until all output -written to Fd fd has been transmitted. - - - - - -discardData :: Fd -> QueueSelector -> IO () - - - - - -discardData fd queues calls tcflush to discard -pending input and/or output for Fd fd, -as indicated by the QueueSelector queues. - - - - - -controlFlow :: Fd -> FlowAction -> IO () - - - - - -controlFlow fd action calls tcflow to control the -flow of data on Fd fd, as indicated by -action. - - - - - -getTerminalProcessGroupID :: Fd -> IO ProcessGroupID - - - - - -getTerminalProcessGroupID fd calls tcgetpgrp to -obtain the ProcessGroupID of the foreground process group -associated with the terminal attached to Fd fd. - - - - - -setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO () - - - - - -setTerminalProcessGroupID fd pgid calls tcsetpgrp to -set the ProcessGroupID of the foreground process group -associated with the terminal attached to Fd -fd to pgid. - - - - - -Posix System Databases - - - -Posix, system databases - - - - - -groupName :: GroupEntry -> String -groupID :: GroupEntry -> GroupID -groupMembers :: GroupEntry -> [String] - -getGroupEntryForID :: GroupID -> IO GroupEntry - - - - - -getGroupEntryForID gid calls getgrgid to obtain -the GroupEntry information associated with GroupID -gid. - - - -The operation may fail with: - - - - - - -NoSuchThing - - -There is no group entry for the GroupID. - - - - - - - - - -getGroupEntryForName :: String -> IO GroupEntry - - - - - -getGroupEntryForName name calls getgrnam to obtain -the GroupEntry information associated with the group called -name. - - - -The operation may fail with: - - - - - - -NoSuchThing - - -There is no group entry for the name. - - - - - - - - - -userName :: UserEntry -> String -userID :: UserEntry -> UserID -userGroupID :: UserEntry -> GroupID -homeDirectory :: UserEntry -> String -userShell :: UserEntry -> String - -getUserEntryForID :: UserID -> IO UserEntry - - - - - -getUserEntryForID gid calls getpwuid to obtain -the UserEntry information associated with UserID -uid. -The operation may fail with: - - - - - - -NoSuchThing - - -There is no user entry for the UserID. - - - - - - - - - -getUserEntryForName :: String -> IO UserEntry - - - - - -getUserEntryForName name calls getpwnam to obtain -the UserEntry information associated with the user login -name. - - - -The operation may fail with: - - - - - - -NoSuchThing - - -There is no user entry for the name. - - - - - - - - - -POSIX Errors - - - -Posix, errors - - - - - -getErrorCode :: IO ErrorCode - - - - - -getErrorCode returns the current value of the external -variable errno. It never fails. - - - - - -setErrorCode :: ErrorCode -> IO () - - - - - -setErrorCode err sets the external -variable errno to err. It never fails. - - - - - -noError :: ErrorCode -noError = 0 - -argumentListTooLong, e2BIG :: ErrorCode -badFd, eBADF :: ErrorCode -brokenPipe, ePIPE :: ErrorCode -directoryNotEmpty, eNOTEMPTY :: ErrorCode -execFormatError, eNOEXEC :: ErrorCode -fileAlreadyExists, eEXIST :: ErrorCode -fileTooLarge, eFBIG :: ErrorCode -filenameTooLong, eNAMETOOLONG :: ErrorCode -improperLink, eXDEV :: ErrorCode -inappropriateIOControlOperation, eNOTTY :: ErrorCode -inputOutputError, eIO :: ErrorCode -interruptedOperation, eINTR :: ErrorCode -invalidArgument, eINVAL :: ErrorCode -invalidSeek, eSPIPE :: ErrorCode -isADirectory, eISDIR :: ErrorCode -noChildProcess, eCHILD :: ErrorCode -noLocksAvailable, eNOLCK :: ErrorCode -noSpaceLeftOnDevice, eNOSPC :: ErrorCode -noSuchOperationOnDevice, eNODEV :: ErrorCode -noSuchDeviceOrAddress, eNXIO :: ErrorCode -noSuchFileOrDirectory, eNOENT :: ErrorCode -noSuchProcess, eSRCH :: ErrorCode -notADirectory, eNOTDIR :: ErrorCode -notEnoughMemory, eNOMEM :: ErrorCode -operationNotImplemented, eNOSYS :: ErrorCode -operationNotPermitted, ePERM :: ErrorCode -permissionDenied, eACCES :: ErrorCode -readOnlyFileSystem, eROFS :: ErrorCode -resourceBusy, eBUSY :: ErrorCode -resourceDeadlockAvoided, eDEADLK :: ErrorCode -resourceTemporarilyUnavailable, eAGAIN :: ErrorCode -tooManyLinks, eMLINK :: ErrorCode -tooManyOpenFiles, eMFILE :: ErrorCode -tooManyOpenFilesInSystem, eNFILE :: ErrorCode - - - - - - - diff --git a/ghc/docs/users_guide/users_guide.sgml b/ghc/docs/users_guide/users_guide.sgml index 119034a..ce559d4 100644 --- a/ghc/docs/users_guide/users_guide.sgml +++ b/ghc/docs/users_guide/users_guide.sgml @@ -11,13 +11,9 @@ - - - + - - ]> @@ -36,8 +32,8 @@ &prof &sooner &lang -&libs &wrong +&libraries &utils &win32-dll