t -> t1 -> t
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.
Semantically identical to seq, but with a subtle operational difference: seq is strict in both its arguments, so the compiler may, for example, rearrange a `seq` b into b `seq` a `seq` b. This is normally no problem when using seq to express strictness, but it can be a problem when annotating code for parallelism, because we need more control over the order of evaluation; we may want to evaluate a before b, because we know that b has already been sparked in parallel with par.
This is why we have pseq. In contrast to seq, pseq is only strict in its first argument (as far as the compiler is concerned), which restricts the transformations that the compiler can do, and ensures that the user can retain control of the evaluation order.
asTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the second.
Like trace, but uses show on the argument to convert it to a String.
> traceShow = trace . show
deepseq: fully evaluates the first argument, before returning the second.
The name deepseq is used to illustrate the relationship to seq: evaluates the top level of its argument, deepseq traverses the entire data structure evaluating it completely.
deepseq can be useful for forcing pending exceptions, eradicating space leaks, or forcing lazy I/O to happen. It is also useful in conjunction with parallel Strategies (see the parallel package).
There is no guarantee about the ordering of evaluation. The implementation may evaluate the components of the structure in any order or in parallel. To impose an actual order on evaluation, use pseq from Control.Parallel in the parallel package.
DEPRECATED: Use pseq or $| instead
DEPRECATED: Use par or $|| instead
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.
O(log n). The expression (findWithDefault def k map) returns the value at key k or returns default value def when the key is not in the map.
> findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'
> findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
Make a generic query; start from a type-specific case; return a constant otherwise
Deprecated. As of version 0.5, replaced by foldr.
O(n). Fold the values in the map using the given right-associative binary operator. This function is an equivalent of foldr and is present for compatibility only.
O(n). Fold the values in the map using the given right-associative binary operator, such that foldr f z == foldr f z . elems.
> elems map = foldr (:)  map
> let f a len = len + (length a)
> foldr f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
O(n). A strict version of foldr. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.
Show more results