{- monster -}

haskell.monster

*** Exception: monster unleashed
CallStack (from HasCallStack): error, called at Monster.hs:1:1 in main:Main
{- encounter -}

Enter the Abyss

Where types become theorems and programs become proofs. The monsters lurk in the spaces between computation and abstraction.

import Control.Monad.Monster

Fear the Type Checker

GHC sees all. Every expression judged, every type inferred. There is no escape from the monstrous precision of Hindley-Milner.

ghc: Could not deduce (Monster m) arising from a use of 'unleash'

Embrace the Chaos

Lazy evaluation means nothing happens until it must. The monster sleeps until you demand its value -- then it devours your stack.

let monster = fix (\m -> m >>= unleash)

Purity is Pain

No side effects. No mutations. Only the cold, beautiful mathematics of lambda calculus stretching into infinity.

pure :: a -> Monster a
{- battle -}

Monster Bestiary

Monad Transformers -- Stack them deep, watch them creep MonadTrans t => t (t (t IO)) a
GADTs -- Generalized terror, algebraically defined data Monster a where { Unleash :: Monster Chaos }
Type Families -- Types that compute, types that haunt type family Summon (m :: Monster) :: Type where ...
Existential Types -- They exist, but you cannot name them data SomeMonster = forall m. Monster m => MkMonster m
Rank-N Types -- Polymorphism within polymorphism unleash :: (forall a. Monster a => a -> Chaos) -> World -> Void
Template Haskell -- Code that writes code that writes nightmares $(deriveMonster ''Cthulhu)
Type Safety:
100%
{- tame -}
No more monsters to slay.