HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulehakyll-4.17.0.0Haskell2010

Hakyll.Core.Identifier.Pattern

As Identifier is used to specify a single item, a Pattern is used to specify a list of items.

In most cases, globs are used for patterns.

A very simple pattern of such a pattern is "foo/bar". This pattern will only match the exact foo/bar identifier.

To match more than one identifier, there are different captures that one can use:

  • "*": matches at most one element of an identifier;

  • "**": matches one or more elements of an identifier.

Some examples:

  • "foo/*" will match "foo/bar" and "foo/foo", but not "foo/bar/qux";

  • "**" will match any identifier;

  • "foo/**" will match "foo/bar" and "foo/bar/qux", but not "bar/foo";

  • "foo/*.html" will match all HTML files in the "foo/" directory.

The capture function allows the user to get access to the elements captured by the capture elements in a glob or regex pattern.

  • 1 type
  • 14 values
  • Packagehakyll-4.17.0.0
  • Exports15
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourcePattern.hs

The pattern type

1 declaration
datadata Pattern
#

Type that allows matching on identifiers

Instances5Show, IsString, Semigroup, Monoid, Binary
  • Show PatternDefined in hakyll-4.17.0.0 · Hakyll.Core.Identifier.Pattern.Internal
  • IsString PatternDefined in hakyll-4.17.0.0 · Hakyll.Core.Identifier.Pattern · orphan
  • Semigroup PatternDefined in hakyll-4.17.0.0 · Hakyll.Core.Identifier.Pattern.Internal
  • Monoid PatternDefined in hakyll-4.17.0.0 · Hakyll.Core.Identifier.Pattern.Internal
  • Binary PatternDefined in hakyll-4.17.0.0 · Hakyll.Core.Identifier.Pattern.Internal

Creating patterns

6 declarations
valuefromList :: [Identifier] -> Pattern
#

Create a Pattern from a list of Identifiers it should match.

Warning: use this carefully with hasNoVersion and hasVersion. The Identifiers in the list already have versions assigned, and the pattern will then only match the intersection of both versions.

A more concrete example,

fromList ["foo.markdown"] .&&. hasVersion "pdf"

will not match anything! The "foo.markdown" Identifier has no version assigned, so the LHS of .&&. will only match this Identifier with no version. The RHS only matches Identifiers with version set to "pdf" -- hence, this pattern matches nothing.

The correct way to use this is:

fromList $ map (setVersion $ Just "pdf") ["foo.markdown"]
valuehasNoVersion :: Pattern
#

Match only if the identifier has no version set, e.g.

"foo/*.markdown" .&&. hasNoVersion

Composing patterns

3 declarations
valuecomplement :: Pattern -> Pattern
#

Inverts a pattern, e.g.

complement "foo/bar.html"

will match anything except "foo/bar.html"

Applying patterns

2 declarations

Capturing strings

3 declarations

Create an identifier from a pattern by filling in the captures with a given string

Example:

fromCapture (fromGlob "tags/*") "foo"

Result:

"tags/foo"

Orphan instances

1 instance