[rearrange standard libraries to remove dependency loop on Prelude
John Meacham <john@repetae.net>**20120130013107
 Ignore-this: 49c9b0ac945d16198faa95ae1d6ba705
] hunk ./lib/jhc/Data/Char.hs 14
---import Array         -- Used for character name table.
-import Prelude
-import Numeric (readDec, readOct, lexDigits, readHex)
-import Prelude.Text
hunk ./lib/jhc/Data/Char.hs 15
-import Prelude.CType
+import Jhc.Enum
+import Jhc.IO
+import Jhc.Inst.Show
+import Jhc.List
+import Jhc.Num
hunk ./lib/jhc/Data/Char.hs 21
-
-
-
-
-lexLitChar :: ReadS String
-lexLitChar ('\\':s) = lexEsc s
-lexLitChar (c:s) = [([c],s)]
+import Jhc.Show
+import Jhc.Text.Read
+import Prelude.CType
hunk ./lib/jhc/Data/Char.hs 55
-lexEsc          :: ReadS String
-lexEsc (c:s) | c `elem` "abfnrtv\\\"\'" = [('\\':[c],s)]
-lexEsc ('^':(c:s)) | c >= '@' && c <= '_'
-                 = [('\\':'^':[c], s)]
---lexEsc s@(d:_) | isDigit d
---                 = [(chr n, t) | (n,t) <- readDec s]
---lexEsc ('o':s)  = [(chr n, t) | (n,t) <- readOct s]
---lexEsc ('x':s)  = [(chr n, t) | (n,t) <- readHex s]
---lexEsc s@(c:_) | isUpper c
---                 = let table = ('\DEL', "DEL") : zip ['\NUL' .. ] asciiTab
---                   in case [(c,s') | (c, mne) <- table,
---                                     ([],s') <- [match mne s]]
---                      of (pr:_) -> [pr]
---                         []     -> []
-lexEsc _        = []
-
hunk ./lib/jhc/Data/Char.hs 78
-
-asciiTab :: [String]
-asciiTab = --listArray ('\NUL', ' ')
-           ["NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
-            "BS",  "HT",  "LF",  "VT",  "FF",  "CR",  "SO",  "SI",
-            "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
-            "CAN", "EM",  "SUB", "ESC", "FS",  "GS",  "RS",  "US",
-            "SP"]
hunk ./lib/jhc/Data/Ratio.hs 2
-
hunk ./lib/jhc/Data/Ratio.hs 5
-import Prelude
-import Prelude.Text
-import Prelude.Float(doubleToRational)
+import Jhc.Basics
+import Jhc.Float
+import Jhc.IO
hunk ./lib/jhc/Data/Ratio.hs 9
+import Jhc.Numeric
hunk ./lib/jhc/Data/Ratio.hs 11
-import Jhc.Float
+import Jhc.Type.Basic
+import Prelude.Float()
+import Prelude.Text
hunk ./lib/jhc/Data/Ratio.hs 19
-
-
hunk ./lib/jhc/Data/Ratio.hs 22
-
-
hunk ./lib/jhc/Data/Ratio.hs 24
-
-
-
hunk ./lib/jhc/Data/Ratio.hs 113
+
+doubleToRational :: Double -> Rational
+doubleToRational x  =  (m:%1)*(b:%1)^^n where
+    (m,n) = decodeFloat x
+    b     = floatRadix  x
hunk ./lib/jhc/Jhc/List.hs 321
+-- take n, applied to a list xs, returns the prefix of xs of length n,
+-- or xs itself if n > length xs.  drop n xs returns the suffix of xs
+-- after the first n elements, or [] if n > length xs.  splitAt n xs
+-- is equivalent to (take n xs, drop n xs).
+
+take :: Int -> [a] -> [a]
+take n xs = f n xs where
+    f n _      | n <= zero =  []
+    f _ []              =  []
+    f n (x:xs)          =  x : f (n `minus` one) xs
+
+drop :: Int -> [a] -> [a]
+drop n xs = f n xs where
+    f n xs | n <= zero =  xs
+    f _ [] = []
+    f n (_:xs) = f (n `minus` one) xs
+
+-- replicate n x is a list of length n with x the value of every element
+replicate        :: Int -> a -> [a]
+replicate n x    = f n where
+    f n | n <= zero = []
+    f n = let n' = n `minus` one in n' `seq` (x:f n')
+
+splitAt                  :: Int -> [a] -> ([a],[a])
+--splitAt n xs             =  (take n xs, drop n xs)
+splitAt n ls | n < zero	= ([], ls)
+splitAt n ls = splitAt' n ls where
+    splitAt' :: Int -> [a] -> ([a], [a])
+    splitAt' z  xs | z == zero = ([], xs)
+    splitAt' _  []  = ([], [])
+    splitAt' m (x:xs) = case splitAt' (m `minus` one) xs of
+        (xs', xs'') -> (x:xs', xs'')
+
+{-# RULES "take/repeat"   forall n x . take n (repeat x) = replicate n x #-}
+
addfile ./lib/jhc/Jhc/Numeric.hs
hunk ./lib/jhc/Jhc/Numeric.hs 1
+module Jhc.Numeric where
+
+import Jhc.IO
+import Jhc.Num
+import Jhc.Type.Basic
+import Jhc.Type.Float
+import Jhc.Float
+import Jhc.Order
+
+infixr 8  ^, ^^
+
+{-# SPECIALIZE gcd :: Int -> Int -> Int #-}
+{-# SPECIALIZE gcd :: Integer -> Integer -> Integer #-}
+gcd              :: (Integral a) => a -> a -> a
+gcd 0 0          =  error "Prelude.gcd: gcd 0 0 is undefined"
+gcd x y          =  gcd' (abs x) (abs y)
+                    where gcd' x 0  =  x
+                          gcd' x y  =  gcd' y (x `rem` y)
+
+{-# SPECIALIZE lcm :: Int -> Int -> Int #-}
+{-# SPECIALIZE lcm :: Integer -> Integer -> Integer #-}
+lcm              :: (Integral a) => a -> a -> a
+lcm _ 0          =  0
+lcm 0 _          =  0
+lcm x y          =  abs ((x `quot` (gcd x y)) * y)
+
+{-# SPECIALIZE (^) :: Int -> Int -> Int #-}
+{-# SPECIALIZE (^) :: Integer -> Int -> Integer #-}
+{-# SPECIALIZE (^) :: Double -> Int -> Double #-}
+
+(^)              :: (Num a, Integral b) => a -> b -> a
+x ^ 0            =  1
+x ^ n | n > 0    =  f x (n-1) x
+                    where f _ 0 y = y
+                          f x n y = g x n  where
+                                    g x n | even n  = g (x*x) (n `quot` 2)
+                                          | True = f x (n-1) (x*y)
+_ ^ _            = error "Prelude.^: negative exponent"
+
+(^^)             :: (Fractional a, Integral b) => a -> b -> a
+x ^^ n           =  if n >= 0 then x^n else recip (x^(-n))
hunk ./lib/jhc/Jhc/Text/Read.hs 40
-
hunk ./lib/jhc/Jhc/Text/Read.hs 148
+
+-- readInt reads a string of digits using an arbitrary base.
+-- Leading minus signs must be handled elsewhere.
+
+{-# SPECIALIZE readInt :: Int -> (Char -> Bool) -> (Char -> Int) -> ReadS Int #-}
+{-# SPECIALIZE readInt :: Integer -> (Char -> Bool) -> (Char -> Int) -> ReadS Integer #-}
+
+readInt :: (Integral a) => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
+readInt radix isDig digToInt s =
+   [(foldl1 (\n d -> n * radix + d) (map (fromIntegral . digToInt) ds), r)
+          | (ds,r) <- nonnull isDig s ]
+
+-- Unsigned readers for various bases
+readDec, readOct, readHex :: (Integral a) => ReadS a
+readDec = readInt 10 isDigit    digitToInt
+readOct = readInt  8 isOctDigit digitToInt
+readHex = readInt 16 isHexDigit digitToInt
hunk ./lib/jhc/Numeric.hs 10
-import Prelude
-import Data.Word
-import Prelude.CType   ( isDigit, isOctDigit, isHexDigit
-                   , digitToInt, intToDigit )
hunk ./lib/jhc/Numeric.hs 11
---import Array  ( (!), Array, array )
-import Prelude.Text
+import Data.Word
+import Jhc.Basics
+import Jhc.Enum
+import Jhc.Float
+import Jhc.IO
+import Jhc.List
+import Jhc.Num
+import Jhc.Numeric
+import Jhc.Order
hunk ./lib/jhc/Numeric.hs 21
+import Data.Char
+import Prelude.CType(isDigit,isOctDigit,isHexDigit,digitToInt,intToDigit)
+import Prelude.Text
hunk ./lib/jhc/Numeric.hs 105
-
hunk ./lib/jhc/Numeric.hs 125
-
hunk ./lib/jhc/Numeric.hs 138
-
hunk ./lib/jhc/Numeric.hs 146
-
--- readInt reads a string of digits using an arbitrary base.
--- Leading minus signs must be handled elsewhere.
-
-{-# SPECIALIZE readInt :: Int -> (Char -> Bool) -> (Char -> Int) -> ReadS Int #-}
-{-# SPECIALIZE readInt :: Integer -> (Char -> Bool) -> (Char -> Int) -> ReadS Integer #-}
-
-readInt :: (Integral a) => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
-readInt radix isDig digToInt s =
-   [(foldl1 (\n d -> n * radix + d) (map (fromIntegral . digToInt) ds), r)
-          | (ds,r) <- nonnull isDig s ]
-
--- Unsigned readers for various bases
-readDec, readOct, readHex :: (Integral a) => ReadS a
-readDec = readInt 10 isDigit    digitToInt
-readOct = readInt  8 isOctDigit digitToInt
-readHex = readInt 16 isHexDigit digitToInt
-
-
hunk ./lib/jhc/Numeric.hs 228
-
hunk ./lib/jhc/Numeric.hs 319
-
-
hunk ./lib/jhc/Prelude.hs 30
+    take,drop,
hunk ./lib/jhc/Prelude.hs 47
+    module Jhc.Numeric,
hunk ./lib/jhc/Prelude.hs 70
+import Jhc.Inst.Num
hunk ./lib/jhc/Prelude.hs 83
+import Jhc.Numeric
hunk ./lib/jhc/Prelude.hs 96
-infixr 8  ^, ^^
+--infixr 8  ^, ^^
hunk ./lib/jhc/Prelude.hs 108
+{-
hunk ./lib/jhc/Prelude.hs 141
+-}
hunk ./lib/jhc/Prelude.hs 163
--- replicate n x is a list of length n with x the value of every element
-
-replicate        :: Int -> a -> [a]
-replicate n x    = f n where
-    f n | n <= 0 = []
-    f n = let n' = n - 1 in n' `seq` (x:f n')
hunk ./lib/jhc/Prelude.hs 172
--- take n, applied to a list xs, returns the prefix of xs of length n,
--- or xs itself if n > length xs.  drop n xs returns the suffix of xs
--- after the first n elements, or [] if n > length xs.  splitAt n xs
--- is equivalent to (take n xs, drop n xs).
-
-take :: Int -> [a] -> [a]
-take n xs = f n xs where
-    f n _      | n <= 0 =  []
-    f _ []              =  []
-    f n (x:xs)          =  x : f (n-1) xs
-
-drop :: Int -> [a] -> [a]
-drop n xs = f n xs where
-    f n xs | n <= 0 =  xs
-    f _ [] = []
-    f n (_:xs) = f (n-1) xs
-
-splitAt                  :: Int -> [a] -> ([a],[a])
---splitAt n xs             =  (take n xs, drop n xs)
-splitAt n ls | n < 0	= ([], ls)
-splitAt n ls = splitAt' n ls where
-    splitAt' :: Int -> [a] -> ([a], [a])
-    splitAt' 0  xs  = ([], xs)
-    splitAt' _  []  = ([], [])
-    splitAt' m (x:xs) = case splitAt' (m - 1) xs of
-        (xs', xs'') -> (x:xs', xs'')
-
hunk ./lib/jhc/Prelude.hs 307
-{-# RULES "take/repeat"   forall n x . take n (repeat x) = replicate n x #-}
hunk ./lib/jhc/Prelude/Float.hs 5
-import Data.Word
-import Foreign.C.Types
hunk ./lib/jhc/Prelude/Float.hs 10
-import Jhc.IO
-import Jhc.List
+import Jhc.IO(error)
+import Jhc.List(length,notElem,take,elem)
hunk ./lib/jhc/Prelude/Float.hs 16
+import Jhc.Type.C
hunk ./lib/jhc/Prelude/Float.hs 18
-import Prelude((^),(^^),elem,take)
+import Jhc.Numeric((^),(^^))
hunk ./lib/jhc/Prelude/Float.hs 20
+import System.IO.Unsafe
hunk ./lib/jhc/Prelude/Text.hs 9
--- The instances of Read and Show for
---      Bool, Maybe, Either, Ordering
--- are done via "deriving" clauses in Prelude.hs
hunk ./lib/jhc/Prelude/Text.hs 10
-import Jhc.Float
-import Jhc.Inst.Show()
+import Jhc.Type.Float
hunk ./lib/jhc/Prelude/Text.hs 18
-import Prelude.Float
hunk ./lib/jhc/Prelude/Text.hs 19
-import Jhc.Inst.Num()
-
hunk ./lib/jhc/Prelude/Text.hs 38
-
-
hunk ./lib/jhc/Prelude/Text.hs 44
-
-
hunk ./lib/jhc/Prelude/Text.hs 49
-
hunk ./lib/jhc/Prelude/Text.hs 55
-
hunk ./lib/jhc/Prelude/Text.hs 58
-
hunk ./lib/jhc/Prelude/Text.hs 79
-
hunk ./lib/jhc/Prelude/Text.hs 82
-
-
hunk ./lib/jhc/Prelude/Text.hs 88
-
hunk ./lib/jhc/Prelude/Text.hs 96
-
-
-
hunk ./lib/jhc/jhc.yaml 31
+        - Jhc.Numeric