module Buffer.Prelude
(
module Exports,
forMToZero_,
forMFromZero_,
strictCons,
traceEventIO,
traceEvent,
traceMarkerIO,
traceMarker,
)
where
import BasePrelude as Exports hiding (assert, left, right, isLeft, isRight, (<>), First(..), Last(..), ProtocolError, traceEvent, traceEventIO, traceMarker, traceMarkerIO)
import Data.ByteString as Exports (ByteString)
import Bug as Exports
import qualified GHC.RTS.Flags as A
import qualified BasePrelude as B
matchTraceUserEvents :: a -> a -> a
matchTraceUserEvents =
case A.user (unsafeDupablePerformIO A.getTraceFlags) of
True -> \_ x -> x
False -> \x _ -> x
!traceEventIO =
matchTraceUserEvents (const (return ())) B.traceEventIO
!traceEvent =
matchTraceUserEvents (const id) B.traceEvent
!traceMarkerIO =
matchTraceUserEvents (const (return ())) B.traceMarkerIO
!traceMarker =
matchTraceUserEvents (const id) B.traceMarker
forMToZero_ :: Applicative m => Int -> (Int -> m a) -> m ()
forMToZero_ !startN f =
($ pred startN) $ fix $ \loop !n -> if n >= 0 then f n *> loop (pred n) else pure ()
forMFromZero_ :: Applicative m => Int -> (Int -> m a) -> m ()
forMFromZero_ !endN f =
($ 0) $ fix $ \loop !n -> if n < endN then f n *> loop (succ n) else pure ()
strictCons :: a -> [a] -> [a]
strictCons !a b =
let !c = a : b in c