    {-# LANGUAGE OverloadedStrings #-}
    {-# OPTIONS_HADDOCK show-extensions #-}

    -- |
    -- Module      :  Yi.Keymap.Vim.Ex.Commands.Yi
    -- License     :  GPL-2
    -- Maintainer  :  yi-devel@googlegroups.com
    -- Stability   :  experimental
    -- Portability :  portable

    module Yi.Keymap.Vim.Ex.Commands.Yi (parse) where

    import           Control.Monad                    (void)
    import qualified Data.Attoparsec.Text             as P (many1, space, string, takeText)
    import qualified Data.Text                        as T (unpack)
    import           Yi.Eval                          (execEditorAction)
    import           Yi.Keymap                        (Action (YiA))
    import           Yi.Keymap.Vim.Common             (EventString)
    import qualified Yi.Keymap.Vim.Ex.Commands.Common as Common (impureExCommand, parse)
    import           Yi.Keymap.Vim.Ex.Types           (ExCommand (cmdAction, cmdShow))

    parse :: EventString -> Maybe ExCommand
    parse :: EventString -> Maybe ExCommand
    parse = Parser ExCommand -> EventString -> Maybe ExCommand
    Common.parse (Parser ExCommand -> EventString -> Maybe ExCommand)
    -> Parser ExCommand -> EventString -> Maybe ExCommand
    forall a b. (a -> b) -> a -> b
    $ do
        Parser Text Text -> Parser Text ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parser Text Text -> Parser Text ())
    -> Parser Text Text -> Parser Text ()
    forall a b. (a -> b) -> a -> b
    $ Text -> Parser Text Text
    P.string Text
    "yi"
        Parser Text String -> Parser Text ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parser Text String -> Parser Text ())
    -> Parser Text String -> Parser Text ()
    forall a b. (a -> b) -> a -> b
    $ Parser Text Char -> Parser Text String
    forall (f :: * -> *) a. Alternative f => f a -> f [a]
    P.many1 Parser Text Char
    P.space
        cmd <- Parser Text Text
    P.takeText
        return $! Common.impureExCommand {
            cmdAction = YiA $ execEditorAction (T.unpack cmd)
          , cmdShow = cmd
          }