module SuperUserSpark.Language.Types where
import Import
import SuperUserSpark.CoreTypes
type CardName = String
type Source = FilePath
type Destination = FilePath
data Card = Card
{ cardName :: CardName
, cardContent :: Declaration
} deriving (Show, Eq, Generic)
instance Validity Card
data Declaration
= SparkOff CardReference
| Deploy Source
Destination
(Maybe DeploymentKind)
| IntoDir Directory
| OutofDir Directory
| DeployKindOverride DeploymentKind
| Alternatives [Directory]
| Block [Declaration]
deriving (Show, Eq, Generic)
instance Validity Declaration
newtype CardNameReference =
CardNameReference CardName
deriving (Show, Eq, Generic)
instance Validity CardNameReference
data CardFileReference =
CardFileReference FilePath
(Maybe CardNameReference)
deriving (Show, Eq, Generic)
instance Validity CardFileReference
instance Read CardFileReference where
readsPrec _ fp =
case length (words fp) of
1 -> [(CardFileReference fp Nothing, "")]
2 ->
let [f, c] = words fp
in [(CardFileReference f (Just $ CardNameReference c), "")]
_ -> []
data CardReference
= CardFile CardFileReference
| CardName CardNameReference
deriving (Show, Eq, Generic)
instance Validity CardReference
data SparkFile = SparkFile
{ sparkFilePath :: Path Abs File
, sparkFileCards :: [Card]
} deriving (Show, Eq, Generic)
instance Validity SparkFile