diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2016-06-18 22:44:19 +0200 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2016-06-20 16:22:07 +0200 |
commit | a7160faafd44d64c2b20a4cc65e80136a93e1aaa (patch) | |
tree | c0fa999a4696a5a05e861b0eacfcd92358d77a48 /testsuite/tests/codeGen | |
parent | 5b03dc69389dc387b922c589ab9a8b92079e6a96 (diff) | |
download | haskell-a7160faafd44d64c2b20a4cc65e80136a93e1aaa.tar.gz |
Testsuite: tabs -> spaces [skip ci]
Diffstat (limited to 'testsuite/tests/codeGen')
31 files changed, 321 insertions, 321 deletions
diff --git a/testsuite/tests/codeGen/should_compile/cg004.hs b/testsuite/tests/codeGen/should_compile/cg004.hs index fb8e3cc413..86b4a23a72 100644 --- a/testsuite/tests/codeGen/should_compile/cg004.hs +++ b/testsuite/tests/codeGen/should_compile/cg004.hs @@ -1,24 +1,24 @@ module ShouldCompile where --- Killed GHC 6.0 in isCrossDllArg +-- Killed GHC 6.0 in isCrossDllArg -- -- ghc-6.0: panic! (the `impossible' happened, GHC version 6.0): --- coreSyn/CoreUtils.lhs:1188: Non-exhaustive patterns in function isCrossDllArg +-- coreSyn/CoreUtils.lhs:1188: Non-exhaustive patterns in function isCrossDllArg -- -- The reason was that newST had the form -- newST = \ @ v -> GHC.Base.: --- @ (Environment.Scope v) --- (case $fScopeOpersScope @ v --- of tpl_B1 { Environment.:DScopeOpers tpl_B2 tpl_B3 -> --- tpl_B2 --- }) --- (GHC.Base.[] @ (Environment.Scope v)) +-- @ (Environment.Scope v) +-- (case $fScopeOpersScope @ v +-- of tpl_B1 { Environment.:DScopeOpers tpl_B2 tpl_B3 -> +-- tpl_B2 +-- }) +-- (GHC.Base.[] @ (Environment.Scope v)) class ScopeOpers s where - emptyScope :: s + emptyScope :: s op :: s -> s -data Scope v = NewScope +data Scope v = NewScope instance ScopeOpers (Scope v) where emptyScope = error "emptyScope" diff --git a/testsuite/tests/codeGen/should_compile/jmp_tbl.hs b/testsuite/tests/codeGen/should_compile/jmp_tbl.hs index 05fabf630c..9f5dbf356a 100644 --- a/testsuite/tests/codeGen/should_compile/jmp_tbl.hs +++ b/testsuite/tests/codeGen/should_compile/jmp_tbl.hs @@ -97,9 +97,9 @@ eqPhase Cc Cc = True eqPhase HCc HCc = True eqPhase SplitAs SplitAs = True eqPhase As As = True -eqPhase LlvmOpt LlvmOpt = True -eqPhase LlvmLlc LlvmLlc = True -eqPhase LlvmMangle LlvmMangle = True +eqPhase LlvmOpt LlvmOpt = True +eqPhase LlvmLlc LlvmLlc = True +eqPhase LlvmMangle LlvmMangle = True eqPhase MergeStub MergeStub = True eqPhase StopLn StopLn = True eqPhase _ _ = False diff --git a/testsuite/tests/codeGen/should_run/T2080.hs b/testsuite/tests/codeGen/should_run/T2080.hs index 13a932a2a7..924e77a30f 100644 --- a/testsuite/tests/codeGen/should_run/T2080.hs +++ b/testsuite/tests/codeGen/should_run/T2080.hs @@ -15,7 +15,7 @@ utf8DecodeChar# a# fred = -- Omitting the next line gives an ASSERT error: -- ghc-6.9: panic! (the 'impossible' happened) -- (GHC version 6.9 for x86_64-unknown-linux): --- ASSERT failed! file nativeGen/MachCodeGen.hs line 1049 +-- ASSERT failed! file nativeGen/MachCodeGen.hs line 1049 -- %MO_S_Le_I8(I8[R2], 127 :: I8) | fred -> True diff --git a/testsuite/tests/codeGen/should_run/T5900.hs b/testsuite/tests/codeGen/should_run/T5900.hs index 231edeba2c..83b0f8a36d 100644 --- a/testsuite/tests/codeGen/should_run/T5900.hs +++ b/testsuite/tests/codeGen/should_run/T5900.hs @@ -4,11 +4,11 @@ import Debug.Trace fl :: Word64 -> Word64 -> Word64 fl fin sk = - let (x1, x2) = w64tow32 fin in - let (k1, k2) = w64tow32 sk in - let y2 = x2 `xor` ((x1 .&. k1) `rotateL` 1) in - let y1 = x1 `xor` (y2 .|. k2) in - trace (show fin ++ " " ++ show sk ++ " -> " ++ show (w32tow64 (y1, y2))) $ w32tow64 (y1, y2) + let (x1, x2) = w64tow32 fin in + let (k1, k2) = w64tow32 sk in + let y2 = x2 `xor` ((x1 .&. k1) `rotateL` 1) in + let y1 = x1 `xor` (y2 .|. k2) in + trace (show fin ++ " " ++ show sk ++ " -> " ++ show (w32tow64 (y1, y2))) $ w32tow64 (y1, y2) w64tow32 :: Word64 -> (Word32, Word32) w64tow32 w = (fromIntegral (w `shiftR` 32), fromIntegral (w .&. 0xffffffff)) diff --git a/testsuite/tests/codeGen/should_run/cgrun002.hs b/testsuite/tests/codeGen/should_run/cgrun002.hs index dddaabd66f..b1dcd5e59d 100644 --- a/testsuite/tests/codeGen/should_run/cgrun002.hs +++ b/testsuite/tests/codeGen/should_run/cgrun002.hs @@ -3,8 +3,8 @@ main = print ((f id2) (10 + thirty_two)) f x = g x where g x = h x - where - h x = x + where + h x = x thirty_two :: Int thirty_two = 32 diff --git a/testsuite/tests/codeGen/should_run/cgrun003.hs b/testsuite/tests/codeGen/should_run/cgrun003.hs index 47b2d9e7bf..645a15ce0e 100644 --- a/testsuite/tests/codeGen/should_run/cgrun003.hs +++ b/testsuite/tests/codeGen/should_run/cgrun003.hs @@ -1,6 +1,6 @@ main = print (id2 (id2 id2) (42::Int)) --- where --- id2 = s k k +-- where +-- id2 = s k k -- id2 x = s k k x diff --git a/testsuite/tests/codeGen/should_run/cgrun006.hs b/testsuite/tests/codeGen/should_run/cgrun006.hs index 609c3c2b4b..bd7ad42c5f 100644 --- a/testsuite/tests/codeGen/should_run/cgrun006.hs +++ b/testsuite/tests/codeGen/should_run/cgrun006.hs @@ -1,6 +1,6 @@ main = print (length thirteen_ones) where - thirteen_ones = take (13::Int) ones + thirteen_ones = take (13::Int) ones - ones :: [Int] - ones = 1 : ones + ones :: [Int] + ones = 1 : ones diff --git a/testsuite/tests/codeGen/should_run/cgrun007.hs b/testsuite/tests/codeGen/should_run/cgrun007.hs index 317b921a42..841869524a 100644 --- a/testsuite/tests/codeGen/should_run/cgrun007.hs +++ b/testsuite/tests/codeGen/should_run/cgrun007.hs @@ -4,11 +4,11 @@ main = print (height our_tree) where our_tree :: Tree Int our_tree = - Branch (Branch (Leaf 1) (Branch (Branch (Leaf 1) (Leaf 1)) (Leaf 1))) - (Branch (Leaf 1) (Leaf 1)) + Branch (Branch (Leaf 1) (Branch (Branch (Leaf 1) (Leaf 1)) (Leaf 1))) + (Branch (Leaf 1) (Leaf 1)) height :: Tree a -> Int -height (Leaf _) = 1 -height (Branch t1 t2) = 1 + max (height t1) (height t2) +height (Leaf _) = 1 +height (Branch t1 t2) = 1 + max (height t1) (height t2) diff --git a/testsuite/tests/codeGen/should_run/cgrun008.hs b/testsuite/tests/codeGen/should_run/cgrun008.hs index 1713b4834e..f7c6b045f4 100644 --- a/testsuite/tests/codeGen/should_run/cgrun008.hs +++ b/testsuite/tests/codeGen/should_run/cgrun008.hs @@ -2,11 +2,11 @@ main = print (length comp_list) where comp_list :: [(Int,Int)] comp_list = [ (elem1,elem2) - | elem1 <- given_list, - elem2 <- given_list, - elem1 >= (4::Int), - elem2 < (3::Int) - ] + | elem1 <- given_list, + elem2 <- given_list, + elem1 >= (4::Int), + elem2 < (3::Int) + ] given_list :: [Int] given_list = [1,2,3,4,5,6,7,8,9] diff --git a/testsuite/tests/codeGen/should_run/cgrun011.hs b/testsuite/tests/codeGen/should_run/cgrun011.hs index c687e50272..5619d5a964 100644 --- a/testsuite/tests/codeGen/should_run/cgrun011.hs +++ b/testsuite/tests/codeGen/should_run/cgrun011.hs @@ -19,11 +19,11 @@ instance Bar Bool where bar a b = a < b foO = if bar (2::Int) (3::Int) then - if bar False True then - (42::Int) - else - (888::Int) + if bar False True then + (42::Int) + else + (888::Int) else - (999::Int) + (999::Int) main = print foO diff --git a/testsuite/tests/codeGen/should_run/cgrun012.hs b/testsuite/tests/codeGen/should_run/cgrun012.hs index 8fe0a869c4..2be5bed751 100644 --- a/testsuite/tests/codeGen/should_run/cgrun012.hs +++ b/testsuite/tests/codeGen/should_run/cgrun012.hs @@ -1,39 +1,39 @@ {-# LANGUAGE MagicHash #-} -- !!! move arguments around on the stacks, mainly the B stack -import GHC.Base ( Float#, Double#, Int#, Int(..) ) +import GHC.Base ( Float#, Double#, Int#, Int(..) ) main = print foo foo = I# - ( f 1.1## - 2.1# - True - 3.1## - 4.1# - 5.1## - 6.1## - 42# -- the answer! - 7.1# - 8.1# ) + ( f 1.1## + 2.1# + True + 3.1## + 4.1# + 5.1## + 6.1## + 42# -- the answer! + 7.1# + 8.1# ) where f :: Double# -> Float# -> Bool -> Double# -> Float# - -> Double# -> Double# -> Int# -> Float# -> Float# - -> Int# + -> Double# -> Double# -> Int# -> Float# -> Float# + -> Int# f b1 s2 t b3 s4 b5 b6 i42 s7 s8 - -- evens, then odds - = g s2 b3 b5 i42 s8 b1 t s4 b6 s7 + -- evens, then odds + = g s2 b3 b5 i42 s8 b1 t s4 b6 s7 g :: Float# -> Double# -> Double# -> Int# -> Float# -> Double# -> Bool -> Float# -> Double# -> Float# - -> Int# + -> Int# g s2 b3 b5 i42 s8 b1 t s4 b6 s7 - -- powers of 2 backwards, then others forwards - = h s7 b6 t b5 s2 b3 i42 s8 b1 s4 + -- powers of 2 backwards, then others forwards + = h s7 b6 t b5 s2 b3 i42 s8 b1 s4 h :: Float# -> Double# -> Bool -> Double# -> Float# -> Double# -> Int# -> Float# -> Double# -> Float# - -> Int# + -> Int# h s7 b6 t b5 s2 b3 i42 s8 b1 s4 - = i42 + = i42 diff --git a/testsuite/tests/codeGen/should_run/cgrun013.hs b/testsuite/tests/codeGen/should_run/cgrun013.hs index 4d2f06de6c..7043fe0a82 100644 --- a/testsuite/tests/codeGen/should_run/cgrun013.hs +++ b/testsuite/tests/codeGen/should_run/cgrun013.hs @@ -7,72 +7,72 @@ Date: Wed, 23 Oct 91 16:19:46 BST module Main where class Foo a where - o1 :: a -> a -> Bool - o2 :: a -> Int + o1 :: a -> a -> Bool + o2 :: a -> Int --- o2 :: Int +-- o2 :: Int -- Lennart: The type of method o2 does not contain the variable a -- (and it must according to line 1 page 29 of the manual). class Foo tyvar => Bar tyvar where - o3 :: a -> tyvar -> tyvar + o3 :: a -> tyvar -> tyvar -- class (Eq a, Foo a) => Baz a where class (Ord a, Foo a) => Baz a where - o4 :: a -> a -> (String,String,String,a) + o4 :: a -> a -> (String,String,String,a) instance (Ord a, Foo a) => Foo [a] where - o2 x = 100 - o1 a b = a < b || o1 (head a) (head b) + o2 x = 100 + o1 a b = a < b || o1 (head a) (head b) -- instance Bar [a] where instance (Ord a, Foo a) => Bar [a] where - o3 x l = [] + o3 x l = [] -- - -- Lennart: I guess the instance declaration - -- instance Bar [w] where - -- o3 x l = [] + -- Lennart: I guess the instance declaration + -- instance Bar [w] where + -- o3 x l = [] -- is wrong because to be a Bar you have to be a Foo. For [w] to -- be a Foo, w has to be Ord and Foo. But w is not Ord or Foo in -- this instance declaration so it must be wrong. (Page 31, line -- 7: The context c' must imply ...) instance Baz a => Baz [a] where - o4 [] [] = ("Nil", "Nil", "Nil", []) - o4 l1 l2 = - (if o1 l1 l2 then "Y" else "N", - if l1 == l2 then "Y" else "N", --- if o4 (head l1) (head l2) then "Y" else "N", - case o4 (head l1) (head l2) of - (_,_,_,l3) -> if (o1 (head l1) l3) then "Y" else "N", - l1 ++ l2 ) + o4 [] [] = ("Nil", "Nil", "Nil", []) + o4 l1 l2 = + (if o1 l1 l2 then "Y" else "N", + if l1 == l2 then "Y" else "N", +-- if o4 (head l1) (head l2) then "Y" else "N", + case o4 (head l1) (head l2) of + (_,_,_,l3) -> if (o1 (head l1) l3) then "Y" else "N", + l1 ++ l2 ) instance Foo Int where - o2 x = x - o1 i j = i == j + o2 x = x + o1 i j = i == j instance Bar Int where - o3 _ j = j + 1 + o3 _ j = j + 1 instance Baz Int where --- o4 i j = i > j - o4 i j = (if i>j then "Y" else "Z", "p", "q", i+j) +-- o4 i j = i > j + o4 i j = (if i>j then "Y" else "Z", "p", "q", i+j) --simpl:o4 i j = ("Z", "p", "q", i+j) {- also works w/ glhc! -} main = if o4 [1,2,3] [1,3,2::Int] /= ("Y","N","Y",[1,2,3,1,3,2]) then - (print "43\n") - else (print "144\n") + (print "43\n") + else (print "144\n") {- works: glhc main = case o4 [1,2,3] [1,3,2::Int] of - (s1,s2,s3,x) -> print s1 + (s1,s2,s3,x) -> print s1 main = case o4 ([]::[Int]) ([]::[Int]) of - (s1,s2,s3,x) -> print s1 + (s1,s2,s3,x) -> print s1 -} -{- simple main: breaks nhc, works w/ glhc +{- simple main: breaks nhc, works w/ glhc main = case o4 (3::Int) (4::Int) of (s1,s2,s3,x) -> print s1 -} diff --git a/testsuite/tests/codeGen/should_run/cgrun015.hs b/testsuite/tests/codeGen/should_run/cgrun015.hs index 4263c4b1b6..e60e46faf4 100644 --- a/testsuite/tests/codeGen/should_run/cgrun015.hs +++ b/testsuite/tests/codeGen/should_run/cgrun015.hs @@ -9,20 +9,20 @@ data CList = CNil | CCons Int# CList mk :: Int# -> CList mk n = if isTrue# (n ==# 0#) - then CNil - else CCons 1# (mk (n -# 1#)) + then CNil + else CCons 1# (mk (n -# 1#)) clen :: CList -> Int# clen CNil = 0# clen (CCons _ cl) = 1# +# (clen cl) main = case (clen list4) of - len4 -> - case (len4 +# len4) of - 8# -> finish 65# -- 'A' - _ -> finish 66# -- 'B' + len4 -> + case (len4 +# len4) of + 8# -> finish 65# -- 'A' + _ -> finish 66# -- 'B' where - list4 = mk 4# + list4 = mk 4# finish :: Int# -> IO () finish n = c_putchar (castCharToCChar (C# (chr# n))) >> return () diff --git a/testsuite/tests/codeGen/should_run/cgrun017.hs b/testsuite/tests/codeGen/should_run/cgrun017.hs index 275eb9b31b..749d20858d 100644 --- a/testsuite/tests/codeGen/should_run/cgrun017.hs +++ b/testsuite/tests/codeGen/should_run/cgrun017.hs @@ -29,5 +29,5 @@ instance Foo a => Foo [a] where -- try it: main = do putStr (show (op2 (3::Int) 3.14159)) - putStr (show (op2 'X' 3.14159)) + putStr (show (op2 'X' 3.14159)) putStr (show (op2 ([]::[Char])3.14159)) diff --git a/testsuite/tests/codeGen/should_run/cgrun018.hs b/testsuite/tests/codeGen/should_run/cgrun018.hs index 49f9800cb6..76669ec6b7 100644 --- a/testsuite/tests/codeGen/should_run/cgrun018.hs +++ b/testsuite/tests/codeGen/should_run/cgrun018.hs @@ -19,7 +19,7 @@ xxx = (Tfo (-0.8143#) (-0.5091#) (-0.2788#) (1.5227#) (6.9114#) (-7.0765#)) selectee1 = F# (case xxx of - Tfo _ _ _ _ _ _ _ x _ _ _ _ -> x) + Tfo _ _ _ _ _ _ _ x _ _ _ _ -> x) selectee2 = F# (case xxx of - Tfo _ _ y _ _ _ _ _ _ _ _ _ -> y) + Tfo _ _ y _ _ _ _ _ _ _ _ _ -> y) diff --git a/testsuite/tests/codeGen/should_run/cgrun021.hs b/testsuite/tests/codeGen/should_run/cgrun021.hs index 190f8dd155..bf7b404652 100644 --- a/testsuite/tests/codeGen/should_run/cgrun021.hs +++ b/testsuite/tests/codeGen/should_run/cgrun021.hs @@ -1,5 +1,5 @@ -- !!! Tests garbage collection in the branch of a case --- !!! alternative where the constructor is returned in the heap. +-- !!! alternative where the constructor is returned in the heap. {- This is also a rather stressful test for another reason. The mutual recursion between munch and f causes lots of @@ -10,7 +10,7 @@ As it turns out, they are mostly garbage, so the GC could eliminate them (though this isn't implemented at present), but that isn't - necessarily the case. + necessarily the case. The only correct solution is to spot that the updates are all updating with the same value (update frames stacked on top of each @@ -47,8 +47,8 @@ munch n Empty = return () -- error "this never happens!\n" munch 0 _ = putStr "I succeeded!\n" munch n s = case (f n s) of - (True, rest) -> rest - (False, _) -> error "this never happens either\n" + (True, rest) -> rest + (False, _) -> error "this never happens either\n" --f :: Int -> Stream a -> (Bool, [Request]) diff --git a/testsuite/tests/codeGen/should_run/cgrun022.hs b/testsuite/tests/codeGen/should_run/cgrun022.hs index e69675431c..d6f92bea0b 100644 --- a/testsuite/tests/codeGen/should_run/cgrun022.hs +++ b/testsuite/tests/codeGen/should_run/cgrun022.hs @@ -4,7 +4,7 @@ module Main where main = f (putStr "a") - (take 1000000 (repeat True)) - (putStr "b") + (take 1000000 (repeat True)) + (putStr "b") f a ns b = if last ns then a else b diff --git a/testsuite/tests/codeGen/should_run/cgrun026.hs b/testsuite/tests/codeGen/should_run/cgrun026.hs index a9dd570759..52dc9f43f3 100644 --- a/testsuite/tests/codeGen/should_run/cgrun026.hs +++ b/testsuite/tests/codeGen/should_run/cgrun026.hs @@ -5,7 +5,7 @@ module Main ( main ) where import GHC.Exts -import Data.Char ( chr ) +import Data.Char ( chr ) import Control.Monad.ST import Data.Array.ST @@ -14,12 +14,12 @@ import Data.Array.Unboxed import Data.Ratio main = putStr - (test_chars ++ "\n" ++ - test_ints ++ "\n" ++ - test_addrs ++ "\n" ++ - test_floats ++ "\n" ++ - test_doubles ++ "\n" ++ - test_ptrs ++ "\n") + (test_chars ++ "\n" ++ + test_ints ++ "\n" ++ + test_addrs ++ "\n" ++ + test_floats ++ "\n" ++ + test_doubles ++ "\n" ++ + test_ptrs ++ "\n") -- Arr# Char# ------------------------------------------- @@ -29,36 +29,36 @@ test_chars :: String test_chars = let arr# = f 1000 in - shows (lookup_range arr# 42# 416#) "\n" + shows (lookup_range arr# 42# 416#) "\n" where f :: Int -> UArray Int Char f size@(I# size#) = runST ( - -- allocate an array of the specified size - newArray_ (0, (size-1)) >>= \ arr# -> + -- allocate an array of the specified size + newArray_ (0, (size-1)) >>= \ arr# -> - -- fill in all elements; elem i has "i" put in it - fill_in arr# 0# (size# -# 1#) >> + -- fill in all elements; elem i has "i" put in it + fill_in arr# 0# (size# -# 1#) >> - -- freeze the puppy: - freeze arr# - ) + -- freeze the puppy: + freeze arr# + ) fill_in :: STUArray s Int Char -> Int# -> Int# -> ST s () fill_in arr_in# first# last# = if isTrue# (first# ># last#) - then return () - else writeArray arr_in# (I# first#) ((chr (I# first#))) >> - fill_in arr_in# (first# +# 1#) last# + then return () + else writeArray arr_in# (I# first#) ((chr (I# first#))) >> + fill_in arr_in# (first# +# 1#) last# lookup_range :: UArray Int Char -> Int# -> Int# -> [Char] lookup_range arr from# to# = if isTrue# (from# ># to#) - then [] - else (arr ! (I# from#)) - : (lookup_range arr (from# +# 1#) to#) + then [] + else (arr ! (I# from#)) + : (lookup_range arr (from# +# 1#) to#) -- Arr# Int# ------------------------------------------- @@ -66,36 +66,36 @@ test_ints :: String test_ints = let arr# = f 1000 in - shows (lookup_range arr# 42# 416#) "\n" + shows (lookup_range arr# 42# 416#) "\n" where f :: Int -> UArray Int Int f size@(I# size#) = runST ( - -- allocate an array of the specified size - newArray_ (0, (size-1)) >>= \ arr# -> + -- allocate an array of the specified size + newArray_ (0, (size-1)) >>= \ arr# -> - -- fill in all elements; elem i has i^2 put in it - fill_in arr# 0# (size# -# 1#) >> + -- fill in all elements; elem i has i^2 put in it + fill_in arr# 0# (size# -# 1#) >> - -- freeze the puppy: - freeze arr# - ) + -- freeze the puppy: + freeze arr# + ) fill_in :: STUArray s Int Int -> Int# -> Int# -> ST s () fill_in arr_in# first# last# = if isTrue# (first# ># last#) - then return () - else writeArray arr_in# (I# first#) (I# (first# *# first#)) >> - fill_in arr_in# (first# +# 1#) last# + then return () + else writeArray arr_in# (I# first#) (I# (first# *# first#)) >> + fill_in arr_in# (first# +# 1#) last# lookup_range :: UArray Int Int -> Int# -> Int# -> [Int] lookup_range arr from# to# = if isTrue# (from# ># to#) - then [] - else (arr ! (I# from#)) - : (lookup_range arr (from# +# 1#) to#) + then [] + else (arr ! (I# from#)) + : (lookup_range arr (from# +# 1#) to#) -- Arr# Addr# ------------------------------------------- @@ -103,40 +103,40 @@ test_addrs :: String test_addrs = let arr# = f 1000 in - shows (lookup_range arr# 42# 416#) "\n" + shows (lookup_range arr# 42# 416#) "\n" where f :: Int -> UArray Int (Ptr ()) f size@(I# size#) = runST ( - -- allocate an array of the specified size - newArray_ (0, (size-1)) >>= \ arr# -> + -- allocate an array of the specified size + newArray_ (0, (size-1)) >>= \ arr# -> - -- fill in all elements; elem i has i^2 put in it - fill_in arr# 0# (size# -# 1#) >> + -- fill in all elements; elem i has i^2 put in it + fill_in arr# 0# (size# -# 1#) >> - -- freeze the puppy: - freeze arr# - ) + -- freeze the puppy: + freeze arr# + ) fill_in :: STUArray s Int (Ptr ()) -> Int# -> Int# -> ST s () fill_in arr_in# first# last# = if isTrue# (first# ># last#) - then return () - else writeArray arr_in# (I# first#) - (Ptr (int2Addr# (first# *# first#))) >> - fill_in arr_in# (first# +# 1#) last# + then return () + else writeArray arr_in# (I# first#) + (Ptr (int2Addr# (first# *# first#))) >> + fill_in arr_in# (first# +# 1#) last# lookup_range :: UArray Int (Ptr ()) -> Int# -> Int# -> [ Int ] lookup_range arr from# to# = let - a2i (Ptr a#) = I# (addr2Int# a#) - in - if isTrue# (from# ># to#) - then [] - else (a2i (arr ! (I# from#))) - : (lookup_range arr (from# +# 1#) to#) + a2i (Ptr a#) = I# (addr2Int# a#) + in + if isTrue# (from# ># to#) + then [] + else (a2i (arr ! (I# from#))) + : (lookup_range arr (from# +# 1#) to#) -- Arr# Float# ------------------------------------------- @@ -144,40 +144,40 @@ test_floats :: String test_floats = let arr# = f 1000 in - shows (lookup_range arr# 42# 416#) "\n" + shows (lookup_range arr# 42# 416#) "\n" where f :: Int -> UArray Int Float f size@(I# size#) = runST ( - -- allocate an array of the specified size - newArray_ (0, (size-1)) >>= \ arr# -> + -- allocate an array of the specified size + newArray_ (0, (size-1)) >>= \ arr# -> - -- fill in all elements; elem i has "i * pi" put in it - fill_in arr# 0# (size# -# 1#) >> + -- fill in all elements; elem i has "i * pi" put in it + fill_in arr# 0# (size# -# 1#) >> - -- freeze the puppy: - freeze arr# - ) + -- freeze the puppy: + freeze arr# + ) fill_in :: STUArray s Int Float -> Int# -> Int# -> ST s () fill_in arr_in# first# last# = if isTrue# (first# ># last#) - then return () -{- else let e = ((fromIntegral (I# first#)) * pi) - in trace (show e) $ writeFloatArray arr_in# (I# first#) e >> - fill_in arr_in# (first# +# 1#) last# + then return () +{- else let e = ((fromIntegral (I# first#)) * pi) + in trace (show e) $ writeFloatArray arr_in# (I# first#) e >> + fill_in arr_in# (first# +# 1#) last# -} - else writeArray arr_in# (I# first#) ((fromIntegral (I# first#)) * pi) >> - fill_in arr_in# (first# +# 1#) last# + else writeArray arr_in# (I# first#) ((fromIntegral (I# first#)) * pi) >> + fill_in arr_in# (first# +# 1#) last# lookup_range :: UArray Int Float -> Int# -> Int# -> [Float] lookup_range arr from# to# = if isTrue# (from# ># to#) - then [] - else (arr ! (I# from#)) - : (lookup_range arr (from# +# 1#) to#) + then [] + else (arr ! (I# from#)) + : (lookup_range arr (from# +# 1#) to#) -- Arr# Double# ------------------------------------------- @@ -185,36 +185,36 @@ test_doubles :: String test_doubles = let arr# = f 1000 in - shows (lookup_range arr# 42# 416#) "\n" + shows (lookup_range arr# 42# 416#) "\n" where f :: Int -> UArray Int Double f size@(I# size#) = runST ( - -- allocate an array of the specified size - newArray_ (0, (size-1)) >>= \ arr# -> + -- allocate an array of the specified size + newArray_ (0, (size-1)) >>= \ arr# -> - -- fill in all elements; elem i has "i * pi" put in it - fill_in arr# 0# (size# -# 1#) >> + -- fill in all elements; elem i has "i * pi" put in it + fill_in arr# 0# (size# -# 1#) >> - -- freeze the puppy: - freeze arr# - ) + -- freeze the puppy: + freeze arr# + ) fill_in :: STUArray s Int Double -> Int# -> Int# -> ST s () fill_in arr_in# first# last# = if isTrue# (first# ># last#) - then return () - else writeArray arr_in# (I# first#) ((fromIntegral (I# first#)) * pi) >> - fill_in arr_in# (first# +# 1#) last# + then return () + else writeArray arr_in# (I# first#) ((fromIntegral (I# first#)) * pi) >> + fill_in arr_in# (first# +# 1#) last# lookup_range :: UArray Int Double -> Int# -> Int# -> [Double] lookup_range arr from# to# = if isTrue# (from# ># to#) - then [] - else (arr ! (I# from#)) - : (lookup_range arr (from# +# 1#) to#) + then [] + else (arr ! (I# from#)) + : (lookup_range arr (from# +# 1#) to#) -- Arr# (Ratio Int) (ptrs) --------------------------------- -- just like Int# test @@ -223,28 +223,28 @@ test_ptrs :: String test_ptrs = let arr# = f 1000 in - shows (lookup_range arr# 42 416) "\n" + shows (lookup_range arr# 42 416) "\n" where f :: Int -> Array Int (Ratio Int) f size = runST ( - newArray (1, size) (3 % 5) >>= \ arr# -> - -- don't fill in the whole thing - fill_in arr# 1 400 >> - freeze arr# - ) + newArray (1, size) (3 % 5) >>= \ arr# -> + -- don't fill in the whole thing + fill_in arr# 1 400 >> + freeze arr# + ) fill_in :: STArray s Int (Ratio Int) -> Int -> Int -> ST s () fill_in arr_in# first last = if (first > last) - then return () - else writeArray arr_in# first (fromIntegral (first * first)) >> - fill_in arr_in# (first + 1) last + then return () + else writeArray arr_in# first (fromIntegral (first * first)) >> + fill_in arr_in# (first + 1) last lookup_range :: Array Int (Ratio Int) -> Int -> Int -> [Ratio Int] lookup_range array from too = if (from > too) - then [] - else (array ! from) : (lookup_range array (from + 1) too) + then [] + else (array ! from) : (lookup_range array (from + 1) too) diff --git a/testsuite/tests/codeGen/should_run/cgrun027.hs b/testsuite/tests/codeGen/should_run/cgrun027.hs index 646d05c38b..bf3183e509 100644 --- a/testsuite/tests/codeGen/should_run/cgrun027.hs +++ b/testsuite/tests/codeGen/should_run/cgrun027.hs @@ -4,7 +4,7 @@ class (Num a, Integral a) => Foo a main = putStr (shows (f ((fromInteger 21)::Int) - ((fromInteger 37))) "\n") + ((fromInteger 37))) "\n") instance Foo Int diff --git a/testsuite/tests/codeGen/should_run/cgrun031.hs b/testsuite/tests/codeGen/should_run/cgrun031.hs index 2a2c7a9b64..259697d961 100644 --- a/testsuite/tests/codeGen/should_run/cgrun031.hs +++ b/testsuite/tests/codeGen/should_run/cgrun031.hs @@ -19,8 +19,8 @@ prog :: Int -> Int -> Int prog size_1 size_2 = let - list1 = static1 : (map mk_foo [1 .. size_1]) - list2 = static2 : (map mk_foo [1 .. size_2]) + list1 = static1 : (map mk_foo [1 .. size_1]) + list2 = static2 : (map mk_foo [1 .. size_2]) in I# (add_up 0# list1 (reverse list2)) diff --git a/testsuite/tests/codeGen/should_run/cgrun033.hs b/testsuite/tests/codeGen/should_run/cgrun033.hs index 6e4a0b9a9d..3cdf176c91 100644 --- a/testsuite/tests/codeGen/should_run/cgrun033.hs +++ b/testsuite/tests/codeGen/should_run/cgrun033.hs @@ -9,10 +9,10 @@ main = putStr (shows true_or_false "\n") where true_or_false = case (cmp_name True imp1 imp2) of - -1# -> False - 0# -> True - 1# -> False - + -1# -> False + 0# -> True + 1# -> False + imp1 = Imp s "Imp1" s s imp2 = Imp s "Imp2" s s @@ -36,17 +36,17 @@ cmp_name False (Imp m1 n1 _ _) (Imp m2 n2 _ _) = case cmpString n1 n2 of { -1# -> -1#; 0# -> case cmpString m1 m2 of { - 0# -> 0#; - xxx -> if null m1 || null m2 - then 0# - else xxx - }; + 0# -> 0#; + xxx -> if null m1 || null m2 + then 0# + else xxx + }; _ -> 1# } cmp_name True (Imp _ _ _ o1) (Prel nm) = let - (_, n2) = getOrigName nm + (_, n2) = getOrigName nm in cmpString o1 n2 @@ -61,15 +61,15 @@ cmp_name by_local other_p1 other_p2 _ -> -1# data ProtoName - = Unk String -- local name in module + = Unk String -- local name in module - | Imp String -- name of defining module - String -- name used in defining name - String -- name of the module whose interface told me - -- about this thing - String -- occurrence name + | Imp String -- name of defining module + String -- name used in defining name + String -- name of the module whose interface told me + -- about this thing + String -- occurrence name - | Prel String{-Name-} + | Prel String{-Name-} cmpString, cmpName :: String -> String -> Int# cmpString a b = 0# diff --git a/testsuite/tests/codeGen/should_run/cgrun034.hs b/testsuite/tests/codeGen/should_run/cgrun034.hs index 0f7f05297e..4975e8df2d 100644 --- a/testsuite/tests/codeGen/should_run/cgrun034.hs +++ b/testsuite/tests/codeGen/should_run/cgrun034.hs @@ -3,17 +3,17 @@ import Data.Ratio -- 1.3 main = putStr ( shows tinyFloat ( '\n' - : shows t_f ( '\n' + : shows t_f ( '\n' : shows hugeFloat ( '\n' - : shows h_f ( '\n' + : shows h_f ( '\n' : shows tinyDouble ( '\n' - : shows t_d ( '\n' + : shows t_d ( '\n' : shows hugeDouble ( '\n' - : shows h_d ( '\n' - : shows x_f ( '\n' - : shows x_d ( '\n' - : shows y_f ( '\n' - : shows y_d ( "\n" + : shows h_d ( '\n' + : shows x_f ( '\n' + : shows x_d ( '\n' + : shows y_f ( '\n' + : shows y_d ( "\n" ))))))))))))) where t_f :: Float @@ -35,48 +35,48 @@ main = putStr ( fromRationalX :: (RealFloat a) => Rational -> a fromRationalX r = - let - h = ceiling (huge `asTypeOf` x) - b = toInteger (floatRadix x) - x = fromRat 0 r - fromRat e0 r' = - let d = denominator r' - n = numerator r' - in if d > h then - let e = integerLogBase b (d `div` h) + 1 - in fromRat (e0-e) (n % (d `div` (b^e))) - else if abs n > h then - let e = integerLogBase b (abs n `div` h) + 1 - in fromRat (e0+e) ((n `div` (b^e)) % d) - else - scaleFloat e0 (rationalToRealFloat {-fromRational-} r') - in x + let + h = ceiling (huge `asTypeOf` x) + b = toInteger (floatRadix x) + x = fromRat 0 r + fromRat e0 r' = + let d = denominator r' + n = numerator r' + in if d > h then + let e = integerLogBase b (d `div` h) + 1 + in fromRat (e0-e) (n % (d `div` (b^e))) + else if abs n > h then + let e = integerLogBase b (abs n `div` h) + 1 + in fromRat (e0+e) ((n `div` (b^e)) % d) + else + scaleFloat e0 (rationalToRealFloat {-fromRational-} r') + in x {- fromRationalX r = rationalToRealFloat r {- Hmmm... - let - h = ceiling (huge `asTypeOf` x) - b = toInteger (floatRadix x) - x = fromRat 0 r - - fromRat e0 r' = -{--} trace (shows e0 ('/' : shows r' ('/' : shows h "\n"))) ( - let d = denominator r' - n = numerator r' - in if d > h then - let e = integerLogBase b (d `div` h) + 1 - in fromRat (e0-e) (n % (d `div` (b^e))) - else if abs n > h then - let e = integerLogBase b (abs n `div` h) + 1 - in fromRat (e0+e) ((n `div` (b^e)) % d) - else - scaleFloat e0 (rationalToRealFloat r') - -- now that we know things are in-bounds, - -- we use the "old" Prelude code. -{--} ) - in x + let + h = ceiling (huge `asTypeOf` x) + b = toInteger (floatRadix x) + x = fromRat 0 r + + fromRat e0 r' = +{--} trace (shows e0 ('/' : shows r' ('/' : shows h "\n"))) ( + let d = denominator r' + n = numerator r' + in if d > h then + let e = integerLogBase b (d `div` h) + 1 + in fromRat (e0-e) (n % (d `div` (b^e))) + else if abs n > h then + let e = integerLogBase b (abs n `div` h) + 1 + in fromRat (e0+e) ((n `div` (b^e)) % d) + else + scaleFloat e0 (rationalToRealFloat r') + -- now that we know things are in-bounds, + -- we use the "old" Prelude code. +{--} ) + in x -} -} @@ -88,11 +88,11 @@ integerLogBase b i = if i < b then 0 else - -- Try squaring the base first to cut down the number of divisions. + -- Try squaring the base first to cut down the number of divisions. let l = 2 * integerLogBase (b*b) i - doDiv :: Integer -> Int -> Int - doDiv i l = if i < b then l else doDiv (i `div` b) (l+1) - in doDiv (i `div` (b^l)) l + doDiv :: Integer -> Int -> Int + doDiv i l = if i < b then l else doDiv (i `div` b) (l+1) + in doDiv (i `div` (b^l)) l ------------ @@ -100,16 +100,16 @@ integerLogBase b i = -- Compute smallest and largest floating point values. tiny :: (RealFloat a) => a tiny = - let (l, _) = floatRange x - x = encodeFloat 1 (l-1) - in x + let (l, _) = floatRange x + x = encodeFloat 1 (l-1) + in x huge :: (RealFloat a) => a huge = - let (_, u) = floatRange x - d = floatDigits x - x = encodeFloat (floatRadix x ^ d - 1) (u - d) - in x + let (_, u) = floatRange x + d = floatDigits x + x = encodeFloat (floatRadix x ^ d - 1) (u - d) + in x tinyDouble = tiny :: Double tinyFloat = tiny :: Float @@ -122,9 +122,9 @@ hugeFloat = huge :: Float A quite reasonable request! This code was added to the Prelude just before the 1.2 release, when Lennart, working with an early version of hbi, noticed that (read . show) was not the identity for -floating-point numbers. (There was a one-bit error about half the time.) +floating-point numbers. (There was a one-bit error about half the time.) The original version of the conversion function was in fact simply -a floating-point divide, as you suggest above. The new version is, +a floating-point divide, as you suggest above. The new version is, I grant you, somewhat denser. How's this? @@ -135,27 +135,27 @@ How's this? rationalToRealFloat :: (RealFloat a) => Rational -> a -rationalToRealFloat x = x' - where x' = f e - --- If the exponent of the nearest floating-point number to x --- is e, then the significand is the integer nearest xb^(-e), --- where b is the floating-point radix. We start with a good --- guess for e, and if it is correct, the exponent of the --- floating-point number we construct will again be e. If --- not, one more iteration is needed. - - f e = if e' == e then y else f e' - where y = encodeFloat (round (x * (1%b)^^e)) e - (_,e') = decodeFloat y - b = floatRadix x' - --- We obtain a trial exponent by doing a floating-point --- division of x's numerator by its denominator. The --- result of this division may not itself be the ultimate --- result, because of an accumulation of three rounding --- errors. - - (s,e) = decodeFloat (fromInteger (numerator x) `asTypeOf` x' - / fromInteger (denominator x)) +rationalToRealFloat x = x' + where x' = f e + +-- If the exponent of the nearest floating-point number to x +-- is e, then the significand is the integer nearest xb^(-e), +-- where b is the floating-point radix. We start with a good +-- guess for e, and if it is correct, the exponent of the +-- floating-point number we construct will again be e. If +-- not, one more iteration is needed. + + f e = if e' == e then y else f e' + where y = encodeFloat (round (x * (1%b)^^e)) e + (_,e') = decodeFloat y + b = floatRadix x' + +-- We obtain a trial exponent by doing a floating-point +-- division of x's numerator by its denominator. The +-- result of this division may not itself be the ultimate +-- result, because of an accumulation of three rounding +-- errors. + + (s,e) = decodeFloat (fromInteger (numerator x) `asTypeOf` x' + / fromInteger (denominator x)) diff --git a/testsuite/tests/codeGen/should_run/cgrun036.hs b/testsuite/tests/codeGen/should_run/cgrun036.hs index 40bfa74328..09d9e32008 100644 --- a/testsuite/tests/codeGen/should_run/cgrun036.hs +++ b/testsuite/tests/codeGen/should_run/cgrun036.hs @@ -10,7 +10,7 @@ g :: Int -> Int -> Int -> [Int] g x y z = let - f a b = a + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b - g c = f c c + f a b = a + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + b * a * b - a + a + b + g c = f c c in [g x, g y, g z, g x, g y, g z, g x, g y, g z, g x, g y, g z, g x, g y, g z, g x, g y, g z, g x, g y, g z, g x, g y, g z, g x, g y, g z, g x, g y, g z, g x, g y] diff --git a/testsuite/tests/codeGen/should_run/cgrun040.hs b/testsuite/tests/codeGen/should_run/cgrun040.hs index d747d4ab8b..6f34ac3910 100644 --- a/testsuite/tests/codeGen/should_run/cgrun040.hs +++ b/testsuite/tests/codeGen/should_run/cgrun040.hs @@ -1,7 +1,7 @@ module Main(main) where data Burble a = B1 { op1 :: a -> Int, op2 :: Int -> a, op3 :: Int} - | B2 { op2 :: Int -> a, op4 :: Int -> Int } + | B2 { op2 :: Int -> a, op4 :: Int -> Int } f1 :: Int -> Burble Int diff --git a/testsuite/tests/codeGen/should_run/cgrun047.hs b/testsuite/tests/codeGen/should_run/cgrun047.hs index 234c6671b6..8880814e78 100644 --- a/testsuite/tests/codeGen/should_run/cgrun047.hs +++ b/testsuite/tests/codeGen/should_run/cgrun047.hs @@ -1,14 +1,14 @@ module Main where --- GHC 4.04 +-- GHC 4.04 -- I've been having problems getting GHC to compile some code I'm working -- on with optimisation (-O) turned on. Compilation is fine without -O -- specified. Through a process of elimination I've managed to reproduce --- the problemin the following (much simpler) piece of code: +-- the problemin the following (much simpler) piece of code: import Data.List -test es = +test es = concat (groupBy eq (zip [0..(length es) - 1] es)) where eq a b = (fst a) == (fst b) diff --git a/testsuite/tests/codeGen/should_run/cgrun049.hs b/testsuite/tests/codeGen/should_run/cgrun049.hs index d4b6a77908..f74bffef07 100644 --- a/testsuite/tests/codeGen/should_run/cgrun049.hs +++ b/testsuite/tests/codeGen/should_run/cgrun049.hs @@ -11,12 +11,12 @@ g (MkT x _ _ _) = x data T = MkT Int !Int !(Int,Int) !(S Int) -data S a = MkS a a +data S a = MkS a a {-# NOINLINE f #-} -f :: T -> T -- Takes apart the thing and puts it - -- back together differently +f :: T -> T -- Takes apart the thing and puts it + -- back together differently f (MkT x y (a,b) (MkS p q)) = MkT a b (p,q) (MkS x y) diff --git a/testsuite/tests/codeGen/should_run/cgrun050.hs b/testsuite/tests/codeGen/should_run/cgrun050.hs index 7eb2cee05f..bbc3d11960 100644 --- a/testsuite/tests/codeGen/should_run/cgrun050.hs +++ b/testsuite/tests/codeGen/should_run/cgrun050.hs @@ -1,7 +1,7 @@ -- !! Test strict, recursive newtypes -- This test made a pre-5.02 fall over -- Reason: the seq arising from the !F didn't see that --- the represtation of F is a function. +-- the represtation of F is a function. -- NB It's crucial to compile this test *without* -O -- The $ then prevents the 'F' from seeing the '\x' @@ -9,8 +9,8 @@ module Main ( main ) where -newtype F = F (Int -> Val) -- NB: F and Val are -data Val = VFn !F | VInt !Int -- mutually recursive +newtype F = F (Int -> Val) -- NB: F and Val are +data Val = VFn !F | VInt !Int -- mutually recursive f :: Val -> Val f (VFn (F f)) = f 4 diff --git a/testsuite/tests/codeGen/should_run/cgrun051.hs b/testsuite/tests/codeGen/should_run/cgrun051.hs index c8ebb7f5e3..43787b5e2c 100644 --- a/testsuite/tests/codeGen/should_run/cgrun051.hs +++ b/testsuite/tests/codeGen/should_run/cgrun051.hs @@ -1,9 +1,9 @@ module Main where -data T1 -- No constructors +data T1 -- No constructors data T2 = T2 !T1 Int main = print (case (T2 (error "OK") 1) of { T2 x y -> y }) --- We should hit the (error "OK") case
\ No newline at end of file +-- We should hit the (error "OK") case diff --git a/testsuite/tests/codeGen/should_run/cgrun052.hs b/testsuite/tests/codeGen/should_run/cgrun052.hs index cfce05442f..d59f6bba83 100644 --- a/testsuite/tests/codeGen/should_run/cgrun052.hs +++ b/testsuite/tests/codeGen/should_run/cgrun052.hs @@ -9,5 +9,5 @@ f 0 = C3 (C1 T1) 42 f n = C3 (C1 T1) n main = case f 23 of - C3 y z -> case y of - C1 T1 -> putStrLn "ok" + C3 y z -> case y of + C1 T1 -> putStrLn "ok" diff --git a/testsuite/tests/codeGen/should_run/cgrun054.hs b/testsuite/tests/codeGen/should_run/cgrun054.hs index cff967e9bb..dd4d7c8e17 100644 --- a/testsuite/tests/codeGen/should_run/cgrun054.hs +++ b/testsuite/tests/codeGen/should_run/cgrun054.hs @@ -1,7 +1,7 @@ module Main where data Y = X1 | X2 | X3 | X4 | X5 | X6 | X7 | X8 - deriving( Show ) + deriving( Show ) data X = WithY Y | A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 @@ -19,8 +19,8 @@ foo (WithY _) = X1 bar :: X -> Y bar (WithY x) = x -bar y = foobar (foo y) -- The WithY case can't occur, and in an - -- earlier version that confused the code generator +bar y = foobar (foo y) -- The WithY case can't occur, and in an + -- earlier version that confused the code generator {-# NOINLINE foobar #-} foobar x = x diff --git a/testsuite/tests/codeGen/should_run/cgrun058.hs b/testsuite/tests/codeGen/should_run/cgrun058.hs index f0001584d1..9bdd551acf 100644 --- a/testsuite/tests/codeGen/should_run/cgrun058.hs +++ b/testsuite/tests/codeGen/should_run/cgrun058.hs @@ -25,6 +25,6 @@ myMul x y = tn ((ti x) * (ti y)) test = [ (x,y,ti (myMul (tn x) (tn y)),x * y) | x<-[-100, -99, -98, -97, -2, -1, 0, 1, 2, 97, 98, 99, 100], y<-([-100..(-1)]++[1..100]), - testi myMul (*) x y ] + testi myMul (*) x y ] main = print test |