THE MAYBE
A timid two-headed sprite. One head is empty, the other clutches a value. Tame it to banish null pointers from the kingdom forever.
- HP40
- ATK12
- WEAKfromJust
— A Bestiary of Functional Beasts —
Below lie the cataloged creatures of the Haskell realm. Approach with care; each beast obeys the strict laws of types.
A timid two-headed sprite. One head is empty, the other clutches a value. Tame it to banish null pointers from the kingdom forever.
A serpentine recursive beast — its tail is forever another smaller serpent. Strict adventurers are devoured by its infinite cousins.
A shape-shifting amorph. Whatever spell you cast on a value, the Functor can cast inside its container without breaking the vessel.
A four-armed sorcerer wielding both spell and target inside the same container. Lifts pure magic into context with a single gesture.
A swirling vortex creature that swallows context and spits out chains of computation. Many adventurers spend years deciphering its three sacred laws.
Hoarder of side effects. Breathes terminal fire and tramples disk drives. Only the runtime itself dares to unleash its actions upon the world.
A chimera of stacked monads. Each layer guards a different power — state, reader, except. To wield it is to command an entire battalion of monsters in perfect formation.
A crystal eye that pierces through nested records. Adjusts the deepest value of any structure without disturbing its surface. Forged in van Laarhoven's workshop.
Each monster grows from the last. Master one, and the next becomes vulnerable.
fmap :: (a -> b) -> f a -> f b
Stage I — learns to map.
pure :: a -> f a
Stage II — learns to lift.
(>>=) :: m a -> (a -> m b) -> m b
Stage III — learns to chain.
StateT s (ReaderT r IO) a
Final form — commands armies.
Two type signatures enter. One unifies. CHOOSE THE SURVIVOR.
(Monad m) =>
m a -> (a -> m b) -> m b
IO () ->
(a -> IO b) -> IO b
Which type wins under unification?
-- summon a Maybe summon :: String -> Maybe Beast summon "monad" = Just theMonad summon "dragon" = Just ioDragon summon _ = Nothing