[project @ 1996-01-08 20:28:12 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         minChar#, maxChar#,
36         toChar#, fromChar#,
37         isAscii#, isControl#, isPrint#, isSpace#, 
38         isUpper#, isLower#, isAlpha#, isDigit#, isAlphanum#,
39         toUpper#, toLower#,
40 #endif
41
42         head, last, tail, init, null, (++), (\\), genericLength,
43         length, (!!), map, filter, partition, {-BUILTIN: foldl,-}
44         foldl1, scanl, scanl1, {-BUILTIN: foldr,-} foldr1, scanr, scanr1,
45         iterate, repeat, cycle, take, drop, splitAt, takeWhile,
46         dropWhile, span, break, lines, words, unlines, unwords, nub,
47         reverse,  and, or, any, all, elem, notElem, sum,
48         product, sums, products, maximum, minimum, concat,
49         transpose, zip, zip3, zip4, zip5, zip6, zip7, zipWith,
50         zipWith3, zipWith4, zipWith5, zipWith6, zipWith7, unzip,
51         unzip3, unzip4, unzip5, unzip6, unzip7,
52
53         array, listArray, (!), bounds, indices, elems, assocs,
54         accumArray, (//), accum, amap, ixmap,
55
56         reads, shows, show, read, lex, showChar, showString,
57         readParen, showParen, readLitChar, showLitChar, readSigned,
58         showSigned, showSpace__, readDec, showInt, readFloat, showFloat,
59         _showHex, _showRadix, _showDigit, -- non-std
60         _readList, _showList, _truncate, _round, _ceiling, _floor,
61
62         _readRational, _showRational, -- extras!
63
64         -- 1.3 I/O stuff from PreludeIO, some *renamed*
65         (>>),
66         (>>=),
67         accumulate,
68         appendFile,
69         either,
70         fail,
71         failWith,
72         getChar,
73         hClose,
74         hFileSize,
75         hFlush,
76         hGetChar,
77         hGetContents,
78         hGetPosn,
79         hIsBlockBuffered,
80         hIsClosed,
81         hIsEOF,
82         hIsLineBuffered,
83         hIsNotBuffered,
84         hIsOpen,
85         hIsReadable,
86         hIsSeekable,
87         hIsWritable,
88         hLookAhead,
89         hPutChar,
90         hPutStr,
91         hPutText,
92         hReady,
93         hSeek,
94         hSetBuffering,
95         hSetPosn,
96         handle,
97         interact,
98         isEOF,
99         openFile,
100         putChar,
101         putStr,
102         putText,
103         print,
104         readFile,
105         return,
106         sequence,
107         stderr,
108         stdin,
109         stdout,
110         try,
111         writeFile,
112
113         primIOToIO, ioToPrimIO, -- extra, and very dodgy
114
115         -- and for foldr/build
116         _build
117
118     ) where
119
120 -- few *Ty(s) imports
121 import TyArray          ( Array(..), Assoc(..), _ByteArray )
122 import TyComplex        ( Complex(..) )
123 --import Builtin        ( trace )
124 import Cls      hiding  ( String )
125 import Core
126 import PreludeGlaST     ( thenStrictlyST, _MutableByteArray, _MutableArray )
127 import PreludePrimIO    ( thenPrimIO, returnPrimIO )
128 --import PrelCore13
129 import IArray
130 import IBool
131 import IChar
132 import IComplex
133 import IDouble
134 import IFloat
135 import IInt
136 import IInteger
137 import IList
138 import IRatio
139 import ITup0
140 import ITup2
141 import ITup3
142 import ITup4
143 import ITup5
144 import List
145 import Prel
146 import Text
147 import PS
148
149 import PreludeIO renaming ( -- IOError13    to IOError -- can't rename PreludeCore types
150                             appendFile13    to appendFile
151                           , interact13      to interact
152                           , print13         to print
153                           , readFile13      to readFile
154                           , stderr13        to stderr
155                           , stdin13         to stdin
156                           , stdout13        to stdout
157                           , writeFile13     to writeFile
158                           )
159
160 primIOToIO :: PrimIO a -> IO a
161 primIOToIO m = m `thenPrimIO` \ a -> return a
162
163 ioToPrimIO :: IO a -> PrimIO a
164 ioToPrimIO io
165   = io          `thenPrimIO` \ r ->
166     case r of
167       Right a -> returnPrimIO a
168       Left  e -> error ("I/O Error (ioToPrimIO): " ++ shows e "\n")
169
170
171 -- 1.3 extra functions
172
173 thenMaybe :: Maybe a -> (a -> Maybe b) -> Maybe b
174 thenMaybe Nothing _ = Nothing
175 thenMaybe (Just x) f = f x
176
177 curry   :: ((a,b) -> c) -> a -> b -> c
178 curry f x y = f (x,y)
179
180 uncurry :: (a -> b -> c) -> (a,b) -> c
181 uncurry f (x,y) = f x y
182
183 {- LATER?:
184 copy     :: Int -> a -> [a]
185 copy  n x = take n (repeat x)
186
187 lookup :: Eq a => [(a,b)] -> a -> Maybe b
188 lookup [] _ = Nothing
189 lookup ((key,val) : rest) x | key == x = Just val
190                             | otherwise = lookup rest x
191 -}