@@ -1,7 +1,9 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2module Countdown where
2module Countdown where
4+import Control.Monad.ST
4import Data.Functor.Identity
5import Data.Functor.Identity
7#ifdef VERSION_eff
9#ifdef VERSION_eff
@@ -47,6 +49,26 @@ countdownRef :: Integer -> (Integer, Integer)
47countdownRef n = if n <= 0 then (n, n) else countdownRef $ n - 1
49countdownRef n = if n <= 0 then (n, n) else countdownRef $ n - 1
48{-# NOINLINE countdownRef #-}
50{-# NOINLINE countdownRef #-}
52+----------------------------------------
55+programST :: STRef s Integer -> ST s Integer
61+ writeSTRef ref $! n - 1
63+{-# NOINLINE programST #-}
65+countdownST :: Integer -> (Integer, Integer)
66+countdownST n = runST $ do
50----------------------------------------
72----------------------------------------