Commit 0056c7fb authored by sof's avatar sof
Browse files

[project @ 1997-09-03 23:12:19 by sof]

Updated to run with 2.05
parent 272781d6
TOP = ../..
TOP = ..
include $(TOP)/mk/boilerplate.mk
SUBDIRS = cfd dcbm linsolv par001 pfib ray prsa soda soda7 coins minimax \
parfact bom NESL
include $(TOP)/nofib/mk/nofib.mk
include $(TOP)/mk/target.mk
......@@ -10,8 +10,8 @@
module GranRandom where
import Random (randomInts, randomDoubles, normalRandomDoubles) -- this requires -syslib hbc
import LibTime -- this requires -fhaskell-1.3
import PreludeGlaST -- this requires -fglasgow-exts
import Time -- this requires -fhaskell-1.3
import GlaExts -- this requires -fglasgow-exts
getRandIntList :: Int -> Int -> IO [Int]
......@@ -45,36 +45,27 @@ getNormalRandomDoubles bound = getRandInt 2147483561 >>= \ s1 ->
getRandInt :: Int -> IO Int
getRandInt bound =
getClockTime `thenPrimIO` \ t ->
return (
case t of
Left _ -> error "error in getClockTime"
Right b -> let
CalendarTime _ _ _ _ _ _ x _ _ _ _ _ = toCalendarTime b
in
((fromInteger x) `mod` bound) :: Int )
-- unwrapIO :: Either String b -> b
unwrapIO x = case x of
Left err -> error ("Error in unwrapIO: " ++ (show err))
Right x' -> x'
getClockTime >>= \ t ->
let
CalendarTime _ _ _ _ _ _ x _ _ _ _ _ = toCalendarTime b
in
return (((fromInteger x) `mod` bound) :: Int )
unsafeGetRandInt :: Int -> Int
unsafeGetRandInt = unwrapIO . unsafePerformPrimIO . getRandInt
unsafeGetRandInt = unsafePerformIO . getRandInt
unsafeGetRandIntList :: Int -> Int -> [Int]
unsafeGetRandIntList len bound =
let l = unsafePerformPrimIO ( getRandIntList len bound )
in unwrapIO l
unsafePerformIO ( getRandIntList len bound )
unsafeGetRandomInts :: Int -> [Int]
unsafeGetRandomInts = unwrapIO . unsafePerformPrimIO . getRandomInts
unsafeGetRandomInts = unsafePerformIO . getRandomInts
unsafeGetRandomDoubles :: Double -> [Double]
unsafeGetRandomDoubles = unwrapIO . unsafePerformPrimIO . getRandomDoubles
unsafeGetRandomDoubles = unsafePerformIO . getRandomDoubles
unsafeGetNormalRandomDoubles :: Double -> [Double]
unsafeGetNormalRandomDoubles = unwrapIO . unsafePerformPrimIO . getNormalRandomDoubles
unsafeGetNormalRandomDoubles = unsafePerformIO . getNormalRandomDoubles
-----------------------------------------------------------------------------
-- Converting the current system time into a stardate.
......@@ -84,11 +75,11 @@ unsafeGetNormalRandomDoubles = unwrapIO . unsafePerformPrimIO . getNormalRandomD
type Stardate = (Int, Int, Int)
unsafeGetStardate :: Int -> Stardate
unsafeGetStardate = unwrapIO . unsafePerformPrimIO . getStardate
unsafeGetStardate = unsafePerformIO . getStardate
getStardate :: Int -> IO Stardate
getStardate prec =
_casm_ ``%r = time((time_t *)0);'' `thenPrimIO` \ tm ->
_casm_ ``%r = time((time_t *)0);'' `thenIO_Prim` \ tm ->
let
(iss, int, frac) = stardate tm
in
......@@ -104,4 +95,4 @@ stardate tm = (issue, integer, fraction)
integer = int_rem
issue = int_quot - 36
#endif
\ No newline at end of file
#endif
......@@ -16,7 +16,7 @@ This example code does adaptive integration of single variable functions.
import Strategies
#endif
import LibSystem -- for getArgs
import System -- for getArgs
\end{code}
% ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %
......@@ -256,4 +256,4 @@ in
else integral2 $
function integrate2(func,a,b) = adaptive2(func,0,a,b);
\end{pseudocode}
\ No newline at end of file
\end{pseudocode}
......@@ -10,8 +10,8 @@
module GranRandom where
import Random (randomInts, randomDoubles, normalRandomDoubles) -- this requires -syslib hbc
import LibTime -- this requires -fhaskell-1.3
import PreludeGlaST -- this requires -fglasgow-exts
import Time -- this requires -fhaskell-1.3
import GlaExts -- this requires -fglasgow-exts
getRandIntList :: Int -> Int -> IO [Int]
......@@ -45,36 +45,27 @@ getNormalRandomDoubles bound = getRandInt 2147483561 >>= \ s1 ->
getRandInt :: Int -> IO Int
getRandInt bound =
getClockTime `thenPrimIO` \ t ->
return (
case t of
Left _ -> error "error in getClockTime"
Right b -> let
CalendarTime _ _ _ _ _ _ x _ _ _ _ _ = toCalendarTime b
in
((fromInteger x) `mod` bound) :: Int )
-- unwrapIO :: Either String b -> b
unwrapIO x = case x of
Left err -> error ("Error in unwrapIO: " ++ (show err))
Right x' -> x'
getClockTime >>= \ t ->
let
CalendarTime _ _ _ _ _ _ x _ _ _ _ _ = toCalendarTime b
in
return (((fromInteger x) `mod` bound) :: Int )
unsafeGetRandInt :: Int -> Int
unsafeGetRandInt = unwrapIO . unsafePerformPrimIO . getRandInt
unsafeGetRandInt = unsafePerformIO . getRandInt
unsafeGetRandIntList :: Int -> Int -> [Int]
unsafeGetRandIntList len bound =
let l = unsafePerformPrimIO ( getRandIntList len bound )
in unwrapIO l
unsafePerformIO ( getRandIntList len bound )
unsafeGetRandomInts :: Int -> [Int]
unsafeGetRandomInts = unwrapIO . unsafePerformPrimIO . getRandomInts
unsafeGetRandomInts = unsafePerformIO . getRandomInts
unsafeGetRandomDoubles :: Double -> [Double]
unsafeGetRandomDoubles = unwrapIO . unsafePerformPrimIO . getRandomDoubles
unsafeGetRandomDoubles = unsafePerformIO . getRandomDoubles
unsafeGetNormalRandomDoubles :: Double -> [Double]
unsafeGetNormalRandomDoubles = unwrapIO . unsafePerformPrimIO . getNormalRandomDoubles
unsafeGetNormalRandomDoubles = unsafePerformIO . getNormalRandomDoubles
-----------------------------------------------------------------------------
-- Converting the current system time into a stardate.
......@@ -84,11 +75,11 @@ unsafeGetNormalRandomDoubles = unwrapIO . unsafePerformPrimIO . getNormalRandomD
type Stardate = (Int, Int, Int)
unsafeGetStardate :: Int -> Stardate
unsafeGetStardate = unwrapIO . unsafePerformPrimIO . getStardate
unsafeGetStardate = unsafePerformIO . getStardate
getStardate :: Int -> IO Stardate
getStardate prec =
_casm_ ``%r = time((time_t *)0);'' `thenPrimIO` \ tm ->
_casm_ ``%r = time((time_t *)0);'' `thenIO_Prim` \ tm ->
let
(iss, int, frac) = stardate tm
in
......@@ -104,4 +95,4 @@ stardate tm = (issue, integer, fraction)
integer = int_rem
issue = int_quot - 36
#endif
\ No newline at end of file
#endif
......@@ -29,11 +29,10 @@ import Strategies
#if defined(IO13)
import GranRandom
import LibSystem (getArgs)
import System (getArgs)
#else
import PreludeGlaMisc
import PreludeGlaST
import PreludeGlaMonadicIO
import GlaExts
import ST
#endif
{------------------------------------------------------------------------------
......@@ -173,19 +172,19 @@ doQuery lo hi bomSize = strategy (map length explodeList)
result
# if defined(ARGS)
main = getArgs exit ( \[a1, a2, a3] ->
let lo = fst (head (readDec a1))
hi = fst (head (readDec a2))
bomSize = fst (head (readDec a3))
in
appendChan stdout (show (doQuery lo hi bomSize)) abort done
main = do
[a1,a2,a3] <- getArgs
let lo = fst (head (readDec a1))
hi = fst (head (readDec a2))
bomSize = fst (head (readDec a3))
print (doQuery lo hi bomSize)
)
# else
main = let lo = 70
hi = 90
bomSize = 100
in
appendChan stdout (show (doQuery lo hi bomSize)) abort done
print (doQuery lo hi bomSize)
# endif
#endif /* IO13 */
......@@ -26,11 +26,10 @@ import Strategies
#if defined(IO13)
import GranRandom
import LibSystem (getArgs)
import System (getArgs)
#else
import PreludeGlaMisc
import PreludeGlaST
import PreludeGlaMonadicIO
import GlaExts
import ST
#endif
{-
......
......@@ -22,11 +22,10 @@ import Strategies
#if defined(IO13)
import GranRandom
import LibSystem (getArgs)
import System (getArgs)
#else
import PreludeGlaMisc
import PreludeGlaST
import PreludeGlaMonadicIO
import GlaExts
import ST
#endif
{------------------------------------------------------------------------------
......@@ -181,4 +180,4 @@ main = let lo = 70
appendChan stdout (show (testChunk lo hi bomSize 3)) abort done
#endif
#endif /* IO13 */
\ No newline at end of file
#endif /* IO13 */
TOP = ../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
TOP = ../..
include $(TOP)/mk/boilerplate.mk
Primitives.hi : Primitives.lhi
cp $< $@
depend :: Primitives.hi
SRC_HC_OPTS += -cpp
include $(TOP)/mk/target.mk
......
Hand-generated interface file for the Primitives module.
eq determines whether two values are identical (the *same pointer*
as in Lisp). It does no evaluation, and errs on the side of safety.
boolval determines whether a Boolean expression is True, False or not
yet evaluated, returning TRUE, FALSE or UNKNOWN, respectively. Again,
it does not evaluate its argument.
\begin{code}
interface Primitives 1
__exports__
Primitives eq (..)
Primitives boolval (..)
__declarations__
Primitives.eq :: __forall__ [a] a -> a -> Prelude.Bool;
Primitives.boolval :: Prelude.Bool -> Types.BOOL;
\end{code}
--Hand-generated interface file for the Primitives module.
--
--eq determines whether two values are identical (the *same pointer*
--as in Lisp). It does no evaluation, and errs on the side of safety.
--
--boolval determines whether a Boolean expression is True, False or not
--yet evaluated, returning TRUE, FALSE or UNKNOWN, respectively. Again,
--it does not evaluate its argument.
--
_interface_ Primitives 1
_exports_
Primitives eq(..) boolval(..);
_declarations_
1 eq _:_ _forall_ [a] => a -> a -> PrelBase.Bool ;;
1 boolval _:_ PrelBase.Bool -> Types.BOOL ;;
TOP = ../../..
PROG = soda7
EXTRA_HCFLAGS = -cpp
include $(TOP)/nofib/mk/nofib.mk
TOP = ../..
include $(TOP)/mk/boilerplate.mk
SRC_HC_OPTS += -cpp
include $(TOP)/mk/target.mk
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment