module Control.Biegunka.Language
( Scope(..)
, Term(..), Action(..), Source(..), Modifier(..)
, PatchSpec(..), CopySpec(..)
, Token
) where
import Control.Applicative((<$>))
import Data.Foldable (Foldable(..))
import Data.Traversable (Traversable(..), fmapDefault, foldMapDefault)
import Control.Monad.Free (Free(..))
import Data.Copointed (Copointed(..))
import Data.Default.Class (Default(..))
import Data.Set (Set)
import Data.Text (Text)
import System.Process (CmdSpec)
import Control.Biegunka.Templates
import Control.Biegunka.Script.Token
data Scope = Actions | Sources
data Term :: (Scope -> *) -> Scope -> * -> * where
TS :: f Sources -> Source -> Free (Term f Actions) () -> x -> Term f Sources x
TA :: f Actions -> Action -> x -> Term f Actions x
TM :: Modifier -> x -> Term f s x
instance Functor (Term f s) where
fmap = fmapDefault
instance Foldable (Term f s) where
foldMap = foldMapDefault
instance Traversable (Term f s) where
traverse f (TS a s i x) = TS a s i <$> f x
traverse f (TA a z x) = TA a z <$> f x
traverse f (TM w x) = TM w <$> f x
instance Copointed (Term f s) where
copoint (TS _ _ _ x) = x
copoint (TA _ _ x) = x
copoint (TM _ x) = x
data Source = Source {
stype :: String
, suri :: String
, spath :: FilePath
, supdate :: FilePath -> IO ()
}
data Action =
Link FilePath FilePath
| Copy FilePath FilePath CopySpec
| Template FilePath FilePath (forall t. TemplateSystem t => t -> Text -> Text)
| Command FilePath CmdSpec
| Patch FilePath FilePath PatchSpec
data CopySpec =
OnlyDirectories
| OnlyFiles
| BothDirectoriesAndFiles
deriving (Show, Read)
data PatchSpec = PatchSpec
{ strip :: Int
, reversely :: Bool
} deriving (Show, Read)
instance Default PatchSpec where
def = PatchSpec
{ strip = 1
, reversely = False
}
data Modifier = Wait (Set Token)