hindent-6.0.0: Extensible Haskell pretty printer
Safe HaskellSafe-Inferred
LanguageHaskell2010

HIndent.Pragma

Description

Pragma-related functions.

Synopsis

Documentation

extractPragmasFromCode Source #

Arguments

:: String 
-> [(String, String)]
(Pragma's name (e.g., LANGUAGE), Pragma's element (e.g., "CPP, DerivingVia"))

Extracts all pragmas from the given source code.

FIXME: The function is slow because it lexicographically analyzes the given source code. An alternative way is to use regular expressions. However, this method cannot determine if what appears to be a pragma is really a pragma, or requires complex regular expressions. For example, {-nn{-# LANGUAGE CPP #-}nn-} is not a pragma, but is likely to be recognized as such.

extractPragmaNameAndElement Source #

Arguments

:: String 
-> Maybe (String, String)
(Pragma's name (e.g., LANGUAGE), Pragma's element (e.g., "CPP, DerivingVia"))

Extracts the pragma's name and its element from the given pragma.

This function returns a Nothing if it fails to extract them.

pragmaRegex :: Regex Source #

A regex to match against a pragma.