biegunka-0.2: DSL definitions, interpreters, templating, git support

Safe HaskellNone

Control.Biegunka.Script

Contents

Description

Configuration script machinery

Gets interesting static information from script before passing it to interpreters, which then make use of it

Synopsis

Script types

newtype Script s a Source

Newtype used to provide better error messages for type errors in DSL (for users, mostly)

Constructors

Script 

Fields

unScript :: StreamT (Tokenize s) (ReaderT Annotations (StateT MAnnotations (Free (Term Annotate s)))) a
 

Instances

MonadReader Annotations (Script s) 
Monad (Script s) 
Functor (Script s) 
Applicative (Script s) 
(~ Scope scope Actions, ~ * a ()) => Eval (Script scope a)

Biegunka script shell commands

Default a => Default (Script s a) 

data family Annotate sc :: *Source

Language Term annotations

Different scopes require different kinds of annotations, so it is a family of them

Annotations

data MAnnotations Source

Script annotations state

Mnemonic is 'Mutable Annotations'

data Annotations Source

Script annotations environment

Environment

class HasRoot s whereSource

Methods

root :: Lens' s FilePathSource

Biegunka root

class HasSource s whereSource

Methods

source :: Lens' s FilePathSource

Source root

Get annotated script

runScript :: MAnnotations -> Annotations -> Infinite (Tokenize s) -> Script s a -> (Free (Term Annotate s) a, MAnnotations)Source

Get annotated DSL and resulting annotations alongside

evalScript :: MAnnotations -> Annotations -> Infinite (Tokenize s) -> Script s a -> Free (Term Annotate s) aSource

Get annotated DSL without annotations

Script mangling

script :: Term Annotate s a -> Script s aSource

Lift DSL term to annotated Script

sourced :: String -> URI -> FilePath -> Script Actions () -> (FilePath -> IO ()) -> Script Sources ()Source

Abstract away all plumbing needed to make source

actioned :: (FilePath -> FilePath -> Action) -> Script Actions ()Source

Get Actions scope script from FilePath mangling

constructTargetFilePath :: FilePath -> FilePath -> FilePath -> FilePathSource

Construct destination FilePath

>>> constructTargetFilePath "" "" ""
""
>>> constructTargetFilePath "/root" "from" "to"
"/root/to"
>>> constructTargetFilePath "/root" "from" "to/"
"/root/to/from"
>>> constructTargetFilePath "/root" "from" (into "to")
"/root/to/from"
>>> constructTargetFilePath "/root" "from" "/to"
"/to"
>>> constructTargetFilePath "/root" "from" "/to/"
"/to/from"
>>> constructTargetFilePath "/root" "from" (into "/to")
"/to/from"

Lenses

app :: Lens' Annotations FilePathSource

Biegunka filepath root

profileName :: Lens' Annotations StringSource

Current profile name

sourcePath :: Lens' Annotations FilePathSource

Current source filepath

sourceURL :: Lens' Annotations StringSource

Current source url

profiles :: Lens' MAnnotations (Set String)Source

All profiles encountered so far

order :: Lens' MAnnotations IntSource

Current action order

sourceReaction :: Lens' Annotations ReactSource

How to react on source failure

actionReaction :: Lens' Annotations ReactSource

How to react on action failure

activeUser :: Lens' Annotations (Maybe UserW)Source

Current user

maxRetries :: Lens' Annotations RetrySource

Maximum retries count

Misc

type URI = StringSource

Repository URI (like git@github.com:whoever/whatever.git)

data UserW Source

Wrapper around User hiding particular implementation from the type sistem

Constructors

forall u . UserW (User u) 

Instances

data User u whereSource

User setting modifier

Constructors

UserID :: CUid -> User CUid 
Username :: String -> User String 

Instances

~ * u CUid => Num (User u)

Because I can

Show (User u) 
~ * u String => IsString (User u) 

data React Source

Failure reaction

Used then all retries errored

Constructors

Ignorant 
Abortive 

newtype Retry Source

Retries count

Constructors

Retry 

Fields

unRetry :: Int
 

Instances

incr :: Retry -> RetrySource

Increment retry count

into :: FilePath -> FilePathSource

A hack to support the notion of making destination FilePath inside some directory