language-dockerfile 0.3.3.0 → 0.3.4.0
raw patch · 4 files changed
+27/−15 lines, 4 files
Files
- README.md +8/−1
- language-dockerfile.cabal +1/−1
- src/Language/Dockerfile.hs +2/−0
- src/Language/Dockerfile/EDSL.hs +16/−13
README.md view
@@ -1,4 +1,11 @@ # haskell-language-dockerfile+[](https://travis-ci.org/beijaflor-io/haskell-language-dockerfile)+[](https://circleci.com/gh/beijaflor-io/haskell-language-dockerfile)++[Hackage](https://hackage.haskell.org/package/language-dockerfile/)++[GH Pages Haddock](http://beijaflor-io.github.io/haskell-language-dockerfile/)+- - - Dockerfile linter, parser, pretty-printer and embedded DSL, forked from [hadolint](https://github.com/lukasmartinelli/hadolint). @@ -46,7 +53,7 @@ main = putStr $ toDockerfileStr $ do from "node" run "apt-get update"- run ["apt-get", "install", "something"]+ runArgs ["apt-get", "install", "something"] -- ... ```
language-dockerfile.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: language-dockerfile-version: 0.3.3.0+version: 0.3.4.0 synopsis: Dockerfile linter, parser, pretty-printer and embedded DSL description: Forked from @hadolint@. .
src/Language/Dockerfile.hs view
@@ -53,6 +53,8 @@ , Language.Dockerfile.EDSL.Quasi.edockerfile -- ** Support types for the EDSL+ , Language.Dockerfile.EDSL.EDockerfileM+ , Language.Dockerfile.EDSL.EDockerfileTM , Language.Dockerfile.EDSL.Types.EBaseImage(..) -- * QuasiQuoter (@Language.Dockerfile.EDSL.Quasi@)
src/Language/Dockerfile/EDSL.hs view
@@ -4,12 +4,9 @@ module Language.Dockerfile.EDSL where --- import Control.Exception--- import Data.List (isInfixOf) import Control.Monad.Free import Control.Monad.Free.TH-import Control.Monad.Identity (Identity)-import Control.Monad.Trans.Free (FreeT, iterTM, runFreeT)+import Control.Monad.Trans.Free (FreeT, iterTM) import Control.Monad.Writer import Data.ByteString (ByteString) @@ -18,6 +15,12 @@ import Language.Dockerfile.EDSL.Types +-- | The type of 'Identity' based EDSL blocks+type EDockerfileM = Free EInstruction++-- | The type of free monad EDSL blocks+type EDockerfileTM = FreeT EInstruction+ type EInstructionM = Free EInstruction type EInstructionTM = FreeT EInstruction @@ -25,7 +28,7 @@ runDockerWriter :: (MonadWriter [Syntax.Instruction] m)- => EInstructionM a -> m a+ => EDockerfileM a -> m a runDockerWriter = iterM runD runDockerWriterIO ::@@ -34,7 +37,7 @@ , Monad (t m) , MonadWriter [Syntax.Instruction] (t m) , MonadIO (t m)- ) => EInstructionTM m a -> t m a+ ) => EDockerfileTM m a -> t m a runDockerWriterIO = iterTM runD runDef :: MonadWriter [t] m => (t1 -> t) -> t1 -> m b -> m b@@ -72,7 +75,7 @@ -- | Runs the Dockerfile EDSL and returns a 'Dockerfile' you can pretty print -- or manipulate-toDockerfile :: EInstructionM a -> Syntax.Dockerfile+toDockerfile :: EDockerfileM a -> Syntax.Dockerfile toDockerfile e = let (_, w) = runWriter (runDockerWriter e) in map instructionPos w@@ -91,7 +94,7 @@ -- run (words "stack build --test --only-dependencies") -- cmd (words "stack test") -- @-toDockerfileStr :: EInstructionM a -> String+toDockerfileStr :: EDockerfileM a -> String toDockerfileStr = PrettyPrint.prettyPrint . toDockerfile untagged :: String -> EBaseImage@@ -132,26 +135,26 @@ -- @ onBuild :: MonadFree EInstruction m- => EInstructionM a+ => EDockerfileM a -> m () onBuild b = mapM_ (onBuildRaw . Syntax.instruction) (toDockerfile b) -- | A version of 'toDockerfile' which allows IO actions-toDockerfileIO :: MonadIO m => EInstructionTM m t -> m Syntax.Dockerfile+toDockerfileIO :: MonadIO m => EDockerfileTM m t -> m Syntax.Dockerfile toDockerfileIO e = liftM snd (runDockerfileIO e) -- | A version of 'toDockerfileStr' which allows IO actions-toDockerfileStrIO :: MonadIO m => EInstructionTM m t -> m String+toDockerfileStrIO :: MonadIO m => EDockerfileTM m t -> m String toDockerfileStrIO e = liftM snd (runDockerfileStrIO e) -- | Just runs the EDSL's writer monad-runDockerfileIO :: MonadIO m => EInstructionTM m t -> m (t, Syntax.Dockerfile)+runDockerfileIO :: MonadIO m => EDockerfileTM m t -> m (t, Syntax.Dockerfile) runDockerfileIO e = do (r, w) <- runWriterT (runDockerWriterIO e) return (r, map instructionPos w) -- | Runs the EDSL's writer monad and pretty-prints the result-runDockerfileStrIO :: MonadIO m => EInstructionTM m t -> m (t, String)+runDockerfileStrIO :: MonadIO m => EDockerfileTM m t -> m (t, String) runDockerfileStrIO e = do (r, w) <- runDockerfileIO e return (r, PrettyPrint.prettyPrint w)