{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

module Stack.Types.SCM
  ( SCM (..)
  ) where

import           Pantry.Internal.AesonExtended ( FromJSON (..), ToJSON (..) )
import           Stack.Prelude

-- | A software control system.

data SCM
  = Git
  deriving Int -> SCM -> ShowS
[SCM] -> ShowS
SCM -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SCM] -> ShowS
$cshowList :: [SCM] -> ShowS
show :: SCM -> String
$cshow :: SCM -> String
showsPrec :: Int -> SCM -> ShowS
$cshowsPrec :: Int -> SCM -> ShowS
Show

instance FromJSON SCM where
  parseJSON :: Value -> Parser SCM
parseJSON Value
v = do
    String
s <- forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
    case String
s of
      String
"git" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure SCM
Git
      String
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String
"Unknown or unsupported SCM: " forall a. Semigroup a => a -> a -> a
<> String
s)

instance ToJSON SCM where
  toJSON :: SCM -> Value
toJSON SCM
Git = forall a. ToJSON a => a -> Value
toJSON (Text
"git" :: Text)