Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Helper functions for enforcing strictness.
Synopsis
- data StrictUnit
- forceElemsToWHNF ∷ Foldable t ⇒ t a → t a
Documentation
data StrictUnit Source #
The equivalent of ()
, but with a strict mappend
implementation.
For more information, see the documentation for forceElemsToWHNF
.
Instances
Monoid StrictUnit Source # | |
Defined in Data.Unit.Strict mappend ∷ StrictUnit → StrictUnit → StrictUnit Source # mconcat ∷ [StrictUnit] → StrictUnit Source # | |
Semigroup StrictUnit Source # | |
Defined in Data.Unit.Strict (<>) ∷ StrictUnit → StrictUnit → StrictUnit Source # sconcat ∷ NonEmpty StrictUnit → StrictUnit Source # stimes ∷ Integral b ⇒ b → StrictUnit → StrictUnit Source # |
forceElemsToWHNF ∷ Foldable t ⇒ t a → t a Source #
Force all of the elements of a Foldable
to weak head normal form.
In order to ensure that all of the elements of a Foldable
are strict, we
can simply foldMap
over it and seq
each value with ()
. However,
()
's mappend
implementation is actually completely lazy: _ <> _ = ()
So, in order to work around this, we instead utilize this newly defined
StrictUnit
whose mappend
implementation is specifically strict.