[project @ 1996-01-22 18:37:39 by partain]
[ghc-hetmet.git] / ghc / lib / prelude / Prel13.hs
1 -- compiled to produce a 1.3 (whatever that is) Prelude.hi file
2 --
3 module Prelude (
4
5         -- 1.3 extras (I/O is later)
6         thenMaybe, 
7         curry, uncurry,
8 -- LATER?
9 --      copy, lookup,
10
11         -- NO: really builtin (0.20+): trace,
12
13         (%), numerator, denominator, approxRational,
14
15         realPart, imagPart, conjugate, mkPolar, cis,
16         polar, magnitude, phase,
17
18         _appendPS, _breakPS, _concatPS, _dropPS, _dropWhilePS,
19         _filterPS, _foldlPS, _foldrPS, _headPS, _indexPS, _lengthPS,
20         _linesPS, _mapPS, _nilPS, _consPS, _nullPS, _packCBytes,
21         _packCString, _packString, _byteArrayToPS, _psToByteArray,
22         _reversePS, _spanPS, _splitAtPS, _substrPS, _tailPS, _takePS,
23         _takeWhilePS, _unpackPS, _wordsPS, _putPS,
24
25         (&&), (||), not, otherwise,
26         (^), (^^), appendBin, asTypeOf, atan2, fromIntegral,
27         fromRealFrac, gcd, isAlpha, isAlphanum, isAscii, isControl,
28         isDigit, isLower, isNullBin, isPrint, isSpace, isUpper, lcm,
29         maxChar, maxInt, minChar, minInt, nullBin, subtract, toLower,
30         toUpper, until, fst, snd, id, const, (.), flip, ($),
31         ord, chr,
32
33 #if defined(__UNBOXED_INSTANCES__)
34         minInt#, maxInt#,
35         toInt#, fromInt#,
36         minChar#, maxChar#,
37         toChar#, fromChar#,
38         isAscii#, isControl#, isPrint#, isSpace#, 
39         isUpper#, isLower#, isAlpha#, isDigit#, isAlphanum#,
40         toUpper#, toLower#,
41 #endif
42
43         head, last, tail, init, null, (++), (\\), genericLength,
44         length, (!!), map, filter, partition, {-BUILTIN: foldl,-}
45         foldl1, scanl, scanl1, {-BUILTIN: foldr,-} foldr1, scanr, scanr1,
46         iterate, repeat, cycle, take, drop, splitAt, takeWhile,
47         dropWhile, span, break, lines, words, unlines, unwords, nub,
48         reverse,  and, or, any, all, elem, notElem, sum,
49         product, sums, products, maximum, minimum, concat,
50         transpose, zip, zip3, zip4, zip5, zip6, zip7, zipWith,
51         zipWith3, zipWith4, zipWith5, zipWith6, zipWith7, unzip,
52         unzip3, unzip4, unzip5, unzip6, unzip7,
53
54         array, listArray, (!), bounds, indices, elems, assocs,
55         accumArray, (//), accum, amap, ixmap,
56
57         reads, shows, show, read, lex, showChar, showString,
58         readParen, showParen, readLitChar, showLitChar, readSigned,
59         showSigned, showSpace__, readDec, showInt, readFloat, showFloat,
60         _showHex, _showRadix, _showDigit, -- non-std
61         _readList, _showList,
62
63         _readRational, _showRational, -- extras!
64
65         -- 1.3 I/O stuff from PreludeIO, some *renamed*
66         (>>),
67         (>>=),
68         accumulate,
69         appendFile,
70         either,
71         fail,
72         failWith,
73         getChar,
74         hClose,
75         hFileSize,
76         hFlush,
77         hGetChar,
78         hGetContents,
79         hGetPosn,
80         hIsBlockBuffered,
81         hIsClosed,
82         hIsEOF,
83         hIsLineBuffered,
84         hIsNotBuffered,
85         hIsOpen,
86         hIsReadable,
87         hIsSeekable,
88         hIsWritable,
89         hLookAhead,
90         hPutChar,
91         hPutStr,
92         hPutText,
93         hReady,
94         hSeek,
95         hSetBuffering,
96         hSetPosn,
97         handle,
98         interact,
99         isEOF,
100         openFile,
101         putChar,
102         putStr,
103         putText,
104         print,
105         readFile,
106         return,
107         sequence,
108         stderr,
109         stdin,
110         stdout,
111         try,
112         writeFile,
113
114         primIOToIO, ioToPrimIO, -- extra, and very dodgy
115
116         -- and for foldr/build
117         _build, _augment, 
118
119         _newArray, _freezeArray, _arrEleBottom,
120         _rangeComplaint_Ix_Int
121     ) where
122
123 -- few *Ty(s) imports
124 import TyArray          ( Array(..), Assoc(..), _ByteArray )
125 import TyComplex        ( Complex(..) )
126 --import Builtin        ( trace )
127 import Cls      hiding  ( String )
128 import Core
129 import PreludeGlaST     ( thenStrictlyST, _MutableByteArray, _MutableArray )
130 import PreludePrimIO    ( thenPrimIO, returnPrimIO )
131 --import PrelCore13
132 import IArray
133 import IBool
134 import IChar
135 import IComplex
136 import IDouble
137 import IFloat
138 import IInt
139 import IInteger
140 import IList
141 import IRatio
142 import ITup0
143 import ITup2
144 import ITup3
145 import ITup4
146 import ITup5
147 import List
148 import Prel
149 import Text
150 import PS
151
152 import PreludeIO renaming ( -- IOError13    to IOError -- can't rename PreludeCore types
153                             appendFile13    to appendFile
154                           , interact13      to interact
155                           , print13         to print
156                           , readFile13      to readFile
157                           , stderr13        to stderr
158                           , stdin13         to stdin
159                           , stdout13        to stdout
160                           , writeFile13     to writeFile
161                           )
162
163 primIOToIO :: PrimIO a -> IO a
164 primIOToIO m = m `thenPrimIO` \ a -> return a
165
166 ioToPrimIO :: IO a -> PrimIO a
167 ioToPrimIO io
168   = io          `thenPrimIO` \ r ->
169     case r of
170       Right a -> returnPrimIO a
171       Left  e -> error ("I/O Error (ioToPrimIO): " ++ showsPrec 0 e "\n")
172
173
174 -- 1.3 extra functions
175
176 thenMaybe :: Maybe a -> (a -> Maybe b) -> Maybe b
177 thenMaybe Nothing _ = Nothing
178 thenMaybe (Just x) f = f x
179
180 curry   :: ((a,b) -> c) -> a -> b -> c
181 curry f x y = f (x,y)
182
183 uncurry :: (a -> b -> c) -> (a,b) -> c
184 uncurry f (x,y) = f x y
185
186 {- LATER?:
187 copy     :: Int -> a -> [a]
188 copy  n x = take n (repeat x)
189
190 lookup :: Eq a => [(a,b)] -> a -> Maybe b
191 lookup [] _ = Nothing
192 lookup ((key,val) : rest) x | key == x = Just val
193                             | otherwise = lookup rest x
194 -}