primal-0.3.0.0: Primeval world of Haskell.
Copyright(c) Alexey Kuleshevich 2020
LicenseBSD3
MaintainerAlexey Kuleshevich <alexey@kuleshevi.ch>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Control.Prim.Eval

Description

 
Synopsis

Liveness

touch :: MonadPrim s m => a -> m () Source #

This is an action that ensures that the value is still available and garbage collector has not cleaned it up.

Make sure not to use it after some computation that doesn't return, like after forever for example, otherwise touch will simply be removed by ghc and bad things will happen. If you have a case like that, make sure to use withAlivePrimBase or keepAlive instead.

Since: 0.1.0

touch# :: a -> State# s -> State# s Source #

Same as touch#, except it is not restricted to RealWorld state token.

keepAlive Source #

Arguments

:: MonadUnliftPrim s m 
=> a

The value to preserve

-> m b

Action to run in which the value will be preserved

-> m b 

Similar to touch. See withAlive# for more info.

Since: 0.3.0

keepAlive# Source #

Arguments

:: a

The value to preserve

-> (State# s -> (# State# s, r #))

The continuation in which the value will be preserved

-> State# s 
-> (# State# s, r #) 

Forward compatible operator that might be introduced in some future ghc version.

See: #17760

Current version is not as efficient as the version that will be introduced in the future, because it works around the ghc bug by simply preventing inlining and relying on the touch function.

Since: 0.1.0

Weak-Head Normal Form

seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b infixr 0 #

The value of seq a b is bottom if a is bottom, and otherwise equal to b. In other words, it evaluates the first argument a to weak head normal form (WHNF). seq is usually introduced to improve performance by avoiding unneeded laziness.

A note on evaluation order: the expression seq a b does not guarantee that a will be evaluated before b. The only guarantee given by seq is that the both a and b will be evaluated before seq returns a value. In particular, this means that b may be evaluated before a. If you need to guarantee a specific order of evaluation, you must use the function pseq from the "parallel" package.

eval :: MonadPrim s m => a -> m a Source #

An action that evaluates a value to Weak Head Normal Form (WHNF). Same as evaluate, except it works in MonadPrim. This function provides stronger guarantees than seq with respect to ordering of operations, but it does have a slightly higher overhead.

Since: 0.3.0

evalM :: MonadPrim s m => m a -> m a Source #

Run the action and then use eval to ensure its result is evaluated to Weak Head Normal Form (WHNF)

Since: 0.3.0

Normal Form

deepeval :: (MonadPrim s m, NFData a) => a -> m a Source #

An action that evaluates a value to Normal Form (NF). This function provides stronger guarantees than deepseq with respect to ordering of operations.

Since: 0.3.0

deepevalM :: (MonadPrim s m, NFData a) => m a -> m a Source #

Run the action and the using deepeval ensure its result is evaluated to Normal Form (NF)

Since: 0.3.0

newtype BNF a Source #

Bogus Normal Form. This is useful in places where NFData constraint is required, but an instance can't really be created in any meaningful way for the type at hand. Creating environment in benchmarks is one such place where it may come in handy.

Since: 0.3.0

Constructors

BNF a 

Instances

Instances details
NFData (BNF a) Source #

Unlawful instance that only evaluates its contents to WHNF

Since: 0.3.0

Instance details

Defined in Control.Prim.Eval

Methods

rnf :: BNF a -> () #