    module Data.Tuple.Example where

    import qualified Data.Tuple.Lazy as Lazy
    import qualified Data.Tuple.Strict as Strict

    import Data.List.HT (sieve, )

    partitionLazy :: (a -> Bool) -> [a] -> ([a], [a])
    partitionLazy :: (a -> Bool) -> [a] -> ([a], [a])
    partitionLazy p :: a -> Bool
    p =
       (a -> ([a], [a]) -> ([a], [a])) -> ([a], [a]) -> [a] -> ([a], [a])
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr
          (\x :: a
    x -> (if a -> Bool
    p a
    x then ([a] -> [a]) -> ([a], [a]) -> ([a], [a])
    forall a c b. (a -> c) -> (a, b) -> (c, b)
    Lazy.mapFst else ([a] -> [a]) -> ([a], [a]) -> ([a], [a])
    forall b c a. (b -> c) -> (a, b) -> (a, c)
    Lazy.mapSnd) (a
    xa -> [a] -> [a]
    forall a. a -> [a] -> [a]
    :))
          ([], [])

    partitionStrict :: (a -> Bool) -> [a] -> ([a], [a])
    partitionStrict :: (a -> Bool) -> [a] -> ([a], [a])
    partitionStrict p :: a -> Bool
    p =
       (a -> ([a], [a]) -> ([a], [a])) -> ([a], [a]) -> [a] -> ([a], [a])
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr
          (\x :: a
    x -> (if a -> Bool
    p a
    x then ([a] -> [a]) -> ([a], [a]) -> ([a], [a])
    forall a c b. (a -> c) -> (a, b) -> (c, b)
    Strict.mapFst else ([a] -> [a]) -> ([a], [a]) -> ([a], [a])
    forall b c a. (b -> c) -> (a, b) -> (a, c)
    Strict.mapSnd) (a
    xa -> [a] -> [a]
    forall a. a -> [a] -> [a]
    :))
          ([], [])

    mainPartitionRuns :: IO ()
    mainPartitionRuns :: IO ()
    mainPartitionRuns =
       ([Int], [Int]) -> IO ()
    forall a. Show a => a -> IO ()
    print (([Int], [Int]) -> IO ()) -> ([Int], [Int]) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ (Int -> Bool) -> [Int] -> ([Int], [Int])
    forall a. (a -> Bool) -> [a] -> ([a], [a])
    partitionLazy (Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >=0) ([Int] -> ([Int], [Int])) -> [Int] -> ([Int], [Int])
    forall a b. (a -> b) -> a -> b
    $ Int -> [Int]
    forall a. a -> [a]
    repeat (0::Int)

    mainPartitionBlocks :: IO ()
    mainPartitionBlocks :: IO ()
    mainPartitionBlocks =
       ([Int], [Int]) -> IO ()
    forall a. Show a => a -> IO ()
    print (([Int], [Int]) -> IO ()) -> ([Int], [Int]) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ (Int -> Bool) -> [Int] -> ([Int], [Int])
    forall a. (a -> Bool) -> [a] -> ([a], [a])
    partitionStrict (Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >=0) ([Int] -> ([Int], [Int])) -> [Int] -> ([Int], [Int])
    forall a b. (a -> b) -> a -> b
    $ Int -> [Int]
    forall a. a -> [a]
    repeat (0::Int)

    printSomeChars :: (Show a) => a -> IO ()
    printSomeChars :: a -> IO ()
    printSomeChars = String -> IO ()
    putStrLn (String -> IO ()) -> (a -> String) -> a -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> String -> String
    forall a. Int -> [a] -> [a]
    sieve 100000 (String -> String) -> (a -> String) -> a -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> String
    forall a. Show a => a -> String
    show

    mainMemoryOk :: IO ()
    mainMemoryOk :: IO ()
    mainMemoryOk =
       ([Int], Int) -> IO ()
    forall a. Show a => a -> IO ()
    printSomeChars (([Int], Int) -> IO ()) -> ([Int], Int) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ (Int -> Int) -> ([Int], Int) -> ([Int], Int)
    forall b c a. (b -> c) -> (a, b) -> (a, c)
    Strict.mapSnd (1Int -> Int -> Int
    forall a. Num a => a -> a -> a
    +) (([Int], Int) -> ([Int], Int)) -> ([Int], Int) -> ([Int], Int)
    forall a b. (a -> b) -> a -> b
    $ ((Int -> Int) -> Int -> [Int]
    forall a. (a -> a) -> a -> [a]
    iterate (1Int -> Int -> Int
    forall a. Num a => a -> a -> a
    +) (0::Int), 0::Int)

    mainMemoryLeak :: IO ()
    mainMemoryLeak :: IO ()
    mainMemoryLeak =
       ([Int], Int) -> IO ()
    forall a. Show a => a -> IO ()
    printSomeChars (([Int], Int) -> IO ()) -> ([Int], Int) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ (Int -> Int) -> ([Int], Int) -> ([Int], Int)
    forall b c a. (b -> c) -> (a, b) -> (a, c)
    Lazy.mapSnd (1Int -> Int -> Int
    forall a. Num a => a -> a -> a
    +) (([Int], Int) -> ([Int], Int)) -> ([Int], Int) -> ([Int], Int)
    forall a b. (a -> b) -> a -> b
    $ ((Int -> Int) -> Int -> [Int]
    forall a. (a -> a) -> a -> [a]
    iterate (1Int -> Int -> Int
    forall a. Num a => a -> a -> a
    +) (0::Int), 0::Int)