Safe Haskell | None |
---|---|
Language | Haskell2010 |
- runHscaffold :: MonadIO m => FilePath -> WriterT ScaffoldActionV m a -> m a
- toHsfiles :: Writer ScaffoldActionV a -> Text
- writeToHsfiles :: MonadIO m => FilePath -> Writer ScaffoldActionV a -> m ()
- fromHsfiles :: String -> ScaffoldAction e
- fromHsfilesW :: MonadWriter (ScaffoldAction e) m => String -> m ()
- readHsfiles :: FilePath -> IO (ScaffoldAction e)
- hscaffoldFromDirectory :: FilePath -> IO (ScaffoldAction e)
- hscaffoldFromDirectoryWith :: ([FilePath] -> [FilePath]) -> FilePath -> IO (ScaffoldAction e)
- hscaffoldToHaskell :: Foldable t => t (ScaffoldActionType e) -> Text
- runAction :: FilePath -> ScaffoldActionType e -> IO ()
- runWriter :: Writer w a -> (a, w)
- runWriterT :: WriterT w m a -> m (a, w)
- directory :: MonadWriter (ScaffoldAction e) m => FilePath -> WriterT (ScaffoldAction e) m b -> m b
- file :: MonadWriter (ScaffoldAction e) m => FilePath -> Text -> m ()
- link :: MonadWriter (ScaffoldAction e) m => FilePath -> FilePath -> m ()
- copy :: MonadWriter (ScaffoldAction e) m => FilePath -> FilePath -> m ()
- touch :: MonadWriter (ScaffoldAction e) m => FilePath -> m ()
- permissions :: MonadWriter (ScaffoldAction e) m => FilePath -> Permissions -> m ()
- fileWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> Text -> m ()
- directoryWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> WriterT (ScaffoldAction e) m b -> m b
- copyWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> FilePath -> m ()
- touchWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> m ()
- data Permissions :: *
- type ScaffoldMonadT m a = WriterT ScaffoldActionV m a
- type ScaffoldMonadIO a = WriterT ScaffoldActionV IO a
- data ScaffoldActionType e
- type ScaffoldAction e = [ScaffoldActionType e]
- type ScaffoldActionV = ScaffoldAction ()
- type ScaffoldMonadET e m a = WriterT (ScaffoldAction e) m a
- withTemporaryHscaffold :: (MonadMask m, MonadIO m) => ScaffoldMonadT m a -> (FilePath -> m b) -> m b
- withTemporaryHscaffold' :: (MonadMask m, MonadIO m) => String -> ScaffoldMonadT m a -> (FilePath -> m b) -> m b
- withTemporaryHscaffoldIO :: ScaffoldMonadIO a -> (FilePath -> IO b) -> IO b
- withTemporaryHscaffoldIO' :: String -> ScaffoldMonadIO a -> (FilePath -> IO b) -> IO b
- runHscaffoldIO :: FilePath -> ScaffoldMonadIO a -> IO a
- mkActionPath :: FilePath -> FilePath -> FilePath
- data Text :: *
- module Control.Monad.IO.Class
- module Control.Monad.Writer
- module System.Directory
- module System.FilePath
Running Hscaffold
runHscaffold :: MonadIO m => FilePath -> WriterT ScaffoldActionV m a -> m a Source #
Run the scaffolding writer on the IO monad with no extensions
runHscaffold "." $ do file "./.gitignore" (Text.unlines [ ".stack-work" , "stuff" , "here" ]) directory "./src" $ do file "./Main.hs" "main = putStrLn \"Hello World\"" file "./Other.hs" "other = putStrLn \"Hello You\""
Convert Hscaffold to HSFILES (stack templates
)
toHsfiles :: Writer ScaffoldActionV a -> Text Source #
Run the scaffolding writer and return an .hsfiles
Text
to use with
stack-templates
writeToHsfiles :: MonadIO m => FilePath -> Writer ScaffoldActionV a -> m () Source #
Shortcut for
writeToHsfiles = do h <- toHsfiles w; liftIO $ Text.writeFile fp h
Convert HSFILES to Hscaffold
fromHsfiles :: String -> ScaffoldAction e Source #
Converts hsfiles to hscaffold actions
fromHsfilesW :: MonadWriter (ScaffoldAction e) m => String -> m () Source #
Converts hsfiles to a hscaffold monad
readHsfiles :: FilePath -> IO (ScaffoldAction e) Source #
Convert a directory to Hscaffold
hscaffoldFromDirectory :: FilePath -> IO (ScaffoldAction e) Source #
Converts a directory to scaffold actions
hscaffoldFromDirectoryWith :: ([FilePath] -> [FilePath]) -> FilePath -> IO (ScaffoldAction e) Source #
Converts a directory to scaffold actions with a custom filter function. By
default we ignore directories starting with .
Compile Hscaffold to Haskell code
hscaffoldToHaskell :: Foldable t => t (ScaffoldActionType e) -> Text Source #
Generates Haskell code from scaffold actions
Finer grained runners
runAction :: FilePath -> ScaffoldActionType e -> IO () Source #
Run a single scaffolding action on the IO monad with no extensions
runWriter :: Writer w a -> (a, w) #
Unwrap a writer computation as a (result, output) pair.
(The inverse of writer
.)
runWriterT :: WriterT w m a -> m (a, w) #
EDSL Combinators
directory :: MonadWriter (ScaffoldAction e) m => FilePath -> WriterT (ScaffoldAction e) m b -> m b Source #
Create a directory with the nested contents
file :: MonadWriter (ScaffoldAction e) m => FilePath -> Text -> m () Source #
Create a file with the given contents
link :: MonadWriter (ScaffoldAction e) m => FilePath -> FilePath -> m () Source #
Create a symbolic link between two filepaths
copy :: MonadWriter (ScaffoldAction e) m => FilePath -> FilePath -> m () Source #
Copy a file from A to B
Non-absolute paths are treated relative to the *current* root, nested blocks change the root
touch :: MonadWriter (ScaffoldAction e) m => FilePath -> m () Source #
Write the empty string to a file
Setting permissions
permissions :: MonadWriter (ScaffoldAction e) m => FilePath -> Permissions -> m () Source #
Set permissions on a filepath
fileWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> Text -> m () Source #
Create a file with the given contents and permissions
directoryWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> WriterT (ScaffoldAction e) m b -> m b Source #
Create a directory with the nested contents and permissions
copyWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> FilePath -> m () Source #
Copy a file from A to B and set permissions on B, see copy
touchWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> m () Source #
Write the empty string to a file with given permissions
data Permissions :: * #
Types
type ScaffoldMonadT m a = WriterT ScaffoldActionV m a Source #
The writer monad transformer for scaffold actions
type ScaffoldMonadIO a = WriterT ScaffoldActionV IO a Source #
The writer monad for scaffold actions, running in IO
data ScaffoldActionType e Source #
Type of actions scaffolding can make, ScaffoldActionTypeExtension
is open
for extension through other data-types
File FilePath Text | |
Link FilePath FilePath | |
Directory FilePath (ScaffoldAction e) | |
SetPermissions Permissions FilePath | |
Copy FilePath FilePath | |
ScaffoldActionTypeExtension e |
Eq e => Eq (ScaffoldActionType e) Source # | |
Ord e => Ord (ScaffoldActionType e) Source # | |
Show e => Show (ScaffoldActionType e) Source # | |
type ScaffoldAction e = [ScaffoldActionType e] Source #
Accumulator for actions
type ScaffoldActionV = ScaffoldAction () Source #
Accumulator for actions set with void extension
type ScaffoldMonadET e m a = WriterT (ScaffoldAction e) m a Source #
The writer monad transformer for scaffold actions with an extension
Utilities
withTemporaryHscaffold :: (MonadMask m, MonadIO m) => ScaffoldMonadT m a -> (FilePath -> m b) -> m b Source #
Creates a temporary directory with the scaffold and runs an action that takes it as its argument.
Uses withSystemTempDirectory
under the hood.
withTemporaryHscaffold (do file "something" "something" directory "something" $ file "something-else" "something" ) (tmp -> do undefined )
withTemporaryHscaffold' :: (MonadMask m, MonadIO m) => String -> ScaffoldMonadT m a -> (FilePath -> m b) -> m b Source #
withTemporaryHscaffoldIO :: ScaffoldMonadIO a -> (FilePath -> IO b) -> IO b Source #
withTemporaryHscaffoldIO' :: String -> ScaffoldMonadIO a -> (FilePath -> IO b) -> IO b Source #
Helpers
runHscaffoldIO :: FilePath -> ScaffoldMonadIO a -> IO a Source #
Very simple helper, if the second argument is absolute, returns it, otherwise, return it relative to the first argument
Re-exports
module Control.Monad.IO.Class
module Control.Monad.Writer
module System.Directory
module System.FilePath