The slug package

[Tags:bsd3, library, test]

Type-safe slugs for Yesod ecosystem.

[Skip to Readme]


Versions 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6
Change log
Dependencies aeson (>=0.8 && <1.2), base (>=4.7 && <5.0), exceptions (>=0.6 && <0.9), http-api-data (>=0.2 && <0.4), path-pieces (>=0.1.5 && <0.3), persistent (>=2.0 && <3.0), QuickCheck (>=2.4 && <3.0), text (>=1.0 && <1.3) [details]
License BSD3
Author Mark Karpov <>
Maintainer Mark Karpov <>
Stability Unknown
Category Web, Yesod
Home page
Bug tracker
Source repository head: git clone
Uploaded Tue Jan 3 00:00:51 UTC 2017 by mrkkrp
Distributions LTSHaskell:0.1.6, NixOS:0.1.6, Stackage:0.1.6, Tumbleweed:0.1.6
Downloads 316 total (14 in the last 30 days)
0 []
Status Docs available [build log]
Last success reported on 2017-01-03 [all 1 reports]




devTurn on development settings.DisabledManual

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


Maintainer's Corner

For package maintainers and hackage trustees

Readme for slug

Readme for slug-0.1.6


License BSD3 Hackage Stackage Nightly Stackage LTS Build Status Coverage Status

This is slug implementation that plays nicely with Yesod ecosystem. Although it's fairly easy to write this thing, slugs are useful and general enough to be coded once and be used again and again. So this little package eliminates some boilerplate you might find yourself writing.

Quick start

The package provides data type Slug that is instance of various type classes, so it can be used with Persistent or as part of route. It also works with aeson package.

The slugs are completely type-safe. When you have a Slug, you can be sure that there is a valid slug inside. Valid slug has the following qualities:

  • it's not empty;

  • it consists only of alpha-numeric groups of characters (words) separated by '-' dashes in such a way that entire slug cannot start or end in a dash and also two dashes in a row cannot be found;

  • every character with defined notion of case is lower-cased.

To use the package with persistent models, just import Web.Slug and add it to model file:

  slug Slug

Use it in route file like this:

/post/#Slug PostR GET

In Haskell code, create slugs from Text with mkSlug and extract their textual representation with unSlug. The following property holds:

mkSlug = mkSlug >=> mkSlug . unSlug


Copyright © 2015–2017 Mark Karpov

Distributed under BSD 3 clause license.