Replace `dhall-to-text` with `dhall text` subcommand (#1090)
Fixes #1087
This commit is contained in:
parent
8ae7b603fe
commit
90b62ee9d7
|
@ -11,7 +11,6 @@ the following packages:
|
||||||
* [`dhall-bash`](./dhall-bash) - [![Hackage](https://img.shields.io/hackage/v/dhall-bash.svg)](https://hackage.haskell.org/package/dhall-bash)
|
* [`dhall-bash`](./dhall-bash) - [![Hackage](https://img.shields.io/hackage/v/dhall-bash.svg)](https://hackage.haskell.org/package/dhall-bash)
|
||||||
* [`dhall-json`](./dhall-json) - [![Hackage](https://img.shields.io/hackage/v/dhall-json.svg)](https://hackage.haskell.org/package/dhall-json)
|
* [`dhall-json`](./dhall-json) - [![Hackage](https://img.shields.io/hackage/v/dhall-json.svg)](https://hackage.haskell.org/package/dhall-json)
|
||||||
* [`dhall-nix`](./dhall-nix) - [![Hackage](https://img.shields.io/hackage/v/dhall-nix.svg)](https://hackage.haskell.org/package/dhall-nix)
|
* [`dhall-nix`](./dhall-nix) - [![Hackage](https://img.shields.io/hackage/v/dhall-nix.svg)](https://hackage.haskell.org/package/dhall-nix)
|
||||||
* [`dhall-text`](./dhall-text) - [![Hackage](https://img.shields.io/hackage/v/dhall-text.svg)](https://hackage.haskell.org/package/dhall-text)
|
|
||||||
|
|
||||||
Navigate to each package's directory for their respective `README`s
|
Navigate to each package's directory for their respective `README`s
|
||||||
|
|
||||||
|
@ -41,7 +40,6 @@ visit one of the following links:
|
||||||
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-json/latest](https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-json/latest)
|
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-json/latest](https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-json/latest)
|
||||||
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-nix/latest](https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-nix/latest)
|
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-nix/latest](https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-nix/latest)
|
||||||
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-lsp-server/latest](https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-lsp-server/latest)
|
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-lsp-server/latest](https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-lsp-server/latest)
|
||||||
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-text/latest](https://hydra.dhall-lang.org/job/dhall-haskell/master/linux-dhall-text/latest)
|
|
||||||
|
|
||||||
You can then click the "Help" button in the bottom right corner, which will
|
You can then click the "Help" button in the bottom right corner, which will
|
||||||
show you a `nix-env` command that you can run to install the prebuilt
|
show you a `nix-env` command that you can run to install the prebuilt
|
||||||
|
@ -71,7 +69,6 @@ download image archives for each package using the following URLs:
|
||||||
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-json/latest/download/1/docker-image-dhall-json.tar.gz](https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-json/latest/download/1/docker-image-dhall-json.tar.gz)
|
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-json/latest/download/1/docker-image-dhall-json.tar.gz](https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-json/latest/download/1/docker-image-dhall-json.tar.gz)
|
||||||
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-lsp-server/latest/download/1/docker-image-dhall-lsp-server.tar.gz](https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-lsp-server/latest/download/1/docker-image-dhall-lsp-server.tar.gz)
|
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-lsp-server/latest/download/1/docker-image-dhall-lsp-server.tar.gz](https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-lsp-server/latest/download/1/docker-image-dhall-lsp-server.tar.gz)
|
||||||
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-nix/latest/download/1/docker-image-dhall-nix.tar.gz](https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-nix/latest/download/1/docker-image-dhall-nix.tar.gz)
|
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-nix/latest/download/1/docker-image-dhall-nix.tar.gz](https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-nix/latest/download/1/docker-image-dhall-nix.tar.gz)
|
||||||
* [https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-text/latest/download/1/docker-image-dhall-text.tar.gz](https://hydra.dhall-lang.org/job/dhall-haskell/master/image-dhall-text/latest/download/1/docker-image-dhall-text.tar.gz)
|
|
||||||
|
|
||||||
You can then load and run one of these archives like so:
|
You can then load and run one of these archives like so:
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ cache:
|
||||||
- .stack-work -> '%STACK_YAML%'
|
- .stack-work -> '%STACK_YAML%'
|
||||||
- dhall\.stack-work -> '%STACK_YAML%'
|
- dhall\.stack-work -> '%STACK_YAML%'
|
||||||
- dhall-json\.stack-work -> '%STACK_YAML%'
|
- dhall-json\.stack-work -> '%STACK_YAML%'
|
||||||
- dhall-text\.stack-work -> '%STACK_YAML%'
|
|
||||||
- dhall-bash\.stack-work -> '%STACK_YAML%'
|
- dhall-bash\.stack-work -> '%STACK_YAML%'
|
||||||
- dhall-lsp-server\.stack-work -> '%STACK_YAML%'
|
- dhall-lsp-server\.stack-work -> '%STACK_YAML%'
|
||||||
|
|
||||||
|
@ -51,7 +50,6 @@ for:
|
||||||
- 7z a "bin\dhall-json-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-to-yaml.exe"
|
- 7z a "bin\dhall-json-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-to-yaml.exe"
|
||||||
- 7z a "bin\dhall-json-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\json-to-dhall.exe"
|
- 7z a "bin\dhall-json-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\json-to-dhall.exe"
|
||||||
- 7z a "bin\dhall-json-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\yaml-to-dhall.exe"
|
- 7z a "bin\dhall-json-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\yaml-to-dhall.exe"
|
||||||
- 7z a "bin\dhall-text-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-to-text.exe"
|
|
||||||
- 7z a "bin\dhall-bash-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-to-bash.exe"
|
- 7z a "bin\dhall-bash-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-to-bash.exe"
|
||||||
- 7z a "bin\dhall-lsp-server-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-lsp-server.exe"
|
- 7z a "bin\dhall-lsp-server-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-lsp-server.exe"
|
||||||
|
|
||||||
|
@ -59,7 +57,6 @@ for:
|
||||||
test_script:
|
test_script:
|
||||||
- stack test dhall:tasty
|
- stack test dhall:tasty
|
||||||
- stack test dhall-json
|
- stack test dhall-json
|
||||||
- stack test dhall-text
|
|
||||||
- stack test dhall-bash
|
- stack test dhall-bash
|
||||||
# - stack test dhall-lsp-server # Disabled while the tests are broken.
|
# - stack test dhall-lsp-server # Disabled while the tests are broken.
|
||||||
- stack bench --benchmark-arguments "--quick --min-duration=0 --include-first-iter"
|
- stack bench --benchmark-arguments "--quick --min-duration=0 --include-first-iter"
|
||||||
|
@ -77,7 +74,6 @@ for:
|
||||||
# dhall-json and dhall-lsp-server is not supported for LTS 6, so do not try to copy the
|
# dhall-json and dhall-lsp-server is not supported for LTS 6, so do not try to copy the
|
||||||
# corresponding binaries
|
# corresponding binaries
|
||||||
- 7z a "bin\dhall-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall.exe"
|
- 7z a "bin\dhall-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall.exe"
|
||||||
- 7z a "bin\dhall-text-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-to-text.exe"
|
|
||||||
- 7z a "bin\dhall-bash-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-to-bash.exe"
|
- 7z a "bin\dhall-bash-%DEPLOY_SUFFIX%" "%APPVEYOR_BUILD_FOLDER%\bin\dhall-to-bash.exe"
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
|
@ -85,8 +81,6 @@ artifacts:
|
||||||
name: dhall
|
name: dhall
|
||||||
- path: bin\dhall-json-%DEPLOY_SUFFIX%
|
- path: bin\dhall-json-%DEPLOY_SUFFIX%
|
||||||
name: dhall-json
|
name: dhall-json
|
||||||
- path: bin\dhall-text-%DEPLOY_SUFFIX%
|
|
||||||
name: dhall-text
|
|
||||||
- path: bin\dhall-bash-%DEPLOY_SUFFIX%
|
- path: bin\dhall-bash-%DEPLOY_SUFFIX%
|
||||||
name: dhall-bash
|
name: dhall-bash
|
||||||
- path: bin\dhall-lsp-server-%DEPLOY_SUFFIX%
|
- path: bin\dhall-lsp-server-%DEPLOY_SUFFIX%
|
||||||
|
@ -96,7 +90,7 @@ deploy:
|
||||||
- provider: GitHub
|
- provider: GitHub
|
||||||
auth_token:
|
auth_token:
|
||||||
secure: Gs/tiz6Jtg/Zjd4zGHDhuSv4Y9a+zJ574LWwzOe2bvZNGX/M8XupkxdGmBpDlnOf
|
secure: Gs/tiz6Jtg/Zjd4zGHDhuSv4Y9a+zJ574LWwzOe2bvZNGX/M8XupkxdGmBpDlnOf
|
||||||
artifact: dhall, dhall-json, dhall-text, dhall-bash, dhall-lsp-server
|
artifact: dhall, dhall-json, dhall-bash, dhall-lsp-server
|
||||||
on:
|
on:
|
||||||
APPVEYOR_REPO_TAG: true
|
APPVEYOR_REPO_TAG: true
|
||||||
STACK_YAML: stack.yaml
|
STACK_YAML: stack.yaml
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
packages: ./dhall ./dhall-bash ./dhall-json ./dhall-text ./dhall-lsp-server
|
packages: ./dhall ./dhall-bash ./dhall-json ./dhall-lsp-server
|
||||||
|
|
|
@ -13,7 +13,6 @@ in
|
||||||
dhall-json
|
dhall-json
|
||||||
dhall-lsp-server
|
dhall-lsp-server
|
||||||
dhall-nix
|
dhall-nix
|
||||||
dhall-text
|
|
||||||
;
|
;
|
||||||
|
|
||||||
inherit (shared_ghcjs) dhall-try;
|
inherit (shared_ghcjs) dhall-try;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
Copyright (c) 2018 Gabriel Gonzalez
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
3. Neither the name of the author nor the names of its contributors may be
|
|
||||||
used to endorse or promote products derived from this software without
|
|
||||||
specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
@ -1,4 +1,7 @@
|
||||||
# `dhall-text`
|
# `dhall text`
|
||||||
|
|
||||||
|
The `dhall-text` executable is now subsumed by the `dhall text` subcommand,
|
||||||
|
which does the same thing. This `README` remains behind as a tutorial.
|
||||||
|
|
||||||
For installation or development instructions, see:
|
For installation or development instructions, see:
|
||||||
|
|
||||||
|
@ -6,8 +9,8 @@ For installation or development instructions, see:
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
This `dhall-text` package provides a `dhall-to-text` executable which you can
|
You can use the `dhall text` subcommand to template text using the Dhall
|
||||||
use to template text using the Dhall configuration language.
|
configuration language.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
@ -80,7 +83,7 @@ in \(people : List ./Person) ->
|
||||||
Templating HTML is just ordinary function application:
|
Templating HTML is just ordinary function application:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ dhall-to-text <<< './make-items ./people'
|
$ dhall text <<< './make-items ./people'
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<span class="badge">14</span>
|
<span class="badge">14</span>
|
||||||
Maria
|
Maria
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import Distribution.Simple
|
|
||||||
main = defaultMain
|
|
|
@ -1 +0,0 @@
|
||||||
(import ../nix/shared.nix {}).possibly-static.dhall-text
|
|
|
@ -1,33 +0,0 @@
|
||||||
Name: dhall-text
|
|
||||||
Version: 1.0.18
|
|
||||||
Cabal-Version: >=1.8.0.2
|
|
||||||
Build-Type: Simple
|
|
||||||
Tested-With: GHC == 7.10.3, GHC == 8.4.3, GHC == 8.6.1
|
|
||||||
License: BSD3
|
|
||||||
License-File: LICENSE
|
|
||||||
Copyright: 2017 Gabriel Gonzalez
|
|
||||||
Author: Gabriel Gonzalez
|
|
||||||
Maintainer: Gabriel439@gmail.com
|
|
||||||
Bug-Reports: https://github.com/dhall-lang/dhall-haskell/issues
|
|
||||||
Synopsis: Template text using Dhall
|
|
||||||
Description:
|
|
||||||
This package provides a @dhall-to-text@ executable that templates text using
|
|
||||||
the Dhall configuration language
|
|
||||||
Category: Compiler
|
|
||||||
Extra-Source-Files:
|
|
||||||
README.md
|
|
||||||
Source-Repository head
|
|
||||||
Type: git
|
|
||||||
Location: https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-text
|
|
||||||
|
|
||||||
Executable dhall-to-text
|
|
||||||
Hs-Source-Dirs: exec
|
|
||||||
Main-Is: Main.hs
|
|
||||||
Build-Depends:
|
|
||||||
base >= 4.8.0.0 && < 5 ,
|
|
||||||
dhall >= 1.15.0 && < 1.25,
|
|
||||||
optparse-applicative < 0.16,
|
|
||||||
text >= 0.11.1.0 && < 1.3
|
|
||||||
GHC-Options: -Wall
|
|
||||||
Other-Modules:
|
|
||||||
Paths_dhall_text
|
|
|
@ -1,63 +0,0 @@
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
|
||||||
|
|
||||||
import Control.Applicative ((<|>))
|
|
||||||
import Data.Monoid ((<>))
|
|
||||||
import Options.Applicative (Parser, ParserInfo)
|
|
||||||
|
|
||||||
import qualified Data.Text.IO
|
|
||||||
import qualified Data.Version
|
|
||||||
import qualified Dhall
|
|
||||||
import qualified Options.Applicative
|
|
||||||
import qualified Paths_dhall_text
|
|
||||||
|
|
||||||
data Options
|
|
||||||
= Default { explain :: Bool }
|
|
||||||
| Version
|
|
||||||
|
|
||||||
parseOptions :: Parser Options
|
|
||||||
parseOptions = parseVersion <|> parseDefault
|
|
||||||
where
|
|
||||||
parseVersion =
|
|
||||||
Options.Applicative.subparser
|
|
||||||
( Options.Applicative.command "version" parserInfoVersion
|
|
||||||
<> Options.Applicative.metavar "version"
|
|
||||||
)
|
|
||||||
where
|
|
||||||
parserInfoVersion =
|
|
||||||
Options.Applicative.info parser
|
|
||||||
( Options.Applicative.fullDesc
|
|
||||||
<> Options.Applicative.progDesc "Display version"
|
|
||||||
)
|
|
||||||
|
|
||||||
parser =
|
|
||||||
Options.Applicative.helper <*> pure Version
|
|
||||||
|
|
||||||
parseDefault = Default <$> parseExplain
|
|
||||||
where
|
|
||||||
parseExplain =
|
|
||||||
Options.Applicative.switch
|
|
||||||
( Options.Applicative.long "explain"
|
|
||||||
<> Options.Applicative.help "Explain error messages in detail"
|
|
||||||
)
|
|
||||||
|
|
||||||
parserInfoOptions :: ParserInfo Options
|
|
||||||
parserInfoOptions =
|
|
||||||
Options.Applicative.info
|
|
||||||
(Options.Applicative.helper <*> parseOptions)
|
|
||||||
( Options.Applicative.progDesc "Template text using Dhall"
|
|
||||||
<> Options.Applicative.fullDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main = do
|
|
||||||
options <- Options.Applicative.execParser parserInfoOptions
|
|
||||||
|
|
||||||
case options of
|
|
||||||
Default {..} -> do
|
|
||||||
let detail = if explain then Dhall.detailed else id
|
|
||||||
code <- Data.Text.IO.getContents
|
|
||||||
text <- detail (Dhall.input Dhall.auto code)
|
|
||||||
Data.Text.IO.putStr text
|
|
||||||
|
|
||||||
Version -> do
|
|
||||||
putStrLn (Data.Version.showVersion Paths_dhall_text.version)
|
|
|
@ -1 +0,0 @@
|
||||||
(import ../nix/shared.nix {}).shell-dhall-text
|
|
|
@ -230,6 +230,8 @@ data InvalidType s a = InvalidType
|
||||||
}
|
}
|
||||||
deriving (Typeable)
|
deriving (Typeable)
|
||||||
|
|
||||||
|
instance (Pretty s, Typeable s, Pretty a, Typeable a) => Exception (InvalidType s a)
|
||||||
|
|
||||||
_ERROR :: String
|
_ERROR :: String
|
||||||
_ERROR = "\ESC[1;31mError\ESC[0m"
|
_ERROR = "\ESC[1;31mError\ESC[0m"
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import Data.Text (Text)
|
||||||
import Data.Text.Prettyprint.Doc (Doc, Pretty)
|
import Data.Text.Prettyprint.Doc (Doc, Pretty)
|
||||||
import Data.Version (showVersion)
|
import Data.Version (showVersion)
|
||||||
import Dhall.Binary (StandardVersion)
|
import Dhall.Binary (StandardVersion)
|
||||||
import Dhall.Core (Expr(..), Import, pretty)
|
import Dhall.Core (Expr(Annot), Import, pretty)
|
||||||
import Dhall.Freeze (Intent(..), Scope(..))
|
import Dhall.Freeze (Intent(..), Scope(..))
|
||||||
import Dhall.Import (Imported(..), Depends(..))
|
import Dhall.Import (Imported(..), Depends(..))
|
||||||
import Dhall.Parser (Src)
|
import Dhall.Parser (Src)
|
||||||
|
@ -100,6 +100,7 @@ data Mode
|
||||||
| Lint { inplace :: Maybe FilePath }
|
| Lint { inplace :: Maybe FilePath }
|
||||||
| Encode { file :: Maybe FilePath, json :: Bool }
|
| Encode { file :: Maybe FilePath, json :: Bool }
|
||||||
| Decode { file :: Maybe FilePath, json :: Bool }
|
| Decode { file :: Maybe FilePath, json :: Bool }
|
||||||
|
| Text { file :: Maybe FilePath }
|
||||||
|
|
||||||
data ResolveMode
|
data ResolveMode
|
||||||
= Dot
|
= Dot
|
||||||
|
@ -186,6 +187,10 @@ parseMode =
|
||||||
"decode"
|
"decode"
|
||||||
"Decode a Dhall expression from binary"
|
"Decode a Dhall expression from binary"
|
||||||
(Decode <$> optional parseFile <*> parseJSONFlag)
|
(Decode <$> optional parseFile <*> parseJSONFlag)
|
||||||
|
<|> subcommand
|
||||||
|
"text"
|
||||||
|
"Render a Dhall expression that evaluates to a Text literal"
|
||||||
|
(Text <$> optional parseFile)
|
||||||
<|> (Default <$> optional parseFile <*> parseAnnotate <*> parseAlpha)
|
<|> (Default <$> optional parseFile <*> parseAnnotate <*> parseAlpha)
|
||||||
where
|
where
|
||||||
argument =
|
argument =
|
||||||
|
@ -567,6 +572,27 @@ command (Options {..}) = do
|
||||||
|
|
||||||
renderDoc System.IO.stdout doc
|
renderDoc System.IO.stdout doc
|
||||||
|
|
||||||
|
Text {..} -> do
|
||||||
|
expression <- getExpression file
|
||||||
|
|
||||||
|
resolvedExpression <- State.evalStateT (Dhall.Import.loadWith expression) (toStatus file)
|
||||||
|
|
||||||
|
_ <- Dhall.Core.throws (Dhall.TypeCheck.typeOf (Annot resolvedExpression Dhall.Core.Text))
|
||||||
|
|
||||||
|
let normalizedExpression = Dhall.Core.normalize resolvedExpression
|
||||||
|
|
||||||
|
case normalizedExpression of
|
||||||
|
Dhall.Core.TextLit (Dhall.Core.Chunks [] text) -> do
|
||||||
|
Data.Text.IO.putStr text
|
||||||
|
_ -> do
|
||||||
|
let invalidTypeExpected :: Expr X X
|
||||||
|
invalidTypeExpected = Dhall.Core.Text
|
||||||
|
|
||||||
|
let invalidTypeExpression :: Expr X X
|
||||||
|
invalidTypeExpression = normalizedExpression
|
||||||
|
|
||||||
|
Control.Exception.throwIO (Dhall.InvalidType {..})
|
||||||
|
|
||||||
-- | Entry point for the @dhall@ executable
|
-- | Entry point for the @dhall@ executable
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
|
|
@ -7,7 +7,6 @@ let
|
||||||
"dhall-json"
|
"dhall-json"
|
||||||
"dhall-lsp-server"
|
"dhall-lsp-server"
|
||||||
"dhall-nix"
|
"dhall-nix"
|
||||||
"dhall-text"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
fetchNixpkgs = import ./fetchNixpkgs.nix;
|
fetchNixpkgs = import ./fetchNixpkgs.nix;
|
||||||
|
@ -139,7 +138,6 @@ let
|
||||||
# to ../dhall/dhall-lang/
|
# to ../dhall/dhall-lang/
|
||||||
# "dhall-lsp-server"
|
# "dhall-lsp-server"
|
||||||
"dhall-nix"
|
"dhall-nix"
|
||||||
"dhall-text"
|
|
||||||
]
|
]
|
||||||
# Test suite doesn't work on GHCJS or GHC 7.10.3
|
# Test suite doesn't work on GHCJS or GHC 7.10.3
|
||||||
++ pkgsNew.lib.optional (!(compiler == "ghcjs" || compiler == "ghc7103")) "dhall"
|
++ pkgsNew.lib.optional (!(compiler == "ghcjs" || compiler == "ghc7103")) "dhall"
|
||||||
|
@ -153,7 +151,6 @@ let
|
||||||
"dhall"
|
"dhall"
|
||||||
"dhall-bash"
|
"dhall-bash"
|
||||||
"dhall-json"
|
"dhall-json"
|
||||||
"dhall-text"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
extension =
|
extension =
|
||||||
|
@ -196,12 +193,6 @@ let
|
||||||
(pkgsNew.sdist ../dhall-nix)
|
(pkgsNew.sdist ../dhall-nix)
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
dhall-text =
|
|
||||||
haskellPackagesNew.callCabal2nix
|
|
||||||
"dhall-text"
|
|
||||||
(pkgsNew.sdist ../dhall-text)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
dhall-try =
|
dhall-try =
|
||||||
pkgsNew.haskell.lib.overrideCabal
|
pkgsNew.haskell.lib.overrideCabal
|
||||||
(haskellPackagesNew.callCabal2nix
|
(haskellPackagesNew.callCabal2nix
|
||||||
|
@ -536,9 +527,6 @@ let
|
||||||
|
|
||||||
dhall-nix-static =
|
dhall-nix-static =
|
||||||
pkgsNew.haskell.lib.statify haskellPackagesOld.dhall-nix;
|
pkgsNew.haskell.lib.statify haskellPackagesOld.dhall-nix;
|
||||||
|
|
||||||
dhall-text-static =
|
|
||||||
pkgsNew.haskell.lib.statify haskellPackagesOld.dhall-text;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
@ -594,7 +582,6 @@ let
|
||||||
dhall-json = makeStaticIfPossible "dhall-json" ;
|
dhall-json = makeStaticIfPossible "dhall-json" ;
|
||||||
dhall-lsp-server = makeStaticIfPossible "dhall-lsp-server";
|
dhall-lsp-server = makeStaticIfPossible "dhall-lsp-server";
|
||||||
dhall-nix = makeStaticIfPossible "dhall-nix" ;
|
dhall-nix = makeStaticIfPossible "dhall-nix" ;
|
||||||
dhall-text = makeStaticIfPossible "dhall-text" ;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
toDockerImage = name:
|
toDockerImage = name:
|
||||||
|
@ -622,11 +609,10 @@ in
|
||||||
tarball-dhall-json = makeTarball "dhall-json" ;
|
tarball-dhall-json = makeTarball "dhall-json" ;
|
||||||
tarball-dhall-lsp-server = makeTarball "dhall-lsp-server";
|
tarball-dhall-lsp-server = makeTarball "dhall-lsp-server";
|
||||||
tarball-dhall-nix = makeTarball "dhall-nix" ;
|
tarball-dhall-nix = makeTarball "dhall-nix" ;
|
||||||
tarball-dhall-text = makeTarball "dhall-text" ;
|
|
||||||
|
|
||||||
inherit (pkgs) tarball-website website;
|
inherit (pkgs) tarball-website website;
|
||||||
|
|
||||||
inherit (pkgs.haskell.packages."${compiler}") dhall dhall-bash dhall-json dhall-lsp-server dhall-nix dhall-text dhall-try;
|
inherit (pkgs.haskell.packages."${compiler}") dhall dhall-bash dhall-json dhall-lsp-server dhall-nix dhall-try;
|
||||||
|
|
||||||
inherit (pkgs.releaseTools) aggregate;
|
inherit (pkgs.releaseTools) aggregate;
|
||||||
|
|
||||||
|
@ -635,7 +621,6 @@ in
|
||||||
shell-dhall-json = pkgs.haskell.packages."${compiler}".dhall-json.env ;
|
shell-dhall-json = pkgs.haskell.packages."${compiler}".dhall-json.env ;
|
||||||
shell-dhall-lsp-server = pkgs.haskell.packages."${compiler}".dhall-lsp-server.env;
|
shell-dhall-lsp-server = pkgs.haskell.packages."${compiler}".dhall-lsp-server.env;
|
||||||
shell-dhall-nix = pkgs.haskell.packages."${compiler}".dhall-nix.env ;
|
shell-dhall-nix = pkgs.haskell.packages."${compiler}".dhall-nix.env ;
|
||||||
shell-dhall-text = pkgs.haskell.packages."${compiler}".dhall-text.env ;
|
|
||||||
shell-dhall-try = pkgs.haskell.packages."${compiler}".dhall-try.env ;
|
shell-dhall-try = pkgs.haskell.packages."${compiler}".dhall-try.env ;
|
||||||
|
|
||||||
image-dhall = toDockerImage "dhall" ;
|
image-dhall = toDockerImage "dhall" ;
|
||||||
|
@ -643,7 +628,6 @@ in
|
||||||
image-dhall-json = toDockerImage "dhall-json" ;
|
image-dhall-json = toDockerImage "dhall-json" ;
|
||||||
image-dhall-lsp-server = toDockerImage "dhall-lsp-server";
|
image-dhall-lsp-server = toDockerImage "dhall-lsp-server";
|
||||||
image-dhall-nix = toDockerImage "dhall-nix" ;
|
image-dhall-nix = toDockerImage "dhall-nix" ;
|
||||||
image-dhall-text = toDockerImage "dhall-text" ;
|
|
||||||
|
|
||||||
test-dhall =
|
test-dhall =
|
||||||
pkgs.mkShell
|
pkgs.mkShell
|
||||||
|
|
|
@ -33,7 +33,6 @@ in
|
||||||
# shared_7_10_3.dhall-lsp-server
|
# shared_7_10_3.dhall-lsp-server
|
||||||
# `hnix` depends on `lens-family-th`, which doesn't support GHC 7.10.3
|
# `hnix` depends on `lens-family-th`, which doesn't support GHC 7.10.3
|
||||||
# shared_7_10_3.dhall-nix
|
# shared_7_10_3.dhall-nix
|
||||||
shared_7_10_3.dhall-text
|
|
||||||
|
|
||||||
# Verify that the packages build against the latest supported version
|
# Verify that the packages build against the latest supported version
|
||||||
# of the compiler
|
# of the compiler
|
||||||
|
@ -44,7 +43,6 @@ in
|
||||||
# shared_8_6_1.dhall-lsp-server
|
# shared_8_6_1.dhall-lsp-server
|
||||||
# `hnix` depends on `unix-2.7.*` and doesn't work with GHC 8.6
|
# `hnix` depends on `unix-2.7.*` and doesn't work with GHC 8.6
|
||||||
# shared_8_6_1.dhall-nix
|
# shared_8_6_1.dhall-nix
|
||||||
shared_8_6_1.dhall-text
|
|
||||||
|
|
||||||
# However, we still use GHC 8.4.3 to build the distributed tarballs
|
# However, we still use GHC 8.4.3 to build the distributed tarballs
|
||||||
# due to a bug in GHC 8.6.1. See:
|
# due to a bug in GHC 8.6.1. See:
|
||||||
|
@ -55,7 +53,6 @@ in
|
||||||
shared.tarball-dhall-json
|
shared.tarball-dhall-json
|
||||||
shared.tarball-dhall-lsp-server
|
shared.tarball-dhall-lsp-server
|
||||||
shared.tarball-dhall-nix
|
shared.tarball-dhall-nix
|
||||||
shared.tarball-dhall-text
|
|
||||||
|
|
||||||
shared_ghcjs.tarball-website
|
shared_ghcjs.tarball-website
|
||||||
|
|
||||||
|
@ -77,7 +74,6 @@ in
|
||||||
tarball-dhall-json
|
tarball-dhall-json
|
||||||
tarball-dhall-lsp-server
|
tarball-dhall-lsp-server
|
||||||
tarball-dhall-nix
|
tarball-dhall-nix
|
||||||
tarball-dhall-text
|
|
||||||
;
|
;
|
||||||
|
|
||||||
linux-dhall = shared_linux.possibly-static.dhall;
|
linux-dhall = shared_linux.possibly-static.dhall;
|
||||||
|
@ -85,7 +81,6 @@ in
|
||||||
linux-dhall-json = shared_linux.possibly-static.dhall-json;
|
linux-dhall-json = shared_linux.possibly-static.dhall-json;
|
||||||
linux-dhall-lsp-server = shared_linux.possibly-static.dhall-lsp-server;
|
linux-dhall-lsp-server = shared_linux.possibly-static.dhall-lsp-server;
|
||||||
linux-dhall-nix = shared_linux.possibly-static.dhall-nix;
|
linux-dhall-nix = shared_linux.possibly-static.dhall-nix;
|
||||||
linux-dhall-text = shared_linux.possibly-static.dhall-text;
|
|
||||||
|
|
||||||
inherit (shared_linux)
|
inherit (shared_linux)
|
||||||
image-dhall
|
image-dhall
|
||||||
|
@ -93,6 +88,5 @@ in
|
||||||
image-dhall-json
|
image-dhall-json
|
||||||
image-dhall-lsp-server
|
image-dhall-lsp-server
|
||||||
image-dhall-nix
|
image-dhall-nix
|
||||||
image-dhall-text
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ shared.pkgs.runCommand "dhall-shell-${shell}" {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
static.dhall
|
static.dhall
|
||||||
static.dhall-json
|
static.dhall-json
|
||||||
static.dhall-text
|
|
||||||
static.dhall-bash
|
static.dhall-bash
|
||||||
static.dhall-nix
|
static.dhall-nix
|
||||||
];
|
];
|
||||||
|
@ -22,7 +21,6 @@ shared.pkgs.runCommand "dhall-shell-${shell}" {
|
||||||
echo " $ nix-shell --argstr shell zsh"
|
echo " $ nix-shell --argstr shell zsh"
|
||||||
|
|
||||||
source <(dhall --${shell}-completion-script dhall)
|
source <(dhall --${shell}-completion-script dhall)
|
||||||
source <(dhall-to-text --${shell}-completion-script dhall-to-text)
|
|
||||||
source <(dhall-to-bash --${shell}-completion-script dhall-to-bash)
|
source <(dhall-to-bash --${shell}-completion-script dhall-to-bash)
|
||||||
source <(dhall-to-nix --${shell}-completion-script dhall-to-nix)
|
source <(dhall-to-nix --${shell}-completion-script dhall-to-nix)
|
||||||
source <(dhall-to-json --${shell}-completion-script dhall-to-json)
|
source <(dhall-to-json --${shell}-completion-script dhall-to-json)
|
||||||
|
|
|
@ -3,7 +3,6 @@ packages:
|
||||||
- dhall
|
- dhall
|
||||||
- dhall-bash
|
- dhall-bash
|
||||||
- dhall-json
|
- dhall-json
|
||||||
- dhall-text
|
|
||||||
- dhall-lsp-server
|
- dhall-lsp-server
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- megaparsec-7.0.4
|
- megaparsec-7.0.4
|
||||||
|
|
|
@ -2,7 +2,6 @@ resolver: lts-6.27
|
||||||
packages:
|
packages:
|
||||||
- dhall
|
- dhall
|
||||||
- dhall-bash
|
- dhall-bash
|
||||||
- dhall-text
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- ansi-terminal-0.7.1.1
|
- ansi-terminal-0.7.1.1
|
||||||
- either-5
|
- either-5
|
||||||
|
|
|
@ -3,7 +3,6 @@ packages:
|
||||||
- dhall
|
- dhall
|
||||||
- dhall-bash
|
- dhall-bash
|
||||||
- dhall-json
|
- dhall-json
|
||||||
- dhall-text
|
|
||||||
- dhall-lsp-server
|
- dhall-lsp-server
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- repline-0.2.1.0
|
- repline-0.2.1.0
|
||||||
|
|
Loading…
Reference in New Issue