dhall-text: Template text using Dhall

[ bsd3, compiler, deprecated, program ] [ Propose Tags ] [ Report a vulnerability ]
Deprecated in favor of dhall

This package provides a dhall-to-text executable that templates text using the Dhall configuration language

This package is now superseded by the dhall text command from the dhall package


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.0.9, 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14, 1.0.15, 1.0.16, 1.0.17, 1.0.18
Dependencies base (>=4.8.0.0 && <5), dhall (>=1.15.0 && <1.25), optparse-applicative (<0.16), text (>=0.11.1.0 && <1.3) [details]
Tested with ghc ==7.10.3, ghc ==8.4.3, ghc ==8.6.1
License BSD-3-Clause
Copyright 2017 Gabriella Gonzalez
Author Gabriella Gonzalez
Maintainer GenuineGabriella@gmail.com
Revised Revision 3 made by GabrielGonzalez at 2022-09-04T22:40:46Z
Category Compiler
Bug tracker https://github.com/dhall-lang/dhall-haskell/issues
Source repo head: git clone https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-text
Uploaded by GabrielGonzalez at 2019-06-07T00:16:55Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables dhall-to-text
Downloads 11202 total (42 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2019-06-07 [all 3 reports]

Readme for dhall-text-1.0.18

[back to package description]

dhall-text

For installation or development instructions, see:

Introduction

This dhall-text package provides a dhall-to-text executable which you can use to template text using the Dhall configuration language.

Example

Suppose you save the following files to your current directory:

$ cat Person
-- Dhall is a typed programming language

-- This file is the type of an anonymous record
{ name : Text, upvotes : Natural }
$ cat people
-- Dhall natively supports lists and anonymous records

[ { name = "Maria" , upvotes = 14 }
, { name = "Jordan", upvotes =  2 }
, { name = "Pranav", upvotes =  1 }
]

{- This file has type:
  
       ./people : List { name : Text, upvotes : Natural }
  
   ... or just:
  
       ./people : List ./Person
-}
$ cat make-item
    -- You can define anonymous functions in Dhall using a backslash (i.e. `\`)
    \(person : ./Person)  -- You can import any type or expression by its path

    {- Dhall supports multiline strings that strip leading whitespace and Dhall
       supports string interpolation, too, using `${...}` syntax
    -}
->  ''
    <li class="list-group-item">
      <span class="badge">${Natural/show person.upvotes}</span>
      ${person.name}
    </li>
    ''

{- This file has type:
  
       ./make-item : ./Person -> Text
-}
$ cat make-items
-- You can also import any type or expression by its URL
let List/map = https://prelude.dhall-lang.org/List/map

let Text/concat = https://prelude.dhall-lang.org/Text/concat

in  \(people : List ./Person) ->
        Text/concat (List/map ./Person Text ./make-item people)

{- This file has type:
  
       ./make-items : List ./Person -> Text
-}

Templating HTML is just ordinary function application:

$ dhall-to-text <<< './make-items ./people'
<li class="list-group-item">
  <span class="badge">14</span>
  Maria
</li>

<li class="list-group-item">
  <span class="badge">2</span>
  Jordan
</li>

<li class="list-group-item">
  <span class="badge">1</span>
  Pranav
</li>

To learn more about the Dhall configuration language, read the tutorial