[Base library changes part 2/2
Einar Karttunen <ekarttun@cs.helsinki.fi>**20060310113449] move ./lib/base/Array.hs ./lib/base/Data/Array.hs
move ./lib/base/IO.hs ./lib/base/System/IO.hs
move ./lib/base/Random.hs ./lib/base/System/Random.hs
hunk ./lib/base/Data/Char.hs 1
-module Data.Char (module Char) where import Char
rmfile ./lib/base/Data/Char.hs
move ./lib/base/Char.hs ./lib/base/Data/Char.hs
move ./lib/base/Complex.hs ./lib/base/Data/Complex.hs
move ./lib/base/Ix.hs ./lib/base/Data/Ix.hs
hunk ./lib/base/Data/List.hs 1
-module Data.List (module List) where import List
rmfile ./lib/base/Data/List.hs
move ./lib/base/List.hs ./lib/base/Data/List.hs
move ./lib/base/Locale.hs ./lib/base/System/Locale.hs
move ./lib/base/Maybe.hs ./lib/base/Data/Maybe.hs
move ./lib/base/Ratio.hs ./lib/base/Data/Ratio.hs
move ./lib/base/Time.hs ./lib/base/System/Time.hs
hunk ./lib/base/Control/Monad.hs 1
-module Control.Monad (module Monad) where import Monad
rmfile ./lib/base/Control/Monad.hs
move ./lib/base/Monad.hs ./lib/base/Control/Monad.hs
addfile ./lib/base/Control/Exception.hs
addfile ./lib/base/Foreign/StablePtr.hs
hunk ./Makefile 42
+PACKAGES=base-1.0.hl haskell98-1.0.hl
hunk ./Makefile 48
-	./jhc -v $(JHC_TEST) -ilib/base --noauto --build-hl lib/base/base.cabal -o base-1.0.hl 2>&1 | tee base.log
+	./jhc $(JHC_TEST) -ilib/base --noauto --build-hl lib/base/base.cabal -o base-1.0.hl 2>&1 | tee base.log
hunk ./Makefile 50
-base-1.0.prof.hl: jhc lib/base/base.cabal
-	-[ -e base.prof.log ] && mv -f base.prof.log base.prof.log.bak
-	./jhcp -v $(JHC_TEST) -ilib/base --noauto --build-hl lib/base/base.cabal -o base-1.0.prof.hl +RTS $(PROF_OPTS)  2>&1 | tee base.log
-
hunk ./Makefile 55
-	install base-1.0.hl $(LIBRARYPATH)
+	install $(PACKAGES) $(LIBRARYPATH)
hunk ./lib/base/Control/Exception.hs 1
+-- | This is mostly dummy, JHC does not support inexact exceptions.
+
+module Control.Exception where
+
+import Prelude hiding(catch)
+import qualified Prelude as P
+
+type IOException = IOError
+
+data Exception = IOException IOException
+
+-- throw :: Exception -> a
+
+throwIO :: Exception -> IO a
+throwIO (IOException ioe) = ioError ioe
+
+catch :: IO a -> (Exception -> IO a) -> IO a
+catch c h = P.catch c (h . IOException)
+
+catchJust :: (Exception -> Maybe b) -> IO a -> (b -> IO a) -> IO a
+catchJust et c h = catch c $ \e -> maybe (throwIO e) h (et e)
+
+handle :: (Exception -> IO a) -> IO a -> IO a
+handle = flip catch
+
+handleJust :: (Exception -> Maybe b) -> (b -> IO a) -> IO a -> IO a
+handleJust et h c = catchJust et c h
+
+try :: IO a -> IO (Either Exception a)
+try c = catch (fmap Right c) (return . Left)
+
+tryJust :: (Exception -> Maybe b) -> IO a -> IO (Either b a)
+tryJust et c = catchJust et (fmap Right c) (return . Left)
+
+-- FIXME this is wrong!
+evaluate :: a -> IO a
+evaluate = return
+
+-- mapException
+
+ioErrors (IOException _) = True
+
+block, unblock :: IO a -> IO a
+block   = id
+unblock = id
+
+bracket        :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
+bracket before after m = do
+        x  <- before
+        rs <- try (m x)
+        after x
+        case rs of
+           Right r -> return r
+           Left  e -> throwIO e
+
+bracket_        :: IO a -> (a -> IO b) -> IO c -> IO c
+bracket_ before after m = bracket before after (const m)
+
+finally :: IO a -> IO b -> IO a
+finally cmd end = bracket_ (return ()) (const end) cmd
hunk ./lib/base/Control/Monad.hs 1
-module Monad(
+module Control.Monad(
hunk ./lib/base/Data/Array.hs 1
-module  Array (
+module  Data.Array (
hunk ./lib/base/Data/Array.hs 6
-import Ix
-import List( (\\) )
+import Data.Ix
+import Data.List( (\\) )
hunk ./lib/base/Data/Char.hs 1
-module Char (
+module Data.Char (
hunk ./lib/base/Data/Complex.hs 1
-module Complex(
+module Data.Complex(
hunk ./lib/base/Data/Ix.hs 1
-module Ix ( Ix(range, index, inRange, rangeSize) ) where
+module Data.Ix ( Ix(range, index, inRange, rangeSize) ) where
hunk ./lib/base/Data/List.hs 2
-module List (
+module Data.List (
hunk ./lib/base/Data/Maybe.hs 2
-module Maybe(
+module Data.Maybe(
hunk ./lib/base/Data/Ratio.hs 3
-module  Ratio (
+module  Data.Ratio (
hunk ./lib/base/Foreign/C/String.hs 95
+import Data.Char ( chr, ord )
hunk ./lib/base/Foreign/C/String.hs 98
-import Char ( chr, ord )
hunk ./lib/base/Foreign/StablePtr.hs 1
+-- | Just a dummy skeleton, fixme.
+module Foreign.StablePtr where
hunk ./lib/base/Numeric.hs 10
-import Char   ( isDigit, isOctDigit, isHexDigit
-              , digitToInt, intToDigit )
+import Data.Char   ( isDigit, isOctDigit, isHexDigit
+                   , digitToInt, intToDigit )
hunk ./lib/base/Prelude/Float.hs 3
-import Ratio
+import Data.Ratio
hunk ./lib/base/Prelude/IO.hs 12
-import Char
+import Data.Char
hunk ./lib/base/Prelude/Text.hs 14
-import Char(isSpace, isAlpha, isDigit, isAlphaNum,
-            showLitChar, readLitChar, lexLitChar)
+import Data.Char(isSpace, isAlpha, isDigit, isAlphaNum,
+                 showLitChar, readLitChar, lexLitChar)
hunk ./lib/base/Prelude.hs 20
-import Ratio
-import qualified Char(isSpace,ord,chr)
+import Data.Ratio
+import qualified Data.Char as Char(isSpace,ord,chr)
hunk ./lib/base/System/IO.hs 1
-module IO(
+module System.IO(
hunk ./lib/base/System/IO.hs 10
-    try,bracket,bracket_,hFlush,stdin,stdout,stderr,
+    try,hFlush,stdin,stdout,stderr,
hunk ./lib/base/System/IO.hs 36
-import Char(ord)
+import Data.Char(ord)
hunk ./lib/base/System/IO.hs 51
-bracket        :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
-bracket before after m = do
-        x  <- before
-        rs <- try (m x)
-        after x
-        case rs of
-           Right r -> return r
-           Left  e -> ioError e
-
--- variant of the above where middle computation doesn't want x
-bracket_        :: IO a -> (a -> IO b) -> IO c -> IO c
-bracket_ before after m = do
-         x  <- before
-         rs <- try m
-         after x
-         case rs of
-            Right r -> return r
-            Left  e -> ioError e
-
-
hunk ./lib/base/System/Locale.hs 1
-module Locale where
+module System.Locale where
hunk ./lib/base/System/Random.hs 15
-module Random
+module System.Random
hunk ./lib/base/System/Random.hs 29
-import Char ( isSpace, chr, ord )
-
+import Data.Char ( isSpace, chr, ord )
hunk ./lib/base/System/Time.hs 17
-import Ix
-import Locale
-import System.IO.Unsafe
-import Foreign.Ptr
-import Char
+import Data.Char
+import Data.Ix
hunk ./lib/base/System/Time.hs 20
+import Foreign.Ptr
+import System.Locale
+import System.IO.Unsafe
hunk ./lib/base/base.cabal 4
-Exposed-Modules: Array,
+Exposed-Modules: Control.Exception,
hunk ./lib/base/base.cabal 6
-                 Char,
-                 Complex,
+                 Data.Array,
hunk ./lib/base/base.cabal 8
+                 Data.Complex,
hunk ./lib/base/base.cabal 12
-                 Data.Int,
hunk ./lib/base/base.cabal 14
---                 Data.IORef,
+                 Data.IORef,
hunk ./lib/base/base.cabal 16
+                 Data.Ratio,
hunk ./lib/base/base.cabal 22
+                 Foreign.ForeignPtr,
hunk ./lib/base/base.cabal 27
-                 Foreign.ForeignPtr,
-                 Foreign.Storable,
hunk ./lib/base/base.cabal 28
-                 IO,
-                 Ix,
+                 Foreign.StablePtr,
+                 Foreign.Storable,
hunk ./lib/base/base.cabal 38
-                 List,
-                 Locale,
-                 Maybe,
-                 Monad,
hunk ./lib/base/base.cabal 45
-                 Random,
-                 Ratio,
+                 System.Console.GetOpt,
hunk ./lib/base/base.cabal 49
+                 System.IO,
+                 System.IO.Error,
hunk ./lib/base/base.cabal 53
-                 System.Console.GetOpt,
+                 System.Locale,
+                 System.Random,
+                 System.Time,
hunk ./lib/base/base.cabal 57
-                 Time,