Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Alex D
GHC
Commits
5b03dc69
Commit
5b03dc69
authored
Jun 18, 2016
by
thomie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testsuite: tabs > spaces [skip ci]
parent
915e07c3
Changes
64
Expand all
Hide whitespace changes
Inline
Sidebyside
Showing
64 changed files
with
892 additions
and
892 deletions
+892
892
libraries/base/tests/Memo1.lhs
libraries/base/tests/Memo1.lhs
+42
42
libraries/base/tests/Memo2.lhs
libraries/base/tests/Memo2.lhs
+42
42
testsuite/tests/concurrent/prog001/Arithmetic.hs
testsuite/tests/concurrent/prog001/Arithmetic.hs
+120
120
testsuite/tests/concurrent/prog001/Converter.hs
testsuite/tests/concurrent/prog001/Converter.hs
+63
63
testsuite/tests/concurrent/prog001/Mult.hs
testsuite/tests/concurrent/prog001/Mult.hs
+216
216
testsuite/tests/concurrent/prog001/Stream.hs
testsuite/tests/concurrent/prog001/Stream.hs
+67
67
testsuite/tests/concurrent/prog001/Thread.hs
testsuite/tests/concurrent/prog001/Thread.hs
+23
23
testsuite/tests/concurrent/prog001/Trit.hs
testsuite/tests/concurrent/prog001/Trit.hs
+28
28
testsuite/tests/concurrent/prog001/Utilities.hs
testsuite/tests/concurrent/prog001/Utilities.hs
+4
4
testsuite/tests/concurrent/prog002/Scheduler.hs
testsuite/tests/concurrent/prog002/Scheduler.hs
+15
15
testsuite/tests/concurrent/prog002/Server.hs
testsuite/tests/concurrent/prog002/Server.hs
+4
4
testsuite/tests/concurrent/should_run/T5421.hs
testsuite/tests/concurrent/should_run/T5421.hs
+8
8
testsuite/tests/concurrent/should_run/conc001.hs
testsuite/tests/concurrent/should_run/conc001.hs
+2
2
testsuite/tests/concurrent/should_run/conc002.hs
testsuite/tests/concurrent/should_run/conc002.hs
+3
3
testsuite/tests/concurrent/should_run/conc003.hs
testsuite/tests/concurrent/should_run/conc003.hs
+12
12
testsuite/tests/concurrent/should_run/conc004.hs
testsuite/tests/concurrent/should_run/conc004.hs
+4
4
testsuite/tests/concurrent/should_run/conc006.hs
testsuite/tests/concurrent/should_run/conc006.hs
+8
8
testsuite/tests/concurrent/should_run/conc010.hs
testsuite/tests/concurrent/should_run/conc010.hs
+3
3
testsuite/tests/concurrent/should_run/conc012.hs
testsuite/tests/concurrent/should_run/conc012.hs
+3
3
testsuite/tests/concurrent/should_run/conc014.hs
testsuite/tests/concurrent/should_run/conc014.hs
+2
2
testsuite/tests/concurrent/should_run/conc015.hs
testsuite/tests/concurrent/should_run/conc015.hs
+7
7
testsuite/tests/concurrent/should_run/conc015a.hs
testsuite/tests/concurrent/should_run/conc015a.hs
+9
9
testsuite/tests/concurrent/should_run/conc016.hs
testsuite/tests/concurrent/should_run/conc016.hs
+3
3
testsuite/tests/concurrent/should_run/conc017.hs
testsuite/tests/concurrent/should_run/conc017.hs
+19
19
testsuite/tests/concurrent/should_run/conc017a.hs
testsuite/tests/concurrent/should_run/conc017a.hs
+19
19
testsuite/tests/concurrent/should_run/conc018.hs
testsuite/tests/concurrent/should_run/conc018.hs
+5
5
testsuite/tests/concurrent/should_run/conc019.hs
testsuite/tests/concurrent/should_run/conc019.hs
+1
1
testsuite/tests/concurrent/should_run/conc022.hs
testsuite/tests/concurrent/should_run/conc022.hs
+12
12
testsuite/tests/concurrent/should_run/conc024.hs
testsuite/tests/concurrent/should_run/conc024.hs
+2
2
testsuite/tests/concurrent/should_run/conc025.hs
testsuite/tests/concurrent/should_run/conc025.hs
+7
7
testsuite/tests/concurrent/should_run/conc031.hs
testsuite/tests/concurrent/should_run/conc031.hs
+6
6
testsuite/tests/concurrent/should_run/conc033.hs
testsuite/tests/concurrent/should_run/conc033.hs
+1
1
testsuite/tests/concurrent/should_run/conc034.hs
testsuite/tests/concurrent/should_run/conc034.hs
+9
9
testsuite/tests/concurrent/should_run/conc035.hs
testsuite/tests/concurrent/should_run/conc035.hs
+6
6
testsuite/tests/concurrent/should_run/conc036.hs
testsuite/tests/concurrent/should_run/conc036.hs
+3
3
testsuite/tests/concurrent/should_run/conc038.hs
testsuite/tests/concurrent/should_run/conc038.hs
+2
2
testsuite/tests/concurrent/should_run/conc039.hs
testsuite/tests/concurrent/should_run/conc039.hs
+8
8
testsuite/tests/concurrent/should_run/conc068.hs
testsuite/tests/concurrent/should_run/conc068.hs
+1
1
testsuite/tests/deriving/should_compile/drv005.hs
testsuite/tests/deriving/should_compile/drv005.hs
+1
1
testsuite/tests/deriving/should_compile/drv006.hs
testsuite/tests/deriving/should_compile/drv006.hs
+1
1
testsuite/tests/deriving/should_compile/drv015.hs
testsuite/tests/deriving/should_compile/drv015.hs
+2
2
testsuite/tests/deriving/should_compile/drv020.hs
testsuite/tests/deriving/should_compile/drv020.hs
+7
7
testsuite/tests/deriving/should_fail/T4846.hs
testsuite/tests/deriving/should_fail/T4846.hs
+0
0
testsuite/tests/deriving/should_fail/drvfail001.hs
testsuite/tests/deriving/should_fail/drvfail001.hs
+6
6
testsuite/tests/deriving/should_fail/drvfail002.hs
testsuite/tests/deriving/should_fail/drvfail002.hs
+1
1
testsuite/tests/deriving/should_fail/drvfail006.hs
testsuite/tests/deriving/should_fail/drvfail006.hs
+2
2
testsuite/tests/deriving/should_fail/drvfail009.hs
testsuite/tests/deriving/should_fail/drvfail009.hs
+5
5
testsuite/tests/deriving/should_run/drvrun005.hs
testsuite/tests/deriving/should_run/drvrun005.hs
+6
6
testsuite/tests/deriving/should_run/drvrun006.hs
testsuite/tests/deriving/should_run/drvrun006.hs
+13
13
testsuite/tests/deriving/should_run/drvrun009.hs
testsuite/tests/deriving/should_run/drvrun009.hs
+4
4
testsuite/tests/deriving/should_run/drvrun010.hs
testsuite/tests/deriving/should_run/drvrun010.hs
+1
1
testsuite/tests/deriving/should_run/drvrun011.hs
testsuite/tests/deriving/should_run/drvrun011.hs
+4
4
testsuite/tests/deriving/should_run/drvrun013.hs
testsuite/tests/deriving/should_run/drvrun013.hs
+7
7
testsuite/tests/deriving/should_run/drvrun018.hs
testsuite/tests/deriving/should_run/drvrun018.hs
+1
1
testsuite/tests/deriving/should_run/drvrun020.hs
testsuite/tests/deriving/should_run/drvrun020.hs
+11
11
testsuite/tests/deriving/should_run/drvrun021.hs
testsuite/tests/deriving/should_run/drvrun021.hs
+6
6
testsuite/tests/th/T3920.hs
testsuite/tests/th/T3920.hs
+3
3
testsuite/tests/th/T4135.hs
testsuite/tests/th/T4135.hs
+3
3
testsuite/tests/th/T5379.hs
testsuite/tests/th/T5379.hs
+1
1
testsuite/tests/th/TH_exn1.hs
testsuite/tests/th/TH_exn1.hs
+1
1
testsuite/tests/th/TH_genExLib.hs
testsuite/tests/th/TH_genExLib.hs
+6
6
testsuite/tests/th/TH_repPrim.hs
testsuite/tests/th/TH_repPrim.hs
+4
4
testsuite/tests/th/TH_spliceE4.hs
testsuite/tests/th/TH_spliceE4.hs
+1
1
testsuite/tests/th/TH_tuple1.hs
testsuite/tests/th/TH_tuple1.hs
+6
6
No files found.
libraries/base/tests/Memo1.lhs
View file @
5b03dc69
...
...
@@ 7,16 +7,16 @@
\begin{code}
module Memo1
( memo
 :: (a > b) > a > b
, memoSized
 :: Int > (a > b) > a > b
)
where
import System.Mem.StableName
( StableName, makeStableName, hashStableName )
import System.Mem.Weak
( Weak, mkWeakPtr, mkWeak, deRefWeak, finalize )
import Data.Array.IO
( IOArray, newArray, readArray, writeArray )
import System.IO.Unsafe
( unsafePerformIO )
import Control.Concurrent.MVar
( MVar, newMVar, putMVar, takeMVar )
( memo
 :: (a > b) > a > b
, memoSized
 :: Int > (a > b) > a > b
)
where
import System.Mem.StableName
( StableName, makeStableName, hashStableName )
import System.Mem.Weak
( Weak, mkWeakPtr, mkWeak, deRefWeak, finalize )
import Data.Array.IO
( IOArray, newArray, readArray, writeArray )
import System.IO.Unsafe
( unsafePerformIO )
import Control.Concurrent.MVar
( MVar, newMVar, putMVar, takeMVar )
\end{code}

...
...
@@ 40,10 +40,10 @@ the documentation).
\begin{code}
type MemoTable key val
= MVar (
Int,
 current table size
IOArray Int [MemoEntry key val]  hash table
)
= MVar (
Int,
 current table size
IOArray Int [MemoEntry key val]  hash table
)
 a memo table entry: compile with funboxstrictfields to eliminate
 the boxes around the StableName and Weak fields.
...
...
@@ 76,19 +76,19 @@ strict = ($!)
lazyMemoSized :: Int > (a > b) > a > b
lazyMemoSized size f =
let (table,weak) = unsafePerformIO (
do { tbl < newArray (0,size) []
; mvar < newMVar (size,tbl)
; weak < mkWeakPtr mvar (Just (table_finalizer tbl size))
; return (mvar,weak)
})
do { tbl < newArray (0,size) []
; mvar < newMVar (size,tbl)
; weak < mkWeakPtr mvar (Just (table_finalizer tbl size))
; return (mvar,weak)
})
in memo' f table weak
table_finalizer :: IOArray Int [MemoEntry key val] > Int > IO ()
table_finalizer table size =
table_finalizer table size =
sequence_ [ finalizeBucket i  i < [0..size] ]
where
finalizeBucket i = do
bucket < readArray table i
bucket < readArray table i
sequence_ [ finalize w  MemoEntry _ w < bucket ]
memo' :: (a > b) > MemoTable a b > Weak (MemoTable a b) > a > b
...
...
@@ 101,35 +101,35 @@ memo' f ref weak_ref = \k > unsafePerformIO $ do
case lkp of
Just result > do
putMVar ref (size,table)
return result
putMVar ref (size,table)
return result
Nothing > do
let result = f k
weak < mkWeak k result (Just (finalizer hash_key stable_key weak_ref))
writeArray table hash_key (MemoEntry stable_key weak : bucket)
putMVar ref (size,table)
return result
let result = f k
weak < mkWeak k result (Just (finalizer hash_key stable_key weak_ref))
writeArray table hash_key (MemoEntry stable_key weak : bucket)
putMVar ref (size,table)
return result
finalizer :: Int > StableName a > Weak (MemoTable a b) > IO ()
finalizer hash_key stable_key weak_ref =
do r < deRefWeak weak_ref
finalizer hash_key stable_key weak_ref =
do r < deRefWeak weak_ref
case r of
Nothing > return ()
Just mvar > do
(size,table) < takeMVar mvar
bucket < readArray table hash_key
let new_bucket = [ e  e@(MemoEntry sn weak) < bucket,
sn /= stable_key ]
writeArray table hash_key new_bucket
putMVar mvar (size,table)
Nothing > return ()
Just mvar > do
(size,table) < takeMVar mvar
bucket < readArray table hash_key
let new_bucket = [ e  e@(MemoEntry sn weak) < bucket,
sn /= stable_key ]
writeArray table hash_key new_bucket
putMVar mvar (size,table)
lookupSN :: StableName key > [MemoEntry key val] > IO (Maybe val)
lookupSN sn [] = sn `seq` return Nothing  make it strict in sn
lookupSN sn (MemoEntry sn' weak : xs)
 sn == sn' = do maybe_item < deRefWeak weak
case maybe_item of
Nothing > error ("dead weak pair: " ++
show (hashStableName sn))
Just v > return (Just v)
case maybe_item of
Nothing > error ("dead weak pair: " ++
show (hashStableName sn))
Just v > return (Just v)
 otherwise = lookupSN sn xs
\end{code}
libraries/base/tests/Memo2.lhs
View file @
5b03dc69
...
...
@@ 7,16 +7,16 @@
\begin{code}
module Memo2
( memo
 :: (a > b) > a > b
, memoSized
 :: Int > (a > b) > a > b
)
where
import System.Mem.StableName
( StableName, makeStableName, hashStableName )
import System.Mem.Weak
( Weak, mkWeakPtr, mkWeak, deRefWeak, finalize )
import Data.Array.IO
( IOArray, newArray, readArray, writeArray )
import System.IO.Unsafe
( unsafePerformIO )
import Control.Concurrent.MVar
( MVar, newMVar, putMVar, takeMVar )
( memo
 :: (a > b) > a > b
, memoSized
 :: Int > (a > b) > a > b
)
where
import System.Mem.StableName
( StableName, makeStableName, hashStableName )
import System.Mem.Weak
( Weak, mkWeakPtr, mkWeak, deRefWeak, finalize )
import Data.Array.IO
( IOArray, newArray, readArray, writeArray )
import System.IO.Unsafe
( unsafePerformIO )
import Control.Concurrent.MVar
( MVar, newMVar, putMVar, takeMVar )
\end{code}

...
...
@@ 40,10 +40,10 @@ the documentation).
\begin{code}
type MemoTable key val
= MVar (
Int,
 current table size
IOArray Int [MemoEntry key val]  hash table
)
= MVar (
Int,
 current table size
IOArray Int [MemoEntry key val]  hash table
)
 a memo table entry: compile with funboxstrictfields to eliminate
 the boxes around the StableName and Weak fields.
...
...
@@ 76,19 +76,19 @@ strict = ($!)
lazyMemoSized :: Int > (a > b) > a > b
lazyMemoSized size f =
let (table,weak) = unsafePerformIO (
do { tbl < newArray (0,size) []
; mvar < newMVar (size,tbl)
; weak < mkWeakPtr mvar (Just (table_finalizer tbl size))
; return (mvar,weak)
})
do { tbl < newArray (0,size) []
; mvar < newMVar (size,tbl)
; weak < mkWeakPtr mvar (Just (table_finalizer tbl size))
; return (mvar,weak)
})
in memo' f table weak
table_finalizer :: IOArray Int [MemoEntry key val] > Int > IO ()
table_finalizer table size =
table_finalizer table size =
sequence_ [ finalizeBucket i  i < [0..size] ]
where
finalizeBucket i = do
bucket < readArray table i
bucket < readArray table i
sequence_ [ finalize w  MemoEntry _ w < bucket ]
memo' :: (a > b) > MemoTable a b > Weak (MemoTable a b) > a > b
...
...
@@ 101,35 +101,35 @@ memo' f ref weak_ref = \k > unsafePerformIO $ do
case lkp of
Just result > do
putMVar ref (size,table)
return result
putMVar ref (size,table)
return result
Nothing > do
let result = f k
weak < mkWeak k result (Just (finalizer hash_key stable_key weak_ref))
writeArray table hash_key (MemoEntry stable_key weak : bucket)
putMVar ref (size,table)
return result
let result = f k
weak < mkWeak k result (Just (finalizer hash_key stable_key weak_ref))
writeArray table hash_key (MemoEntry stable_key weak : bucket)
putMVar ref (size,table)
return result
finalizer :: Int > StableName a > Weak (MemoTable a b) > IO ()
finalizer hash_key stable_key weak_ref =
do r < deRefWeak weak_ref
finalizer hash_key stable_key weak_ref =
do r < deRefWeak weak_ref
case r of
Nothing > return ()
Just mvar > do
(size,table) < takeMVar mvar
bucket < readArray table hash_key
let new_bucket = [ e  e@(MemoEntry sn weak) < bucket,
sn /= stable_key ]
writeArray table hash_key new_bucket
putMVar mvar (size,table)
Nothing > return ()
Just mvar > do
(size,table) < takeMVar mvar
bucket < readArray table hash_key
let new_bucket = [ e  e@(MemoEntry sn weak) < bucket,
sn /= stable_key ]
writeArray table hash_key new_bucket
putMVar mvar (size,table)
lookupSN :: StableName key > [MemoEntry key val] > IO (Maybe val)
lookupSN sn [] = sn `seq` return Nothing  make it strict in sn
lookupSN sn (MemoEntry sn' weak : xs)
 sn == sn' = do maybe_item < deRefWeak weak
case maybe_item of
Nothing > error ("dead weak pair: " ++
show (hashStableName sn))
Just v > return (Just v)
case maybe_item of
Nothing > error ("dead weak pair: " ++
show (hashStableName sn))
Just v > return (Just v)
 otherwise = lookupSN sn xs
\end{code}
testsuite/tests/concurrent/prog001/Arithmetic.hs
View file @
5b03dc69
...
...
@@ 41,114 +41,114 @@ minusOne (1:xs) = 0:fl xs
threadTesting
::
Gray
>
Gray
>
IO
Int
threadTesting
xs
ys
=
do
m
<
newEmptyMVar
c1
<
forkIO
(
t1
m
xs
ys
)
c2
<
forkIO
(
t2
m
xs
ys
)
c3
<
forkIO
(
t3
m
xs
ys
)
c4
<
forkIO
(
t4
m
xs
ys
)
c5
<
forkIO
(
t5
m
xs
ys
)
c6
<
forkIO
(
t6
m
xs
ys
)
c
<
takeMVar
m
killThread
c1
killThread
c2
killThread
c3
killThread
c4
killThread
c5
killThread
c6
return
c
m
<
newEmptyMVar
c1
<
forkIO
(
t1
m
xs
ys
)
c2
<
forkIO
(
t2
m
xs
ys
)
c3
<
forkIO
(
t3
m
xs
ys
)
c4
<
forkIO
(
t4
m
xs
ys
)
c5
<
forkIO
(
t5
m
xs
ys
)
c6
<
forkIO
(
t6
m
xs
ys
)
c
<
takeMVar
m
killThread
c1
killThread
c2
killThread
c3
killThread
c4
killThread
c5
killThread
c6
return
c
addition
::
Gray
>
Gray
>
IO
Gray
addition
xs
ys
=
do
c
<
threadTesting
xs
ys
case
c
of
1
>
do
let
tx
=
tail
xs
let
ty
=
tail
ys
t
<
unsafeInterleaveIO
(
addition
tx
ty
)
return
(
0
:
t
)
2
>
do
let
tx
=
tail
xs
let
ty
=
tail
ys
t
<
unsafeInterleaveIO
(
addition
tx
ty
)
return
(
1
:
t
)
3
>
do
let
tx
=
tail
xs
let
ty
=
tail
ys
cs
<
unsafeInterleaveIO
(
addition
tx
(
fl
ty
))
let
c1
=
cs
!!
0
let
c2
=
tail
cs
return
(
c1
:
1
:
fl
c2
)
4
>
do
let
tx
=
tail
xs
let
ty
=
tail
ys
(
cs
)
<
unsafeInterleaveIO
(
addition
(
fl
tx
)
ty
)
let
c1
=
cs
!!
0
let
c2
=
tail
cs
return
(
c1
:
1
:
(
fl
c2
))
5
>
do
let
x1
=
xs
!!
0
let
y1
=
ys
!!
0
let
tx
=
(
drop
2
)
xs
let
ty
=
(
drop
2
)
ys
cs
<
unsafeInterleaveIO
(
addition
(
x1
:
(
fl
tx
))
(
y1
:
(
fl
ty
)))
let
c1
=
cs
!!
0
let
c2
=
tail
cs
return
(
c1
:
(
1
:
(
fl
c2
)))
6
>
do
let
x1
=
xs
!!
0
let
tx
=
drop
3
xs
let
ty
=
drop
2
ys
t
<
unsafeInterleaveIO
(
addition
(
x1
:
1
:
tx
)
(
1
:
fl
ty
))
return
(
0
:
t
)
7
>
do
let
x1
=
xs
!!
0
let
tx
=
drop
3
xs
let
ty
=
drop
2
ys
t
<
unsafeInterleaveIO
(
addition
(
fl
(
x1
:
1
:
tx
))
(
1
:
(
fl
ty
)))
return
(
1
:
t
)
8
>
do
let
x1
=
xs
!!
0
let
y2
=
ys
!!
1
let
tx
=
drop
3
xs
let
ty
=
drop
3
ys
t
<
unsafeInterleaveIO
(
addition
(
fl
(
x1
:
fl
tx
))
(
fl
(
y2
:
fl
ty
)))
return
(
0
:
1
:
t
)
9
>
do
let
x1
=
xs
!!
0
let
y2
=
ys
!!
1
let
tx
=
drop
3
xs
let
ty
=
drop
3
ys
t
<
unsafeInterleaveIO
(
addition
(
x1
:
fl
tx
)
(
fl
(
y2
:
fl
ty
)))
return
(
1
:
1
:
t
)
10
>
do
let
y1
=
ys
!!
0
let
ty
=
drop
3
ys
let
tx
=
drop
2
xs
t
<
unsafeInterleaveIO
(
addition
(
1
:
fl
tx
)
(
y1
:
1
:
ty
))
return
(
0
:
t
)
11
>
do
let
y1
=
ys
!!
0
let
ty
=
drop
3
ys
let
tx
=
drop
2
xs
t
<
unsafeInterleaveIO
(
addition
(
1
:
fl
tx
)
(
fl
(
y1
:
1
:
ty
)))
return
(
1
:
t
)
12
>
do
let
y1
=
ys
!!
0
let
x2
=
xs
!!
1
let
tx
=
drop
3
xs
let
ty
=
drop
3
ys
t
<
unsafeInterleaveIO
(
addition
(
fl
(
x2
:
fl
tx
))
(
fl
(
y1
:
fl
ty
)))
return
(
0
:
1
:
t
)
13
>
do
let
y1
=
ys
!!
0
let
x2
=
xs
!!
1
let
tx
=
drop
3
xs
let
ty
=
drop
3
ys
t
<
unsafeInterleaveIO
(
addition
(
fl
(
x2
:
fl
tx
))
(
y1
:
fl
ty
))
return
(
1
:
1
:
t
)
c
<
threadTesting
xs
ys
case
c
of
1
>
do
let
tx
=
tail
xs
let
ty
=
tail
ys
t
<
unsafeInterleaveIO
(
addition
tx
ty
)
return
(
0
:
t
)
2
>
do
let
tx
=
tail
xs
let
ty
=
tail
ys
t
<
unsafeInterleaveIO
(
addition
tx
ty
)
return
(
1
:
t
)
3
>
do
let
tx
=
tail
xs
let
ty
=
tail
ys
cs
<
unsafeInterleaveIO
(
addition
tx
(
fl
ty
))
let
c1
=
cs
!!
0
let
c2
=
tail
cs
return
(
c1
:
1
:
fl
c2
)
4
>
do
let
tx
=
tail
xs
let
ty
=
tail
ys
(
cs
)
<
unsafeInterleaveIO
(
addition
(
fl
tx
)
ty
)
let
c1
=
cs
!!
0
let
c2
=
tail
cs
return
(
c1
:
1
:
(
fl
c2
))
5
>
do
let
x1
=
xs
!!
0
let
y1
=
ys
!!
0
let
tx
=
(
drop
2
)
xs
let
ty
=
(
drop
2
)
ys
cs
<
unsafeInterleaveIO
(
addition
(
x1
:
(
fl
tx
))
(
y1
:
(
fl
ty
)))
let
c1
=
cs
!!
0
let
c2
=
tail
cs
return
(
c1
:
(
1
:
(
fl
c2
)))
6
>
do
let
x1
=
xs
!!
0
let
tx
=
drop
3
xs
let
ty
=
drop
2
ys
t
<
unsafeInterleaveIO
(
addition
(
x1
:
1
:
tx
)
(
1
:
fl
ty
))
return
(
0
:
t
)
7
>
do
let
x1
=
xs
!!
0
let
tx
=
drop
3
xs
let
ty
=
drop
2
ys
t
<
unsafeInterleaveIO
(
addition
(
fl
(
x1
:
1
:
tx
))
(
1
:
(
fl
ty
)))
return
(
1
:
t
)
8
>
do
let
x1
=
xs
!!
0
let
y2
=
ys
!!
1
let
tx
=
drop
3
xs
let
ty
=
drop
3
ys
t
<
unsafeInterleaveIO
(
addition
(
fl
(
x1
:
fl
tx
))
(
fl
(
y2
:
fl
ty
)))
return
(
0
:
1
:
t
)
9
>
do
let
x1
=
xs
!!
0
let
y2
=
ys
!!
1
let
tx
=
drop
3
xs
let
ty
=
drop
3
ys
t
<
unsafeInterleaveIO
(
addition
(
x1
:
fl
tx
)
(
fl
(
y2
:
fl
ty
)))
return
(
1
:
1
:
t
)
10
>
do
let
y1
=
ys
!!
0
let
ty
=
drop
3
ys
let
tx
=
drop
2
xs
t
<
unsafeInterleaveIO
(
addition
(
1
:
fl
tx
)
(
y1
:
1
:
ty
))
return
(
0
:
t
)
11
>
do
let
y1
=
ys
!!
0
let
ty
=
drop
3
ys
let
tx
=
drop
2
xs
t
<
unsafeInterleaveIO
(
addition
(
1
:
fl
tx
)
(
fl
(
y1
:
1
:
ty
)))
return
(
1
:
t
)
12
>
do
let
y1
=
ys
!!
0
let
x2
=
xs
!!
1
let
tx
=
drop
3
xs
let
ty
=
drop
3
ys
t
<
unsafeInterleaveIO
(
addition
(
fl
(
x2
:
fl
tx
))
(
fl
(
y1
:
fl
ty
)))
return
(
0
:
1
:
t
)
13
>
do
let
y1
=
ys
!!
0
let
x2
=
xs
!!
1
let
tx
=
drop
3
xs
let
ty
=
drop
3
ys
t
<
unsafeInterleaveIO
(
addition
(
fl
(
x2
:
fl
tx
))
(
y1
:
fl
ty
))
return
(
1
:
1
:
t
)
...
...
@@ 180,51 +180,51 @@ t1 m (1:as) (0:bs) = putMVar m 4
t2
::
MVar
Int
>
Stream
>
Stream
>
IO
()
t2
m
(
a
:
1
:
x
)
(
b
:
1
:
y
)
=
putMVar
m
5
t2
m
x
y
=
yield
t3
m
(
a
:
1
:
0
:
x
)
(
0
:
0
:
y
)
=
putMVar
m
6
t3
m
(
a
:
1
:
0
:
x
)
(
1
:
0
:
y
)
=
putMVar
m
7
t3
m
x
y
=
yield
t4
m
(
a
:
1
:
0
:
x
)
(
0
:
b
:
1
:
y
)
=
putMVar
m
8
t4
m
(
a
:
1
:
0
:
x
)
(
1
:
b
:
1
:
y
)
=
putMVar
m
9
t4
m
x
y
=
yield
t4
m
x
y
=
yield
t5
m
(
0
:
0
:
x
)
(
b
:
1
:
0
:
y
)
=
putMVar
m
10
t5
m
(
1
:
0
:
x
)
(
b
:
1
:
0
:
y
)
=
putMVar
m
11
t5
m
x
y
=
yield
t6
m
(
0
:
a
:
1
:
x
)
(
b
:
1
:
0
:
y
)
=
putMVar
m
12
t6
m
(
1
:
a
:
1
:
x
)
(
b
:
1
:
0
:
y
)
=
putMVar
m
13
t6
m
x
y
=
yield
multiplyIO
::
Gray
>
Gray
>
IO
Gray
multiplyIO
xs
ys
=
do
s1
<
unsafeInterleaveIO
(
grayToSignIO
xs
)
s2
<
unsafeInterleaveIO
(
grayToSignIO
ys
)
let
s
=
Trit
.
multiply
s1
s2
let
g
=
signToGray
s
s1
<
unsafeInterleaveIO
(
grayToSignIO
xs
)
s2
<
unsafeInterleaveIO
(
grayToSignIO
ys
)
let
s
=
Trit
.
multiply
s1
s2
let
g
=
signToGray
s
return
g
start
::
IO
()
start
=
do
c
<
unsafeInterleaveIO
(
multiplyIO
z1
z1
)
putStrLn
(
show
c
)
c
<
unsafeInterleaveIO
(
multiplyIO
z1
z1
)
putStrLn
(
show
c
)
startA
::
IO
()
startA
=
do
c
<
unsafeInterleaveIO
(
addition
(
1
:
1
:
z0
)
(
1
:
1
:
z0
))
putStrLn
(
show
(
take
30
c
))
c
<
unsafeInterleaveIO
(
addition
(
1
:
1
:
z0
)
(
1
:
1
:
z0
))
putStrLn
(
show
(
take
30
c
))
z0
=
(
0
:
z0
)
z1
=
(
1
:
z1
)
...
...
testsuite/tests/concurrent/prog001/Converter.hs
View file @
5b03dc69
...
...
@@ 15,92 +15,92 @@ type State = (Integer, Integer)
 Convert a rational number (in (1,1)) to its Gray representation
rationalToGray
::
Rational
>
Gray
rationalToGray
x

x
<
0
=
f
(
negate'
(
rationalToStream
(

x
)))
(
0
,
0
)

otherwise
=
f
(
rationalToStream
x
)
(
0
,
0
)

x
<
0
=
f
(
negate'
(
rationalToStream
(

x
)))
(
0
,
0
)

otherwise
=
f
(
rationalToStream
x
)
(
0
,
0
)
 Function to implement the two heads Turing machine that convert a
 signeddigit stream to the corresponding Graycode representation
 signeddigit stream to the corresponding Graycode representation
f
::
Stream
>
State
>
Stream
f
(
x
:
xs
)
(
0
,
0
)

x
==
(

1
)
=
0
:
f
xs
(
0
,
0
)

x
==
0
=
c
:
1
:
ds

x
==
1
=
1
:
f
xs
(
1
,
0
)
where
c
:
ds
=
f
xs
(
0
,
1
)

x
==
(

1
)
=
0
:
f
xs
(
0
,
0
)

x
==
0
=
c
:
1
:
ds

x
==
1
=
1
:
f
xs
(
1
,
0
)
where
c
:
ds
=
f
xs
(
0
,
1
)
f
(
x
:
xs
)
(
0
,
1
)

x
==
(

1
)
=
0
:
f
xs
(
1
,
0
)

x
==
0
=
c
:
0
:
ds

x
==
1
=
1
:
f
xs
(
0
,
0
)
where
c
:
ds
=
f
xs
(
0
,
1
)

x
==
(

1
)
=
0
:
f
xs
(
1
,
0
)