HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleloop-0.3.0Haskell98

Control.Loop.Internal

This is for trying out loop alternatives.

Names and types are subjects to change.

  • 2 values
  • Packageloop-0.3.0
  • Exports2
  • LanguageHaskell98
  • LicenceMIT
  • SourceInternal.hs
valueloop :: (Enum e, Eq e, Monad m) => e -> e -> (e -> m ()) -> m ()
#

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.

valueunsafeLoop :: (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.