id package:rebase

the identity morphism
Identity functor and monad. (a non-strict monad)
A Decidable contravariant functor is the contravariant analogue of Alternative. Noting the superclass constraint that f must also be Divisible, a Decidable functor has the ability to "fan out" input, under the intuition that contravariant functors consume input. In the discussion for Divisible, an example was demonstrated with Serializers, that turn as into ByteStrings. Divisible allowed us to serialize the product of multiple values by concatenation. By making our Serializer also Decidable- we now have the ability to serialize the sum of multiple values - for example different constructors in an ADT. Consider serializing arbitrary identifiers that can be either Strings or Ints:
data Identifier = StringId String | IntId Int
We know we have serializers for Strings and Ints, but how do we combine them into a Serializer for Identifier? Essentially, our Serializer needs to scrutinise the incoming value and choose how to serialize it:
identifier :: Serializer Identifier
identifier = Serializer $ \identifier ->
case identifier of
StringId s -> runSerializer string s
IntId i -> runSerializer int i
It is exactly this notion of choice that Decidable encodes. Hence if we add an instance of Decidable for Serializer...
instance Decidable Serializer where
lose f = Serializer $ \a -> absurd (f a)
choose split l r = Serializer $ \a ->
either (runSerializer l) (runSerializer r) (split a)
Then our identifier Serializer is
identifier :: Serializer Identifier
identifier = choose toEither string int where
toEither (StringId s) = Left s
toEither (IntId i) = Right i
semigroupoid with inverses. This technically should be a category with inverses, except we need to use Ob to define the valid objects for the category
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following: The method names refer to the monoid of lists under concatenation, but there are many other instances. Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Sum and Product. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.
Category sans id
A ThreadId is an abstract type representing a handle to a thread. ThreadId is an instance of Eq, Ord and Show, where the Ord instance implements an arbitrary total ordering over ThreadIds. The Show instance lets you convert an arbitrary-valued ThreadId to string form; showing a ThreadId value is occasionally useful when debugging or diagnosing the behaviour of a concurrent program. Note: in GHC, if you have a ThreadId, you essentially have a pointer to the thread itself. This means the thread itself can't be garbage collected until you drop the ThreadId. This misfeature will hopefully be corrected at a later date.
Type representing Universally Unique Identifiers (UUID) as specified in RFC 4122.
Selective instance for the standard applicative functor Validation. This is a good example of a non-trivial selective functor which is not a monad.
Uninhabited data type