-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Strict Identity Monad, handy for writing fast code!
--   
--   strict Identity monad for writing strict performant code sanely
@package strict-identity
@version 0.1.0.0


module Control.Monad.StrictIdentity

-- | <a>StrictIdentity</a> is a newtype wrapper for a given type <tt>a</tt>
--   that satisfies the <a>Functor</a>, <a>Applicative</a>, and
--   <a>Monad</a> laws when restricted to terminating strict computations.
--   
--   The typical use case is to provide a light weight strict nested let
--   notation for code that otherwise must use nested case expressions as a
--   proxy for a strict let.
--   
--   the general pattern is to write code of the form
--   
--   <pre>
--   foo f h g x y z = runStrictIdentity $! do
--       w &lt;- return $! f x y
--       j &lt;- return $! h w z
--       res &lt;- return $! g w j
--       return res
--   </pre>
--   
--   An example usage of <a>StrictIdentity</a> that compiles to assembly
--   comparable to C is the following:
--   
--   <pre>
--   (&gt;&gt;) = unsafeShiftR
--   (&lt;&lt;) = unsafeShiftL
--   outerShuffle64A :: Word -&gt; Word 
--   outerShuffle64A !x =
--       runStrictIdentity $! do
--           x &lt;- return $! ((x .&amp;. 0x00000000FFFF0000) &lt;&lt; 16 )
--               .|. ((x&gt;&gt;16) .&amp;. 0x00000000FFFF0000) .|. (x .&amp;. 0xFFFF00000000FFFF)
--           x &lt;-  return $! ((x .&amp;. 0x0000FF000000FF00 ) &lt;&lt;  8 )
--               .|. (x &gt;&gt; 8) .&amp;. 0x0000FF000000FF00 .|. (x  .&amp;. 0xFF0000FFFF0000FF)
--           x&lt;-  return $! (( x .&amp;. 0x00F000F000F000F0 ) &lt;&lt; 4 )
--               .|. (x &gt;&gt; 4) .&amp;. 0x00F000F000F000F0 .|. (x .&amp;. 0xF00FF00FF00FF00F )
--           x&lt;-   return $!((x .&amp;.  0x0C0C0C0C0C0C0C0C )&lt;&lt; 2 )
--               .|. (x &gt;&gt; 2) .&amp;. 0x0C0C0C0C0C0C0C0C .|.( x .&amp;. 0xC3C3C3C3C3C3C3C3)
--           x&lt;-   return $! ( (x .&amp;. 0x2222222222222222)  &lt;&lt; 1 ) 
--               .|. (x&gt;&gt; 1) .&amp;. 0x2222222222222222 .|. (x .&amp;. 0x9999999999999999)
--           return x
--   </pre>
newtype StrictIdentity a
StrictIdentity :: a -> StrictIdentity a
[runStrictIdentity_] :: StrictIdentity a -> a

-- | <a>runStrictIdentity</a> unwraps a value of type
--   <tt><a>StrictIdentity</a> ty</tt> into a value of type <tt>ty</tt>,
--   strictly.
runStrictIdentity :: StrictIdentity a -> a
instance GHC.Base.Applicative Control.Monad.StrictIdentity.StrictIdentity
instance GHC.Base.Functor Control.Monad.StrictIdentity.StrictIdentity
instance GHC.Base.Monad Control.Monad.StrictIdentity.StrictIdentity
instance Control.Monad.Fix.MonadFix Control.Monad.StrictIdentity.StrictIdentity
