throwFatalError ::Doc -> ErrorM a
throwFatalError d = ErrorM $ do
    modify $ ((Left $ FatalError d) :)
    errorsAndWarnings <- get -- extract errors from the State monad
    _ <- lift $ Left errorsAndWarnings -- and lift them into the Either monad (this causes an immediate error, skipping further evaluation)
    return undefined
throwFatalError ::Doc -> ErrorM a
throwFatalError d = ErrorM $ do
    modify $ ((Left $ FatalError d) :)
    errorsAndWarnings <- get -- extract errors from the State monad
    _ <- lift $ Left errorsAndWarnings -- and lift them into the Either monad (this causes an immediate error, skipping further evaluation)
    return undefined
throwFatalError d = ErrorM $ do
    modify $ ((Left $ FatalError d) :)
    errorsAndWarnings <- get -- extract errors from the State monad
    _ <- lift $ Left errorsAndWarnings -- and lift them into the Either monad (this causes an immediate error, skipping further evaluation)
    return undefined