indentation :: Lexer (Pos Token)
indentation = withPos $ do
    stackNull >>= flip when parserZero
    expect <- peek >>= maybe parserZero return
    found <- lookAhead leadingSpaces
    case compare found expect of
        GT -> leadingSpaces >> push found >> return Indent
        EQ -> leadingSpaces >> isEof >>= \end ->
              if end then parserZero else return Newline
        LT -> (<?> "dedent") $ do
            pop
            end <- isEof
            when (not end) $ do
                stackNull >>= flip when (fail "dedent does not have corresponding indent")
                expect' <- peek >>= maybe (error "indentation disable under enable") return
                when (expect' < found) $ fail "dedent does not have corresponding indent"
            return Dedent
indentation :: Lexer (Pos Token)
indentation = withPos $ do
    stackNull >>= flip when parserZero
    expect <- peek >>= maybe parserZero return
    found <- lookAhead leadingSpaces
    case compare found expect of
        GT -> leadingSpaces >> push found >> return Indent
        EQ -> leadingSpaces >> isEof >>= \end ->
              if end then parserZero else return Newline
        LT -> (<?> "dedent") $ do
            pop
            end <- isEof
            when (not end) $ do
                stackNull >>= flip when (fail "dedent does not have corresponding indent")
                expect' <- peek >>= maybe (error "indentation disable under enable") return
                when (expect' < found) $ fail "dedent does not have corresponding indent"
            return Dedent
indentation = withPos $ do
    stackNull >>= flip when parserZero
    expect <- peek >>= maybe parserZero return
    found <- lookAhead leadingSpaces
    case compare found expect of
        GT -> leadingSpaces >> push found >> return Indent
        EQ -> leadingSpaces >> isEof >>= \end ->
              if end then parserZero else return Newline
        LT -> (<?> "dedent") $ do
            pop
            end <- isEof
            when (not end) $ do
                stackNull >>= flip when (fail "dedent does not have corresponding indent")
                expect' <- peek >>= maybe (error "indentation disable under enable") return
                when (expect' < found) $ fail "dedent does not have corresponding indent"
            return Dedent