Let\'s take a function of type (Monad m) => a -> m a
. For example:
ghci> let f x = Just (x+1)
I\'d like to be able to
I'd probably create some stricter variants of existing functions.
{-# LANGUAGE BangPatterns #-}
iterate' f !x = x : iterate' f (f x)
ma >>=! f = do !a <- ma; f a
times' n f a = iterate' (>>=! f) (return a) !! n
Perhaps your problems stem from the fact that seq
only evaluates the first argument to WHNF? If you're working on a complex structure, you may need a deeper seq
, like deepseq.