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

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

    module Yi.Keymap.Vim.MatchResult where

    import           Control.Applicative (Alternative ((<|>), empty))

    data MatchResult a = NoMatch
                       | PartialMatch
                       | WholeMatch a
                       deriving (forall a b. (a -> b) -> MatchResult a -> MatchResult b)
    -> (forall a b. a -> MatchResult b -> MatchResult a)
    -> Functor MatchResult
    forall a b. a -> MatchResult b -> MatchResult a
    forall a b. (a -> b) -> MatchResult a -> MatchResult b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> MatchResult a -> MatchResult b
    fmap :: forall a b. (a -> b) -> MatchResult a -> MatchResult b
    $c<$ :: forall a b. a -> MatchResult b -> MatchResult a
    <$ :: forall a b. a -> MatchResult b -> MatchResult a
    Functor

    instance Applicative MatchResult where
        pure :: forall a. a -> MatchResult a
    pure = a -> MatchResult a
    forall a. a -> MatchResult a
    WholeMatch
        WholeMatch a -> b
    f <*> :: forall a b. MatchResult (a -> b) -> MatchResult a -> MatchResult b
    <*> WholeMatch a
    x = b -> MatchResult b
    forall a. a -> MatchResult a
    WholeMatch (a -> b
    f a
    x)
        MatchResult (a -> b)
    _ <*> MatchResult a
    _ = MatchResult b
    forall a. MatchResult a
    NoMatch

    instance Alternative MatchResult where
        empty :: forall a. MatchResult a
    empty = MatchResult a
    forall a. MatchResult a
    NoMatch
        WholeMatch a
    x <|> :: forall a. MatchResult a -> MatchResult a -> MatchResult a
    <|> MatchResult a
    _ = a -> MatchResult a
    forall a. a -> MatchResult a
    WholeMatch a
    x
        MatchResult a
    _ <|> WholeMatch a
    x = a -> MatchResult a
    forall a. a -> MatchResult a
    WholeMatch a
    x
        MatchResult a
    PartialMatch <|> MatchResult a
    _ = MatchResult a
    forall a. MatchResult a
    PartialMatch
        MatchResult a
    _ <|> MatchResult a
    PartialMatch = MatchResult a
    forall a. MatchResult a
    PartialMatch
        MatchResult a
    _ <|> MatchResult a
    _ = MatchResult a
    forall a. MatchResult a
    NoMatch

    instance Show (MatchResult a) where
        show :: MatchResult a -> String
    show (WholeMatch a
    _) = String
    "WholeMatch"
        show MatchResult a
    PartialMatch = String
    "PartialMatch"
        show MatchResult a
    NoMatch = String
    "NoMatch"

    matchFromBool :: Bool -> MatchResult ()
    matchFromBool :: Bool -> MatchResult ()
    matchFromBool Bool
    b = if Bool
    b then () -> MatchResult ()
    forall a. a -> MatchResult a
    WholeMatch () else MatchResult ()
    forall a. MatchResult a
    NoMatch

    matchFromMaybe :: Maybe a -> MatchResult a
    matchFromMaybe :: forall a. Maybe a -> MatchResult a
    matchFromMaybe Maybe a
    Nothing = MatchResult a
    forall a. MatchResult a
    NoMatch
    matchFromMaybe (Just a
    a) = a -> MatchResult a
    forall a. a -> MatchResult a
    WholeMatch a
    a