on package:protolude
on b u x y runs the binary function
b
on the results of applying unary function
u to two
arguments
x and
y. From the opposite perspective, it
transforms two inputs and combines the outputs.
((+) `on` f) x y = f x + f y
Typical usage:
sortBy (compare `on`
fst).
Algebraic properties:
(*) `on` id = (*) -- (if (*) ∉ {⊥, const
⊥})
((*) `on` f) `on` g = (*) `on` (f . g)
flip on f . flip on g = flip on (g .
f)
Like
finally, but only performs the final action if there was
an exception raised by the computation.
A handler for a decoding error.
Function type for handling a coding error. It is supplied with two
inputs:
- A String that describes the error.
- The input value that caused the error. If the error arose because
the end of input was reached or could not be identified precisely,
this value will be Nothing.
If the handler returns a value wrapped with
Just, that value
will be used in the output as the replacement for the invalid input.
If it returns
Nothing, no value will be used in the output.
Should the handler need to abort processing, it should use
error or
throw an exception (preferably a
UnicodeException). It may use the description provided to
construct a more helpful error report.
Exceptions generated by array operations
The thread is blocked on an MVar, but there are no other
references to the MVar so it can't ever continue.
The thread is waiting to retry an STM transaction, but there are no
other references to any TVars involved, so it can't ever
continue.
Representational equality. If
Coercion a b is inhabited by
some terminating value, then the type
a has the same
underlying representation as the type
b.
To use this equality in practice, pattern-match on the
Coercion a
b to get out the
Coercible a b instance, and then use
coerce to apply it.
Compaction found an object that cannot be compacted. Functions cannot
be compacted, nor can mutable objects or pinned objects. See
compact.
A value of type
Concurrently a is an
IO operation
that can be composed with other
Concurrently values, using
the
Applicative and
Alternative instances.
Calling
runConcurrently on a value of type
Concurrently
a will execute the
IO operations it contains
concurrently, before delivering the result of type
a.
For example
(page1, page2, page3)
<- runConcurrently $ (,,)
<$> Concurrently (getURL "url1")
<*> Concurrently (getURL "url2")
<*> Concurrently (getURL "url3")
The kind of constraints, like Show a
Class for datatypes that represent data constructors