MyNixOS website logo
Description

Parameterized file evaluator.

Please see the README on GitHub at https://github.com/ltext/ltext#README

ltext

λtext

General-Purpose Templating Utility

Overview

λtext turns text files into higher-order functions, featuring a Hindley-Milner / prenex polymorphic type system. See the github.io page.

Building

$> git clone [email protected]/ltext/ltext
$> cd ltext
$> stack install ltext

This should install in one pass; all the non-stackage dependencies are included in stack.yaml.

Using Nix

You can build with nix with the following command:

nix-build -A ltext.components.exes.ltext

Usage

$> ltext --help

λtext - parameterized file evaluator

Usage: ltext EXPRESSION [--version] [-t|--type] [-v|--verbose] [-r|--raw FILE]
             [--left LEFT] [--right RIGHT]
  Evaluate EXPRESSION and send the substitution to stdout. See
  http://ltext.github.io/ for more details.

Available options:
  -h,--help                Show this help text
  --version                Print the version number
  -t,--type                Perform type inference on an expression
  -v,--verbose             Be verbose, sending info through stderr
  -r,--raw FILE            Treat these files as plaintext without an arity
                           header
  --left LEFT              The left delimiter to use for rendering partially
                           applied files
  --right RIGHT            The right delimiter to use for rendering partially
                           applied files

$> ltext --type "\a -> a"

a0 -> a0

How It Works

From λtext's point of view, any text file can be a template (given that it's utf-8 encoded). Just declare parameters in the first line of your files (usually in a different syntax than the file's native tongue, via comments or obscure delimiters), then use those variables somewhere in the content. With the ltext command you can then apply the function-y files to each other.

The CLI

There will be two primary uses of the ltext command - evaluating template expressions, and querying for the type signature of a template/expression.

Type Queries

Just like the :t command in GHCi, you can find out the type of a template or expression with -t.

Expression Evaluation

All files have closed scope, meaning they only have access to the variables declared in the file. For instance:

{{ foo }}

...

Will only have access to the variable foo, while using the delimiters {{ and }} to escape your expression.

Variable Recognition

When we use a parameter in a file, we need it to be easily recognized by a parser; a different syntax than to the language you're working with.

The first line in a file will be parsed to see if it qualifies as a lambda header. If you don't want a file have recognized arity, just invoke ltext with the --raw argument listing the file:

$> ltext "foo bar" --raw "bar"

Credits

All credits go to Martin Grabmueller's AlgorithmW package for the type inference algorithm used in λtext.

Metadata

Version

0.1.5

Executables (1)

  • bin/ltext

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows