unsafe -package:cryptonite package:rio
Boxed
Vector unsafe functions. These perform no bounds
checking, and may cause segmentation faults etc.! Import as:
import qualified RIO.Vector.Boxed.Unsafe as VB'
Storable
Vector unsafe functions. These perform no bounds
checking, and may cause segmentation faults etc.! Import as:
import qualified RIO.Vector.Storable.Unsafe as VS'
Unoxed
Vector unsafe functions. These perform no bounds
checking, and may cause segmentation faults etc.! Import as:
import qualified RIO.Vector.Unoxed.Unsafe as VU'
Generic
Vector interface unsafe functions. These perform no
bounds checking, and may cause segmentation faults etc.! Import as:
import qualified RIO.Vector.Unsafe as V'
Take
ProcessHandle out of the
Process. This method is
needed in cases one need to use low level functions from the
process package. Use cases for this method are:
- Send a special signal to the process.
- Terminate the process group instead of terminating single
process.
- Use platform specific API on the underlying process.
This method is considered unsafe because the actions it performs on
the underlying process may overlap with the functionality that
typed-process provides. For example the user should not call
waitForProcess on the process handle as eiter
waitForProcess or
stopProcess will lock. Additionally,
even if process was terminated by the
terminateProcess or by
sending signal,
stopProcess should be called either way in
order to cleanup resources allocated by the
typed-process.
Same as
accum but without bounds checking.
O(n) Copy an immutable vector into a mutable one. The two
vectors must have the same length. This is not checked.
O(1) Yield all but the first n elements without
copying. The vector must contain at least n elements but this
is not checked.
O(1) Unsafe convert a mutable vector to an immutable one
without copying. The mutable vector may not be used after this
operation.
O(1) First element without checking if the vector is empty
O(1) First element in a monad without checking for empty
vectors. See
indexM for an explanation of why this is useful.
O(1) Unsafe indexing without bounds checking
O(1) Indexing in a monad without bounds checks. See
indexM for an explanation of why this is useful.
O(1) Yield all but the last element without copying. The vector
may not be empty but this is not checked.
O(1) Last element without checking if the vector is empty
O(1) Last element in a monad without checking for empty
vectors. See
indexM for an explanation of why this is useful.
O(1) Yield a slice of the vector without copying. The vector
must contain at least i+n elements but this is not checked.
O(1) Yield all but the first element without copying. The
vector may not be empty but this is not checked.
O(1) Yield the first n elements without copying. The
vector must contain at least n elements but this is not
checked.
O(1) Unsafely convert an immutable vector to a mutable one
without copying. Note that this is very dangerous function and
generally it's only safe to read from resulting vector. In which case
immutable vector could be used safely as well.
Problem with mutation happens because GHC has a lot of freedom to
introduce sharing. As a result mutable vectors produced by
unsafeThaw may or may not share same underlying buffer. For
example:
foo = do
let vec = V.generate 10 id
mvec <- V.unsafeThaw vec
do_something mvec
Here GHC could lift
vec outside of foo which means all calls
to
do_something will use same buffer with possibly disastrous
results. Whether such aliasing happens or not depends on program in
question, optimization levels, and GHC flags.
All in all attempts to modify vector after unsafeThaw falls out of
domain of software engineering and into realm of black magic, dark
rituals, and unspeakable horrors. Only advice that could be given is:
"don't attempt to mutate vector after unsafeThaw unless you know how
to prevent GHC from aliasing buffers accidentally. We don't"
Same as (
//) but without bounds checking.
Same as
update but without bounds checking.