Bool -> IO () -> IO ()
A specialised version of mkWeakPtr, object returned is simply thrown away (however the finalizer will be remembered by the garbage collector, and will still be run when the key becomes unreachable).
Note: adding a finalizer to a Foreign.ForeignPtr.ForeignPtr using addFinalizer won't work as well as using the specialised version Foreign.ForeignPtr.addForeignPtrFinalizer because the latter version adds the finalizer to the primitive ForeignPtr# object inside, whereas the generic addFinalizer will add the finalizer to the box. Optimisations tend to remove the box, which may cause the finalizer to run earlier than you intended. The same motivation justifies the existence of Control.Concurrent.MVar.addMVarFinalizer and Data.IORef.mkWeakIORef (the non-uniformity is accidental).
Conditional execution of monadic expressions. For example,
> when debug (putStr "Debugging\n")
will output the string Debugging\n if the Boolean value debug is True, and otherwise do nothing.
This function adds a finalizer to the given ForeignPtr. The finalizer will run after the last reference to the foreign object is dropped, but before all previously registered finalizers for the same object.
A specialised variant of bracket with just a computation to run afterward.
Like finally, but only performs the final action if there was an exception raised by the computation.
If the first argument evaluates to True, then the result is the second argument. Otherwise an AssertionFailed exception is raised, containing a String with the source file and line number of the call to assert.
Assertions can normally be turned on or off with a compiler flag (for GHC, assertions are normally on unless optimisation is turned on with -O or the -fignore-asserts option is given). When assertions are turned off, the first argument to assert is ignored, and the second argument is returned as the result.
A variant of bracket computation is not required.
Inserts a key/value mapping into the hash table.
Note that insert doesn't remove the old entry from the table - the behaviour is like an association list, the most-recently-inserted mapping for a key in the table. The reason for this is to keep insert as efficient as possible. If you need to update a mapping, then we provide update.
Flexible type extension
Evaluates its first argument to head normal form, and then returns its second argument as the result.
Indicates that it may be beneficial to evaluate the first argument in parallel with the second. Returns the value of the second argument.
a `par` b is exactly equivalent semantically to b.
par is generally used when the value of a is likely to be required later, but not immediately. Also it is a good idea to ensure that a is not a trivial computation, otherwise the cost of spawning it in parallel overshadows the benefits obtained by running it in parallel.
Note that actual parallelism is only supported by certain implementations (GHC with the -threaded option, and GPH, for now). On other implementations, par a b = b.
Show more results