Skip to content
Snippets Groups Projects
Commit 4dd68859 authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 1997-11-12 10:55:17 by simonm]

PrimIO/library changes
parent af646528
No related merge requests found
module GHCmain ( mainPrimIO ) where
module GHCmain ( mainIO ) where
import GlaExts
import PrelBase
data CList = CNil | CCons Int# CList
......@@ -14,7 +13,7 @@ clen :: CList -> Int#
clen CNil = 0#
clen (CCons _ cl) = 1# +# (clen cl)
mainPrimIO = case (clen list4) of
mainIO = case (clen list4) of
len4 ->
case (len4 +# len4) of
8# -> finish 65# -- 'A'
......@@ -22,5 +21,5 @@ mainPrimIO = case (clen list4) of
where
list4 = mk 4#
finish :: Int# -> PrimIO ()
finish n = _ccall_ putchar (C# (chr# n)) `seqPrimIO` returnPrimIO ()
finish :: Int# -> IO ()
finish n = _ccall_ putchar (C# (chr# n)) >> return ()
......@@ -3,8 +3,7 @@
--
import IO
import System
import IOBase (trace)
--import Trace ToDo: get this via GlaExts -- SOF
import IOExts (trace)
main = do
prog <- getProgName
......
......@@ -6,8 +6,7 @@
--
import IO
import System
import IOBase (trace)
--import Trace ToDo: get this via GlaExts -- SOF
import IOExts (trace)
main = do
prog <- getProgName
......
......@@ -2,12 +2,15 @@
--
module Main ( main ) where
import PrelBase --ghc1.3
import GlaExts
import PrelBase
import ST
import IOExts
import MutableArray
import ByteArray
import Addr
import Ratio -- 1.3
import Array -- 1.3
import Ratio
import Array
main = putStr
(test_chars ++ "\n" ++
......@@ -25,9 +28,9 @@ test_chars :: String
test_chars
= let str = reverse "Now is the time for all good men to come to...\n"
in
unsafePerformPrimIO (
unsafePerformIO (
_ccall_ fprintf (``stdout''::Addr) "%d %s\n" 93 str >>
returnPrimIO ""
return ""
)
-- Arr# Int# -------------------------------------------
......@@ -56,7 +59,7 @@ test_ints
fill_in arr_in# first# last#
= if (first# ># last#)
then returnST ()
then return ()
else writeIntArray arr_in# (I# first#) (I# (first# *# first#)) >>
fill_in arr_in# (first# +# 1#) last#
......@@ -93,7 +96,7 @@ test_addrs
fill_in arr_in# first# last#
= if (first# ># last#)
then returnST ()
then return ()
else writeAddrArray arr_in# (I# first#)
(A# (int2Addr# (first# *# first#))) >>
fill_in arr_in# (first# +# 1#) last#
......@@ -134,7 +137,7 @@ test_floats
fill_in arr_in# first# last#
= if (first# ># last#)
then returnST ()
then return ()
{- else let e = ((fromInt (I# first#)) * pi)
in trace (show e) $ writeFloatArray arr_in# (I# first#) e >>
fill_in arr_in# (first# +# 1#) last#
......@@ -175,7 +178,7 @@ test_doubles
fill_in arr_in# first# last#
= if (first# ># last#)
then returnST ()
then return ()
else writeDoubleArray arr_in# (I# first#) ((fromInt (I# first#)) * pi) >>
fill_in arr_in# (first# +# 1#) last#
......@@ -209,7 +212,7 @@ test_ptrs
fill_in arr_in# first last
= if (first > last)
then returnST ()
then return ()
else writeArray arr_in# first (fromInt (first * first)) >>
fill_in arr_in# (first + 1) last
......
......@@ -3,7 +3,6 @@ module Main(main) where
-- In 0.19, we lost the ability to do ccalls with more than 6 arguments
-- on the Sparc. Just to make sure it never happens again...
import GlaExts
main =
_ccall_ printf "Testing %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n"
......@@ -11,5 +10,5 @@ main =
(11::Int) (12::Int) (13::Int) (14::Int) (15::Int) (16::Int) (17::Int) (18::Int)
(21::Int) (22::Int) (23::Int) (24::Int) (25::Int) (26::Int) (27::Int) (28::Int)
(31::Int) (32::Int) (33::Int) (34::Int) (35::Int) (36::Int) (37::Int) (38::Int)
`thenIO_Prim` \ _ ->
>>
return ()
module Main (main) where
--import PreludeGlaST
import GlaExts
import IOExts ( unsafePerformIO )
po :: Double -> Double
po rd = 0.5 + 0.5 * erf ((rd / 1.04) / sqrt 2)
where
erf :: Double -> Double
erf x = unsafePerformPrimIO (_ccall_ erf x)
erf x = unsafePerformIO (_ccall_ erf x)
main = putStr (shows (po 2.0) "\n")
......@@ -3,7 +3,9 @@
module Main ( main ) where
import PrelBase --ghc1.3
import GlaExts
import IOExts
import ByteArray
import MutableArray
import ST
import Ratio -- 1.3
......@@ -37,7 +39,7 @@ test_doubles
fill_in arr_in# first# last#
= if (first# ># last#)
then returnST ()
then return ()
else writeDoubleArray arr_in# (I# first#) ((fromInt (I# first#)) * pi) >>
fill_in arr_in# (first# +# 1#) last#
......
......@@ -3,10 +3,8 @@
--!!! when converting CoreSyn.App)
module Main where
import GlaExts
getData :: String -> PrimIO ()
getData :: String -> IO ()
getData filename = case leng filename of {0 -> return ()}
leng :: String -> Int
leng [] = 0 --case ls of {[] -> 0 ; (_:xs) -> 1 + leng xs }
......@@ -16,6 +14,5 @@ f [] [] = []
f xs ys = f xs ys
main =
primIOToIO (
(return ()) >>= \ _ ->
case f [] [] of { [] -> getData [] })
return () >>= \ _ ->
case f [] [] of { [] -> getData [] }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment