madlang: Randomized templating language DSL

[ bsd3, library, text ] [ Propose Tags ]

Please see README.md


[Skip to Readme]

Modules

[Index]

Flags

Automatic Flags
NameDescriptionDefault
llvm-fast

Enable build with llvm backend (produces a faster executable)

Disabled
library

Don't build an executable

Disabled
gold

Enable the gold linker for faster build times

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

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] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 1.0.0.0, 1.0.0.1, 1.0.1.0, 1.1.1.0, 1.1.2.0, 1.1.3.0, 2.0.0.0, 2.0.0.1, 2.0.1.0, 2.0.1.1, 2.0.1.2, 2.1.0.0, 2.1.0.1, 2.1.0.2, 2.1.0.3, 2.1.0.4, 2.1.1.0, 2.1.1.1, 2.1.1.2, 2.1.1.3, 2.1.2.0, 2.2.0.1, 2.3.0.2, 2.3.0.3, 2.3.0.4, 2.3.0.5, 2.3.0.6, 2.3.1.0, 2.3.1.1, 2.3.2.0, 2.4.0.0, 2.4.0.1, 2.4.0.2, 2.4.1.0, 2.4.1.1, 2.4.1.2, 2.4.1.3, 2.4.1.4, 2.4.1.5, 2.4.1.6, 2.4.2.0, 2.4.2.1, 2.4.2.2, 2.4.2.3, 2.4.2.4, 2.4.2.5, 2.4.2.6, 2.4.2.7, 2.4.2.8, 2.4.2.10, 2.4.2.11, 2.4.2.12, 2.4.2.13, 2.4.2.14, 2.4.2.20, 2.4.2.21, 2.4.2.22, 2.4.2.25, 3.0.0.0, 3.0.0.1, 3.0.0.3, 3.0.0.4, 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.5, 3.1.0.6, 3.1.0.7, 3.1.0.10, 3.1.1.0, 3.1.1.1, 3.1.1.6, 3.1.1.7, 3.1.1.13, 3.1.1.18, 3.1.1.20, 3.1.1.21, 3.1.2.0, 3.2.0.0, 3.2.0.1, 4.0.0.0, 4.0.0.1, 4.0.0.2, 4.0.0.3, 4.0.0.4, 4.0.1.0, 4.0.1.1, 4.0.2.0, 4.0.2.1, 4.0.2.2, 4.0.2.5, 4.0.2.6, 4.0.2.7, 4.0.2.8, 4.0.2.9, 4.0.2.11, 4.0.2.12, 4.0.2.13, 4.0.2.14, 4.0.2.15, 4.0.2.16
Dependencies ansi-wl-pprint, base (>=4.7 && <5), composition, composition-extra, containers, directory, file-embed, madlang, megaparsec (>=6.0 && <6.0.0), microlens, MonadRandom, mtl, optparse-applicative, random-shuffle, template-haskell, text [details]
License BSD-3-Clause
Copyright Copyright: (c) 2016-2017 Vanessa McHale
Author Vanessa McHale
Maintainer vanessa.mchale@reconfigure.io
Revised Revision 1 made by vmchale at 2018-04-02T02:50:54Z
Category Web
Home page https://github.com/vmchale/madlang#readme
Source repo head: darcs get https://hub.darcs.net/vmchale/madlang
Uploaded by vmchale at 2017-08-10T22:40:36Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables madlang
Downloads 61174 total (115 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-08-10 [all 1 reports]

Readme for madlang-2.4.0.2

[back to package description]

Madlang DSL for generating random text

Build Status

This is the Madlang DSL for generating text. You specify a template, and Madlang will create randomized text from the template.

Madlang is an interpreted language, written in Haskell. It runs from the command line, but also provides a Haskell library that can be integrated into other projects, compiled to a web app, or used as an EDSL.

There is also a vim plugin for syntax highlighting, available here.

It can be used for twitter bots (among other things) and provides human-readable syntax for generating text.

Examples

# Madlang is a declarative language. The most basic component is a function, viz.
:define coinFlip
    1.0 "heads"
    1.0 "tails"

:define die
    1.0 "1"
    1.0 "2"
    1.0 "3"
    1.0 "4"
    1.0 "5"
    1.0 "6"

# Madlang also has categories, that is, a collection of functions that can be
# bundled together
:category gambling
    coinFlip
    die

# :return declarations handle the actual output
:return
    0.7 gambling
    0.3 gambling.to_upper # .to_upper is a modifier which make the whole string uppercase

Syntax

There are two keywords in madlang you'll use most: :define and :return. :return is the main string we'll be spitting back; there can be only one per file. :define on the other hand can be used to make functions. These functions are combinations of templates, organizing pairs of weights and strings.

There is a Shakespearean insult generator demo available in demo/shakespeare.mad

Installation

Releases

Nix

If you're on linux or mac, you can get up-to-date binaries via nix.

Download nix with

curl https://nixos.org/nix/install | sh

From there, nix-env -i madlang will install the proper executables.

Stack

Download stack with

curl -sSL http://haskellstack.org | sh

Then run stack install madlang --resolver nightly and you'll get the madlang executable installed on your path. This may take a bit of time, as it will build all dependencies of madlang first.

Use

To use it, try

 $ madlang run demo/shakespeare.mad

You can do madlang --help if you want a couple other options for debugging.

Using the Haskell library

One function you might want to use is runFile; it reads a file and generates randomized text:

 λ:> runFile [] "demo/shakespeare.mad"
 "Thou hasty-witted gleeking puttock!"

To use the library as an EDSL, there are two options: splicing in a file or using a quasi-quoter, viz.

demo :: IO T.Text
demo = run
    $(madFile "demo/shakespeare.mad")

demo :: IO T.Text
demo = run [|madlang
:define f
    1.0 "heads"
    1.0 "tails"
:return
    1.0 f|]

Haddock documentation of all library functionality is located here.

Syntax Highlighting

Syntax highlighting for the DSL is provided in the vim plugin here. It includes integration with syntastic.