comp
Computation strategy to use when scheduling work.
Complement of regular expression
Functor composition.
Comp f g a is equivalent to
f
(g a), and the
Comp pattern synonym is a way of getting
the
f (g a) in a
Comp f g a.
For example,
Maybe (IO Bool) is
Comp Maybe IO Bool.
This is mostly useful for its typeclass instances: in particular,
Functor,
Applicative,
HBifunctor, and
Monoidal.
This is essentially a version of
:.: and
Compose that
allows for an
HBifunctor instance.
It is slightly less performant. Using
comp .
unComp every once in a while will concretize a
Comp
value (if you have
Functor f) and remove some
indirection if you have a lot of chained operations.
The "free monoid" over
Comp is
Free, and the "free
semigroup" over
Comp is
Free1.
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.