comp -package:functor-combinators
Computation strategy to use when scheduling work.
Complement of regular expression
Use
compareLength xs n as a safer and faster
alternative to
compare (
length xs)
n. Similarly, it's better to write
compareLength xs 10 ==
LT instead of
length xs < 10.
While
length would force and traverse the entire spine of
xs (which could even diverge if
xs is infinite),
compareLength traverses at most
n elements to
determine its result.
>>> compareLength [] 0
EQ
>>> compareLength [] 1
LT
>>> compareLength ['a'] 1
EQ
>>> compareLength ['a', 'b'] 1
GT
>>> compareLength [0..] 100
GT
>>> compareLength undefined (-1)
GT
>>> compareLength ('a' : undefined) 0
GT
Reverse all the bits in the argument
x `complementBit` i is the same as x `xor` bit i
Lift the standard
compare function through the type
constructor.
Lift the standard
compare function through the type
constructor.
Use
compareLength xs n as a safer and faster
alternative to
compare (
length xs)
n.
Similarly, it's better to write
compareLength xs 10 == LT
instead of
length xs < 10.
While
length would force and traverse the entire spine of
xs (which could even diverge if
xs is infinite),
compareLength traverses at most
n elements to
determine its result.
>>> compareLength ('a' :| []) 1
EQ
>>> compareLength ('a' :| ['b']) 3
LT
>>> compareLength (0 :| [1..]) 100
GT
>>> compareLength undefined 0
GT
>>> compareLength ('a' :| 'b' : undefined) 1
GT
comparing p x y = compare (p x) (p y)
Useful combinator for use in conjunction with the
xxxBy
family of functions from
Data.List, for example:
... sortBy (comparing fst) ...
The Haskell implementation with which the program was compiled or is
being interpreted. On the GHC platform, the value is "ghc".
The version of
compilerName with which the program was compiled
or is being interpreted.
Example
ghci> compilerVersion
Version {versionBranch = [8,8], versionTags = []}
Recursively add a closure and its transitive closure to a
Compact# (a CNF), evaluating any unevaluated components at the
same time. Note:
compactAdd# is not thread-safe, so only one
thread may call
compactAdd# with a particular
Compact#
at any given time. The primop does not enforce any mutual exclusion;
the caller is expected to arrange this.
Like
compactAdd#, but retains sharing and cycles during
compaction.
Attempt to allocate a compact block with the capacity (in bytes) given
by the first argument. The
Addr# is a pointer to previous
compact block of the CNF or
nullAddr# to create a new CNF with
a single compact block.
The resulting block is not known to the GC until
compactFixupPointers# is called on it, and care must be taken
so that the address does not escape or memory will be leaked.
Returns 1# if the object is contained in the CNF, 0# otherwise.
Returns 1# if the object is in any CNF at all, 0# otherwise.