The diagrams-svg package

[Tags:bsd3, library]

This package provides a modular backend for rendering diagrams created with the diagrams EDSL to SVG files. It uses blaze-svg to be a fast, native Haskell backend, making it suitable for use on any platform.

The package provides the following modules:

Additional documentation can be found in the README file distributed with the source tarball or viewable on GitHub:

[Skip to Readme]


Versions 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.7, 0.6,, 0.7, 0.8,,, 1.0, 1.0.1,,,, 1.0.2,, 1.1,,,,,, 1.3, 1.3.1,,,,,,,,,,, 1.4,,,,, 1.4.1 (info)
Change log CHANGES.markdown
Dependencies base (>=4.3 && <4.8), blaze-svg (>=0.3.3), bytestring (>=0.9 && <1.0), colour, containers (>=0.3 && <0.6), diagrams-core (==1.0.*), diagrams-lib (==1.0.*), directory, filepath, lens (>=3.8 && <4), monoid-extras (==0.3.*), mtl (>=1 && <2.2), old-time, process, split (>=0.1.2 && <0.3), time, unix (>=2.4 && <2.8), vector-space (>=0.7 && <0.9) [details]
License BSD3
Author Felipe Lessa, Deepak Jois
Category Graphics
Home page
Bug tracker
Source repository head: git clone
Uploaded Mon Nov 25 14:26:17 UTC 2013 by BrentYorgey
Distributions Debian:, LTSHaskell:1.4.1, NixOS:1.4.1, Stackage:1.4.1, Tumbleweed:1.4.1
Downloads 16056 total (150 in the last 30 days)
0 []
Status Docs available [build log]
Successful builds reported [all 1 reports]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees

Readme for diagrams-svg

Readme for diagrams-svg-1.0

Build Status

diagrams-svg is a an SVG backend for diagrams. Diagrams is a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language.

diagrams-svg is the default out-of-the box backend that comes with the diagrams framework, and supports most features defined in diagrams-lib.


cabal update && cabal install diagrams-svg


A simple example that uses diagrams-svg to draw a square.

import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine

b1 = square 20 # lw 0.002

main = mainWith (pad 1.1 b1)

Save this to file named Square.hs and compile this program:

ghc --make Square.hs

This will generate an executable which, when run produces an SVG file. Run the executable with the --help option to find out more about how to call it.

$ ./Square --help

Usage: ./Square [-w|--width WIDTH] [-h|--height HEIGHT] [-o|--output OUTPUT] [--loop] [-s|--src ARG] [-i|--interval INTERVAL]
  Command-line diagram generation.

Available options:
  -?,--help                Show this help text
  -w,--width WIDTH         Desired WIDTH of the output image
  -h,--height HEIGHT       Desired HEIGHT of the output image
  -o,--output OUTPUT       OUTPUT file
  -l,--loop                Run in a self-recompiling loop
  -s,--src ARG             Source file to watch
  -i,--interval INTERVAL   When running in a loop, check for changes every INTERVAL seconds.

You must pass an output file name with a .svg extension to generate the SVG file.

$ ./Square -o square.svg

The command above generates the SVG file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
<svg xmlns="" xmlns:xlink="" version="1.1" width="22.0" height="22.0" viewBox="0 0 22 22">
    <g stroke="rgb(0,0,0)" stroke-opacity="1.0" fill="rgb(0,0,0)" fill-opacity="0.0" stroke-width="2.0e-3">
       <path d="M 21.0,21.0 l -2.220446049250313e-15,-20.0 h -20.0 l -2.220446049250313e-15,20.0 Z" />