In favour of


Template text using Dhall

Version on this page:1.0.15
LTS Haskell 13.30:1.0.18
Stackage Nightly 2019-07-31:1.0.18@rev:1
Latest on Hackage:1.0.18@rev:3

See all snapshots dhall-text appears in

BSD-3-Clause licensed by Gabriel Gonzalez
Maintained by
This version can be pinned in stack with:dhall-text-1.0.15@sha256:d40195e9dc5e0c3cda8a5cec952a3762b9246f1a47bb21e2e0bc04e218ee6bc9,1011

Module documentation for 1.0.15

There are no documented modules for this package.


For installation or development instructions, see:


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


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>

{- 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 =

let 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>

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

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

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