Ticket #2533: generic-negative-index

File generic-negative-index, 18.8 KB (added by japple, 9 years ago)
1Thu Aug 21 19:27:55 PDT 2008 
2  * Generic functions that take integral arguments should work the same way as their prelude counterparts
4  The Prelude functions drop, take, and splitAt are unfailing (never call error). This patch changes the Data.List generic versions to behave the same way. At present, they call error on negative arguments.
7New patches:
9[Generic functions that take integral arguments should work the same way as their prelude counterparts
12 The Prelude functions drop, take, and splitAt are unfailing (never call error). This patch changes the Data.List generic versions to behave the same way. At present, they call error on negative arguments.
14] {
15hunk ./Data/List.hs 574
16-genericTake 0 _         =  []
17+genericTake n _ | n <= 0 = []
18hunk ./Data/List.hs 576
19-genericTake n (x:xs) | n > 0  =  x : genericTake (n-1) xs
20-genericTake _  _        =  error "List.genericTake: negative argument"
21+genericTake n (x:xs)    =  x : genericTake (n-1) xs
22hunk ./Data/List.hs 581
23-genericDrop 0 xs        =  xs
24+genericDrop n xs | n <= 0 = xs
25hunk ./Data/List.hs 583
26-genericDrop n (_:xs) | n > 0  =  genericDrop (n-1) xs
27-genericDrop _ _         =  error "List.genericDrop: negative argument"
28+genericDrop n (_:xs)    =  genericDrop (n-1) xs
30hunk ./Data/List.hs 589
31-genericSplitAt 0 xs     =  ([],xs)
32+genericSplitAt n xs | n <= 0 =  ([],xs)
33hunk ./Data/List.hs 591
34-genericSplitAt n (x:xs) | n > 0  =  (x:xs',xs'') where
35-                               (xs',xs'') = genericSplitAt (n-1) xs
36-genericSplitAt _ _      =  error "List.genericSplitAt: negative argument"
37+genericSplitAt n (x:xs) =  (x:xs',xs'') where
38+    (xs',xs'') = genericSplitAt (n-1) xs
43[remove some functions that aren't used in base
44Simon Marlow <marlowsd@gmail.com>**20080821142339]
45[remove __hscore_renameFile, it is no longer uesd
46Simon Marlow <marlowsd@gmail.com>**20080818155950
47 System.Directory implements renameFile using unix/Win32 now.
49[Rewrite the documentation for forkOS again
50Simon Marlow <marlowsd@gmail.com>**20080818132856
51 Try to make it clearer that forkOS is only necessary when calling
52 foreing libraries that use thread-local state, and it has nothing to
53 do with scheduling behaviour between Haskell threads.  I also added
54 something about the performance impact of forkOS, and mentioned that
55 the main thread is a bound thread.
57[nhc only: expose Foldable and Traversable instances of Array
58Ross Paterson <ross@soi.city.ac.uk>**20080817002719
60 These were turned off as a side-effect of a previous nhc-only fix for
61 #2176 that is no longer needed.  They should be fine for nhc now.
63[Fix hReady (trac #1063)
64Ian Lynagh <igloo@earth.li>**20080816182715
65 We now throw an EOF exception when appropriate
67[Fix oversight in Control.OldException
68Bertram Felgenhauer <int-e@gmx.de>**20080816132631
69 The NonTermination constructor slipped through in the Exception instance.
71[Eliminate orphan rules and instances in the array package
72Ian Lynagh <igloo@earth.li>**20080816122253]
73[Control.OldException: Map exceptions to old exceptions and back properly.
74Ian Lynagh <igloo@earth.li>**20080814210219
75   * Control.OldException: Map exceptions to old exceptions and back properly.
77 It's really necessary to map them back as well, or the RTS and base library
78 will not recognize exceptions that got caught and rethrown. (See #2508)
80 Patch from Bertram Felgenhauer <int-e@gmx.de>
82[add Traversable generalizations of mapAccumL and mapAccumR (#2461)
83Ross Paterson <ross@soi.city.ac.uk>**20080814162617]
84[simplify definition of Prelude.catch
85Ross Paterson <ross@soi.city.ac.uk>**20080814143650]
86[remove returns from void functions
87Ross Paterson <ross@soi.city.ac.uk>**20080814110841]
88[No reason for Handler and catches to exclude nhc98.
90[Must import ExitCode for its instance to be re-exported.
92 The Cabal library depends on "instance Exception ExitCode", and expects
93 to import it from Control.Exception, not Control.Exception.Base.
95[use New.catch instead of catchException in OldException
96Ross Paterson <ross@soi.city.ac.uk>**20080813071307]
97[use the Haskell 98 module Control.Exception.Base in the Concurrent modules
98Ross Paterson <ross@soi.city.ac.uk>**20080813000219]
99[export Control.Exception.Base
100Ross Paterson <ross@soi.city.ac.uk>**20080812233640]
101[use dummy implementation of timeout for all non-GHCs
102Ross Paterson <ross@soi.city.ac.uk>**20080812151602]
103[Hugs only: fix imports
104Ross Paterson <ross@soi.city.ac.uk>**20080812145654]
105[non-GHC: hide Prelude.catch
106Ross Paterson <ross@soi.city.ac.uk>**20080812145622]
107[add Control.Exception.Base to nhc98 build
109[bump to version 4.0
110Simon Marlow <marlowsd@gmail.com>**20080805153354]
111[Hugs only: don't import exception types -- their instances are now in Control.Exception.Base
112Ross Paterson <ross@soi.city.ac.uk>**20080812140433]
113[split most of Control.Exception into new Control.Exception.Base
114Ross Paterson <ross@soi.city.ac.uk>**20080812124912
116 Move everything but catches/Handler into a new internal module.
117 This was needed to get the new exceptions working with Hugs, because Hugs
118 has the constraint that all Haskell 98 library modules, and everything
119 they include, must be Haskell 98.  This also involves a different
120 representation of SomeException for Hugs, so that type is exported
121 opaquely for Hugs.  Then Control.Exception.Base is Haskell 98 as far as
122 Hugs is concerned, but Control.Exception needs the extensions turned on.
124 Control.Exception re-exports everything from Control.Exception.Base
125 except the functions used by the GHC runtime.
127[remove kludges, now that Control.Exception is imported
128Ross Paterson <ross@soi.city.ac.uk>**20080811180328]
129[threadDelay and friends are GHC-only
130Ross Paterson <ross@soi.city.ac.uk>**20080811175039]
131[fix imports for non-GHC
133[Eq and Ord have moved into GHC.Classes
134Ian Lynagh <igloo@earth.li>**20080807095352]
135[Use the proper CInt type in GHC.Unicode
136Ian Lynagh <igloo@earth.li>**20080806232948]
137[Import wibbles
138Ian Lynagh <igloo@earth.li>**20080806232055]
139[Remove unnecessary Data/Dynamic.hs-boot
140Ian Lynagh <igloo@earth.li>**20080806230623]
141[Remove more redundant GHC.Float imports
142Ian Lynagh <igloo@earth.li>**20080806225411]
143[Remove an unnecessary import
144Ian Lynagh <igloo@earth.li>**20080806224742]
145[Move Int, Float and Double into ghc-prim:GHC.Types
146Ian Lynagh <igloo@earth.li>**20080806191554]
147[Put some explicit import lists in Data.Typeable
148Ian Lynagh <igloo@earth.li>**20080806190353]
149[Fix a couple of imports
150Ian Lynagh <igloo@earth.li>**20080806165549]
151[Remove unused conditional import
152Ian Lynagh <igloo@earth.li>**20080806124930]
153[Swap imports around to get GHC.ForeignPtr out of the base knot
154Ian Lynagh <igloo@earth.li>**20080806121313]
155[Move some bits around to stop Data.Either being in the base import knot
156Ian Lynagh <igloo@earth.li>**20080806120504]
157[Tweak an import
158Ian Lynagh <igloo@earth.li>**20080806000440]
159[Remove the DynIOError constructor of IOErrorType
160Ian Lynagh <igloo@earth.li>**20080805234720
161 As far as I can see it is never used or exported
163[Move some internals around to simplify the import graph a bit
164Ian Lynagh <igloo@earth.li>**20080805221341]
165[Move the Char datatype into ghc-prim
166Ian Lynagh <igloo@earth.li>**20080805204009]
167[Remove an unnecessary import
168Ian Lynagh <igloo@earth.li>**20080805182336]
169[The [] definition has moved to ghc-prim
170Ian Lynagh <igloo@earth.li>**20080805182332]
171[Fix warnings
172Ian Lynagh <igloo@earth.li>**20080805150250]
173[Add a missing case to Show AsyncException
174Ian Lynagh <igloo@earth.li>**20080805142811]
175[Remove GHC.Dotnet
176Ian Lynagh <igloo@earth.li>**20080804215840]
177[Hide standalone deriving clauses from haddock
178Ian Lynagh <igloo@earth.li>**20080804211617]
179[Control.Exception doesn't need to export assertError
180Ian Lynagh <igloo@earth.li>**20080804161838]
181[Generalise the type of mapException; pointed out by Isaac Dupree
182Ian Lynagh <igloo@earth.li>**20080804160941]
183[Remove some unnecessary Data.Tuple imports
184Ian Lynagh <igloo@earth.li>**20080804155956]
185[The tuple datatype definitions have moved to ghc-prim
186Ian Lynagh <igloo@earth.li>**20080804155420]
187[make ExitCode an instance of Exception for nhc98
189[poke and peek come from Foreign.Storable
191[zipWithM_ comes from Control.Monad
193[Fix nhc98 code variations to use the extensible exception API.
195 There is still only one real exception type in nhc98, so it is not truly
196 extensible.  But this is enough to get the base package building again.
198[nhc98 needs the Prelude for this module
200[Change some imports and derive Show (Either a b)
201Ian Lynagh <igloo@earth.li>**20080804004147
202 rather than writing it by hand in GHC.Show
204[Windows fixes
205Ian Lynagh <igloo@earth.li>**20080803180345]
206[Remove the duplicate definition of throwTo in Control.Exception
207Ian Lynagh <igloo@earth.li>**20080803141703
208 It now imports GHC.Conc, so it is no longer necessary
210[Remove the only import of GHC.Exts
211Ian Lynagh <igloo@earth.li>**20080803141944]
212[Move assertError into GHC.IOBase
213Ian Lynagh <igloo@earth.li>**20080803141040]
214[Use onException rather than catchAny
215Ian Lynagh <igloo@earth.li>**20080803114104]
216[Generalise the type of onException
217Ian Lynagh <igloo@earth.li>**20080803003001
218 The type of the thing to do on an exception is now
219     IO b
220 rather than
221     IO ()
222 which better matches functions like bracket.
224[Remove the dangerous Exception functions
225Ian Lynagh <igloo@earth.li>**20080802231358
226 Removed: catchAny, handleAny, ignoreExceptions
227 These make it easy to eat /any/ exception, which is rarely what you want.
228 Normally you either want to:
229 * only catch exceptions in a certain part of the hierarchy, e.g.
230   "file not found", in which case you should only catch exceptions
231   of the appropriate type,
232 or
233 * you want to do some cleanup when an exception happens, and then rethrow
234   the exception, in which case you should use onException, or one of the
235   bracketing functions.
237[Remove an unused import
238Ian Lynagh <igloo@earth.li>**20080801230343]
239[Remove unused imports
240Ian Lynagh <igloo@earth.li>**20080801230059]
241[Remove unused imports in Control.Exception
242Ian Lynagh <igloo@earth.li>**20080801225847]
243[Get rid of some duplicate imports
244Ian Lynagh <igloo@earth.li>**20080801214933]
245[Remove the now-unused GHC/Conc.lhs-boot
246Ian Lynagh <igloo@earth.li>**20080801214707]
247[Make some more imports non-recursive
248Ian Lynagh <igloo@earth.li>**20080801214546]
249[Rejig some code so Control.Exception and GHC.Conc don't need recursive imports
250Ian Lynagh <igloo@earth.li>**20080801214208]
251[Remove the now-unused GHC/TopHandler.lhs-boot
252Ian Lynagh <igloo@earth.li>**20080801212105]
253[Reshuffle GHC.Conc/GHC.TopHandler a bit to remove a recursive import
254Ian Lynagh <igloo@earth.li>**20080801211801]
255[Don't import Control.Concurrent.MVar in GHC.TopHandler
256Ian Lynagh <igloo@earth.li>**20080801200123]
257[Export assertError from Control.Exception to make GHC happy
258Ian Lynagh <igloo@earth.li>**20080801111716
259 It's a wired-in name in GHC. We should possibly move it to another module.
261[TopHandler now uses the new extensible exceptions
262Ian Lynagh <igloo@earth.li>**20080731153553]
263[Comment wibble
264Ian Lynagh <igloo@earth.li>**20080730202127]
265[Make numericEnumFrom more efficient
266Ian Lynagh <igloo@earth.li>**20080730202049]
267[Put in some parens to clarify how things parse
268Ian Lynagh <igloo@earth.li>**20080730201934]
269[applied patches to make enumFrom and friends strict in arguments as per the Report; closes ticket #1997
270Bart Massey <bart@cs.pdx.edu>**20080726080444]
271[Don't use "deriving Typeable" (for portability reasons)
272Ian Lynagh <igloo@earth.li>**20080730194434]
273[Add onException
274Ian Lynagh <igloo@earth.li>**20080730172014]
275[Fix whitespace
276Ian Lynagh <igloo@earth.li>**20080730171951
277 The space after "\begin{code}" was confusing haddock
279[Re-add blocked; it got lost in the extensible exceptions patches
280Ian Lynagh <igloo@earth.li>**20080730145614]
281[Start to actually use extensible exceptions
282Ian Lynagh <igloo@earth.li>**20080730145115]
283[Rejig the extensible exceptions so there is less circular importing
284Ian Lynagh <igloo@earth.li>**20080730122539]
285[Define nonTermination for the RTS to use
286Ian Lynagh <igloo@earth.li>**20080621144420
287 We'll probably need to do the same for some other exceptions too
289[Use extensible exceptions at the lowest level
290Ian Lynagh <igloo@earth.li>**20080621121501
291 Everything above is largely unchanged; just the type of catch and throw.
293[add comment
294Simon Marlow <marlowsd@gmail.com>**20080730114559]
295[add some big warnings to the docs for unsafeIOToSTM (#2401)
296Simon Marlow <marlowsd@gmail.com>**20080730114554]
297[FIX #2376: inline shiftR
298Simon Marlow <marlowsd@gmail.com>**20080730103539
299 Duplicating the default definition for shiftR doesn't seem quite right
300 to me, but it gets the right results when compiling the example
301 program, and I couldn't find a better way to do it.
303[Add instance Show Control.Exception.Exception for nhc98.
305[Extend nhc98's Exception type to resemble ghc's more closely
307[fix dummy async implementations for non-GHC
308Ross Paterson <ross@soi.city.ac.uk>**20080715125521]
309[Fix haddocking with older haddocks
310Ian Lynagh <igloo@earth.li>**20080710190855]
311[Add threadStatus :: ThreadId -> IO ThreadStatus
312Simon Marlow <marlowsd@gmail.com>**20080710151711
314 -- | The current status of a thread
315 data ThreadStatus
316   = ThreadRunning
317         -- ^the thread is currently runnable or running
318   | ThreadFinished
319         -- ^the thread has finished
320   | ThreadBlocked  BlockReason
321         -- ^the thread is blocked on some resource
322   | ThreadDied
323         -- ^the thread received an uncaught exception
324   deriving (Eq,Ord,Show)
326 data BlockReason
327   = BlockedOnMVar
328         -- ^blocked on on 'MVar'
329   | BlockedOnBlackHole
330         -- ^blocked on a computation in progress by another thread
331   | BlockedOnException
332         -- ^blocked in 'throwTo'
333   | BlockedOnSTM
334         -- ^blocked in 'retry' in an STM transaction
335   | BlockedOnForeignCall
336         -- ^currently in a foreign call
337   | BlockedOnOther
338         -- ^blocked on some other resource.  Without @-threaded@,
339         -- I/O and 'threadDelay' show up as 'BlockedOnOther', with @-threaded@
340         -- they show up as 'BlockedOnMVar'.
341   deriving (Eq,Ord,Show)
343 This is useful for concurrency debugging.  I've left threadStatus in
344 GHC.Conc for now, since the ThreadStatus type is somewhat GHC-specific.
346[forkOS: start the new thread in blocked mode iff the parent was (#1048)
347Simon Marlow <marlowsd@gmail.com>**20080709135558
348 This matches the behaviour of forkIO
350[Add Control.Exception.blocked :: IO Bool
351Simon Marlow <marlowsd@gmail.com>**20080709133139
352 Tells you whether async exceptions are currently blocked or not.
354[FIX BUILD (on Windows)
355Simon Marlow <marlowsd@gmail.com>**20080709123110]
356[check CONST_SIGINT
357Simon Marlow <marlowsd@gmail.com>**20080709122527]
358[Make threadWaitRead/threadWaitWrite partially useable on Windows
359Simon Marlow <marlowsd@gmail.com>**20080709111008
361 They work with -threaded by calling fdReady() in a separate thread.
363 "threadWaitRead 0" also works without -threaded (because we happen to
364 know it's virtually equivalent to "hWaitForInput stdin (-1)").
366[FIX #1198: hWaitForInput on Windows
367Simon Marlow <marlowsd@gmail.com>**20080708134254
368 Now we do the appropriate magic in fdReady() to detect when there is
369 real input available, as opposed to uninteresting console events.
371[FIX part of #2301
372Simon Marlow <marlowsd@gmail.com>**20080709094437
374 Control-C now causes the new exception (AsyncException UserInterrupt)
375 to be raised in the main thread.  The signal handler is set up by
376 GHC.TopHandler.runMainIO, and can be overriden in the usual way by
377 installing a new signal handler.  The advantage is that now all
378 programs will get a chance to clean up on ^C.
380 When UserInterrupt is caught by the topmost handler, we now exit the
381 program via kill(getpid(),SIGINT), which tells the parent process that
382 we exited as a result of ^C, so the parent can take appropriate action
383 (it might want to exit too, for example).
385 One subtlety is that we have to use a weak reference to the ThreadId
386 for the main thread, so that the signal handler doesn't prevent the
387 main thread from being subject to deadlock detection.
389[() has moved to ghc-prim:GHC.Unit, and the Eq and Ord instances to Data.Tuple
390Ian Lynagh <igloo@earth.li>**20080624144932]
391[Add GHC.Exts.maxTupleSize :: Int, the size of the largest tuple supported
392Ian Lynagh <igloo@earth.li>**20080622141559]
393[Remove code for older GHC versions
394Ian Lynagh <igloo@earth.li>**20080620194521]
395[Make the macros in Typeable.h add type signatures
396Ian Lynagh <igloo@earth.li>**20080619235808]
397[Fix #2363: getChar cannot be interrupted with -threaded
398Simon Marlow <marlowsd@gmail.com>**20080619141911
399 Now in -threaded mode, instead of just making a blocking call to
400 read(), we call select() first to make sure the read() won't block,
401 and if it would block, then we use threadWaitRead.
403 The idea is that the current thread must be interruptible while it
404 blocks.  This is a little slower than before, but the overhead only
405 applies to blocking Handles (stdin/stdout/stderr, and those created by
406 System.Process).
408[Remove -fglasgow-exts from pragmas and comments
409Ian Lynagh <igloo@earth.li>**20080616230727]
410[Avoid using deprecated flags
411Ian Lynagh <igloo@earth.li>**20080616145207]
412[delete __hscore_{mkstemp,getrlimit,setrlimit} (moved to unix)
413Ross Paterson <ross@soi.city.ac.uk>**20080615224413]
414[Update WCsubst.c for Unicode 5.1.0, and add a README.Unicode
415Ian Lynagh <igloo@earth.li>**20080613201754
416 README.Unicode describes how to do updates in the future.
418[Fix ubconfc
419Ian Lynagh <igloo@earth.li>**20080613201456
420 The current code doesn't seem to be what was used to generate WCsubst.c,
421 so I'm not sure if it never worked, or if my tools work slightly
422 differently to those of the previous user.
424['permutations' is now more lazy and also faster
425Twan van Laarhoven <twanvl@gmail.com>**20080102231712]
426['subsequences' is now more lazy and also faster
427Twan van Laarhoven <twanvl@gmail.com>**20080102231629]
428[Add 'subsequences' and 'permutations' to Data.List
429Twan van Laarhoven <twanvl@gmail.com>**20071218154950]
430[Tweak the definition of (^) again
431Ian Lynagh <igloo@earth.li>**20080601120759
432 This fixes trac #2306 (do the minimum number of (*)s), and also means
433 that we don't use the value of (1 :: a) which causes problems if the
434 Num a definition isn't complete.
436[note about evaluation affecting StableNames
437Simon Marlow <marlowsd@gmail.com>**20080527110549]
438[TAG 2008-05-28
439Ian Lynagh <igloo@earth.li>**20080528003830]
440Patch bundle hash: