Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (21 sloc) 0.516 kb
{-# 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 #-}
Jump to Line
Something went wrong with that request. Please try again.