Haskell Language Free Maybe ~~ MaybeT (Writer Nat)


Example

Given

data Maybe a = Just a
             | Nothing

we have

data Free Maybe a
     = Pure a
     | Free (Just (Free Maybe a))
     | Free Nothing

which is equivalent to

data Hopes a
     = Confirmed a
     | Possible (Hopes a)
     | Failed

or equivalently (if you promise to evaluate the fst element first) (Nat, Maybe a), aka MaybeT (Writer Nat) a with

data Nat = Z | S Nat
data Writer Nat a = Writer Nat a
data MaybeT (Writer Nat) a = MaybeT (Nat, Maybe a)