Safe Haskell | None |
---|
Configuration script machinery
Gets interesting static information from script before passing it to interpreters, which then make use of it
- newtype Script s a = Script {
- unScript :: StreamT (Tokenize s) (ReaderT Annotations (StateT MAnnotations (Free (Term Annotate s)))) a
- data family Annotate sc :: *
- data MAnnotations
- data Annotations
- class HasRoot s where
- class HasSource s where
- runScript :: MAnnotations -> Annotations -> Infinite (Tokenize s) -> Script s a -> (Free (Term Annotate s) a, MAnnotations)
- evalScript :: MAnnotations -> Annotations -> Infinite (Tokenize s) -> Script s a -> Free (Term Annotate s) a
- script :: Term Annotate s a -> Script s a
- sourced :: String -> URI -> FilePath -> Script Actions () -> (FilePath -> IO ()) -> Script Sources ()
- actioned :: (FilePath -> FilePath -> Action) -> Script Actions ()
- constructTargetFilePath :: FilePath -> FilePath -> FilePath -> FilePath
- app :: Lens' Annotations FilePath
- profileName :: Lens' Annotations String
- sourcePath :: Lens' Annotations FilePath
- sourceURL :: Lens' Annotations String
- profiles :: Lens' MAnnotations (Set String)
- order :: Lens' MAnnotations Int
- sourceReaction :: Lens' Annotations React
- actionReaction :: Lens' Annotations React
- activeUser :: Lens' Annotations (Maybe UserW)
- maxRetries :: Lens' Annotations Retry
- type URI = String
- data UserW = forall u . UserW (User u)
- data User u where
- data React
- newtype Retry = Retry {}
- incr :: Retry -> Retry
- into :: FilePath -> FilePath
Script types
Newtype used to provide better error messages for type errors in DSL (for users, mostly)
Script | |
|
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'
Read MAnnotations | |
Show MAnnotations | |
Default MAnnotations |
data Annotations Source
Script annotations environment
Show Annotations | |
Default Annotations | |
HasSource Annotations | |
HasRoot Annotations | |
MonadReader Annotations (Script s) |
Environment
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
sourced :: String -> URI -> FilePath -> Script Actions () -> (FilePath -> IO ()) -> Script Sources ()Source
Abstract away all plumbing needed to make source
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
Wrapper around User
hiding particular
implementation from the type sistem
User setting modifier
Failure reaction
Used then all retries errored
Retries count