-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Fast loops (for when GHC can't optimize forM_) -- -- This package provides a convenient and fast alternative to the common -- `forM_ [1..n]` idiom, which in many cases GHC cannot fuse to efficient -- code. -- -- See https:ghc.haskell.orgtracghcticket8763. @package loop @version 0.1.0 -- | This is for trying out loop alternatives. -- -- Names and types are subjects to change. module Control.Loop.Internal -- | loop start end f: Loops from start to end -- (inclusive), executing f on each iteration. Same as forM_ -- [start..end] f. -- -- Uses succ inside, which does a bounds (overflow) check. loop :: (Enum e, Eq e, Monad m) => e -> e -> (e -> m ()) -> m () -- | Like loop, but (sometimes) without bounds (overflow) check. -- -- This circumvents the implementation of succ for the -- Enum type and uses toEnum . (+ 1) . fromEnum -- instead, so it will break on Enums that are not contiguous. -- -- Note that some types (e.g. Word32) have bounds checks even for -- toEnum. unsafeLoop :: (Enum e, Eq e, Monad m) => e -> e -> (e -> m ()) -> m () -- | Like loop, but using Num instead. -- -- It uses (+ 1) so for most integer types it has no bounds -- (overflow) check. numLoop :: (Num a, Eq a, Monad m) => a -> a -> (a -> m ()) -> m () -- | Provides a convenient and fast alternative to the common forM_ -- [1..n] idiom, which in many cases GHC cannot fuse to efficient -- code. -- -- Notes on fast iteration: -- -- module Control.Loop -- | forLoop start cond inc f: A C-style for loop with starting -- value, loop condition and incrementor. forLoop :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()