Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 27 lines (21 sloc) 0.516 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
{-# LANGUAGE BangPatterns #-}
-- | Demonstrate the problem with IO not allowing for unlifted types.
--
-- TODO: Not yet finished.
module StrictIO where



loop :: Int -> Int -> IO ()
loop !i !c
    | i == 1 = print c
    | otherwise = do
        !i' <- subcases
        print i'
        loop i' (c+1)
  where
    subcases
      | i `mod` 2 == 0 = do
          print "even"
          return $ i `div` 2
      | otherwise = do
          print "odd"
          return $ i + 1
    {-# INLINE subcases #-}


  
Something went wrong with that request. Please try again.