SPECIMEN INITIALIZING
THREAT LEVEL PURE
STATUS LAZY
SPECIMENS 6

HASKELL.MONSTER

A Bestiary of Type Classes

Observe. Classify. Understand.

FUNCTOR

Functor

The Shape-Preserving Transformer

class Functor f where fmap :: (a -> b) -> f a -> f b

Identity: fmap id = id

Composition: fmap (g . h) = fmap g . fmap h

COMPLEXITY
APPLICATIVE

Applicative

The Parallel Combinator

class Functor f => Applicative f where pure :: a -> f a (<*>) :: f (a -> b) -> f a -> f b

Identity: pure id <*> v = v

Homomorphism: pure f <*> pure x = pure (f x)

COMPLEXITY
MONAD

Monad

The Sequential Composer

class Applicative m => Monad m where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b

Left identity: return a >>= f = f a

Right identity: m >>= return = m

Associativity: (m >>= f) >>= g = m >>= (\x -> f x >>= g)

COMPLEXITY
MONOID

Monoid

The Accumulator

class Semigroup a => Monoid a where mempty :: a mappend :: a -> a -> a

Left identity: mempty <> x = x

Right identity: x <> mempty = x

Associativity: (x <> y) <> z = x <> (y <> z)

COMPLEXITY
FOLDABLE

Foldable

The Collapsing Structure

class Foldable t where foldr :: (a -> b -> b) -> b -> t a -> b foldMap :: Monoid m => (a -> m) -> t a -> m

foldr f z t = appEndo (foldMap (Endo . f) t) z

COMPLEXITY
TRAVERSABLE

Traversable

The Inside-Out Mapper

class (Functor t, Foldable t) => Traversable t where traverse :: Applicative f => (a -> f b) -> t a -> f (t b) sequenceA :: Applicative f => t (f a) -> f (t a)

Naturality: t . traverse f = traverse (t . f)

Identity: traverse Identity = Identity

COMPLEXITY

LABORATORY NOTES

The specimens cataloged here represent the foundational type classes of the Haskell ecosystem. Each one captures a pattern of computation so fundamental that it appears across mathematics, logic, and programming alike.

From the humble Functor to the powerful Traversable, these creatures form an interconnected web of abstractions. Master one, and the next reveals itself. The bestiary grows with understanding.

END OF OBSERVATION LOG