exon-1.1.0.0: Customizable Quasiquote Interpolation
Safe HaskellSafe-Inferred
LanguageHaskell2010

Exon.Class.Exon

Description

 
Synopsis

Documentation

newtype SkipWs a Source #

Wrapping a quote type with this causes whitespace to be ignored.

Since: 1.0.0.0

Constructors

SkipWs a 

Instances

Instances details
IsString a => IsString (SkipWs a) Source # 
Instance details

Defined in Exon.Class.Exon

Methods

fromString :: String -> SkipWs a #

Generic (SkipWs a) Source # 
Instance details

Defined in Exon.Class.Exon

Associated Types

type Rep (SkipWs a) :: Type -> Type #

Methods

from :: SkipWs a -> Rep (SkipWs a) x #

to :: Rep (SkipWs a) x -> SkipWs a #

Show a => Show (SkipWs a) Source # 
Instance details

Defined in Exon.Class.Exon

Methods

showsPrec :: Int -> SkipWs a -> ShowS #

show :: SkipWs a -> String #

showList :: [SkipWs a] -> ShowS #

Eq a => Eq (SkipWs a) Source # 
Instance details

Defined in Exon.Class.Exon

Methods

(==) :: SkipWs a -> SkipWs a -> Bool #

(/=) :: SkipWs a -> SkipWs a -> Bool #

IsString builder => ExonString (SkipWs result) builder Source #

The instance used when the result type is wrapped in SkipWs, which is done by intron.

It returns Empty for any whitespace.

Instance details

Defined in Exon.Class.Exon

Methods

exonString :: String -> Result builder Source #

exonWhitespace :: String -> Result builder Source #

type Rep (SkipWs a) Source # 
Instance details

Defined in Exon.Class.Exon

type Rep (SkipWs a) = D1 ('MetaData "SkipWs" "Exon.Class.Exon" "exon-1.1.0.0-FaDJAaYUpCcmICmdLf4NV" 'True) (C1 ('MetaCons "SkipWs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

skipWs :: SkipWs a -> a Source #

Defined separately because TH chokes on the selector.

Since: 1.0.0.0

newtype ExonUse a Source #

Wrapping a quote type with this causes a to be used irrespective of whether it is an unwrappable newtype.

Since: 1.0.0.0

Constructors

ExonUse 

Fields

Instances

Instances details
IsString a => IsString (ExonUse a) Source # 
Instance details

Defined in Exon.Class.Exon

Methods

fromString :: String -> ExonUse a #

Show a => Show (ExonUse a) Source # 
Instance details

Defined in Exon.Class.Exon

Methods

showsPrec :: Int -> ExonUse a -> ShowS #

show :: ExonUse a -> String #

showList :: [ExonUse a] -> ShowS #

Eq a => Eq (ExonUse a) Source # 
Instance details

Defined in Exon.Class.Exon

Methods

(==) :: ExonUse a -> ExonUse a -> Bool #

(/=) :: ExonUse a -> ExonUse a -> Bool #

ExonBuilder a builder => ExonBuilder (ExonUse a) builder Source # 
Instance details

Defined in Exon.Class.Exon

Methods

exonBuilder :: ExonUse a -> builder Source #

exonBuilderExtract :: Result builder -> ExonUse a Source #

class ExonBuilder (inner :: Type) (builder :: Type) | inner -> builder where Source #

This class converts a segment into a builder.

A builder is an auxiliary data type that may improve performance when concatenating segments, like Builder. The default instance uses no builder and is implemented as id.

Since: 1.0.0.0

Methods

exonBuilder :: inner -> builder Source #

Construct a builder from the newtype-unwrapped result type.

exonBuilderExtract :: Result builder -> inner Source #

Convert the result of the builder concatenation back to the newtype-unwrapped result type.

Instances

Instances details
ExonBuilder ByteString Builder Source # 
Instance details

Defined in Exon.Class.Exon

ExonBuilder LByteString Builder Source # 
Instance details

Defined in Exon.Class.Exon

ExonBuilder LText Builder Source # 
Instance details

Defined in Exon.Class.Exon

ExonBuilder Text Builder Source # 
Instance details

Defined in Exon.Class.Exon

(Monoid builder, result ~ builder) => ExonBuilder result builder Source # 
Instance details

Defined in Exon.Class.Exon

Methods

exonBuilder :: result -> builder Source #

exonBuilderExtract :: Result builder -> result Source #

ExonBuilder a builder => ExonBuilder (ExonUse a) builder Source # 
Instance details

Defined in Exon.Class.Exon

Methods

exonBuilder :: ExonUse a -> builder Source #

exonBuilderExtract :: Result builder -> ExonUse a Source #

class ExonString (result :: Type) (builder :: Type) where Source #

This class generalizes IsString for use in ExonSegment.

When a plain text segment (not interpolated) is processed, it is converted to the result type, which usually happens via fromString.

For the type of showsPrec (String -> String), there is no instance of IsString, so this class provides an instance that works around that by calling showString.

Since: 1.0.0.0

Minimal complete definition

Nothing

Methods

exonString :: String -> Result builder Source #

Convert a String to the builder type.

default exonString :: IsString builder => String -> Result builder Source #

exonWhitespace :: String -> Result builder Source #

Convert a String containing whitespace to the builder type. This is only used by whitespace-aware quoters, like exonws or intron.

default exonWhitespace :: String -> Result builder Source #

Instances

Instances details
IsString a => ExonString result a Source # 
Instance details

Defined in Exon.Class.Exon

ExonString result (String -> String) Source #

The instance for the type used by showsPrec.

Instance details

Defined in Exon.Class.Exon

IsString builder => ExonString (SkipWs result) builder Source #

The instance used when the result type is wrapped in SkipWs, which is done by intron.

It returns Empty for any whitespace.

Instance details

Defined in Exon.Class.Exon

Methods

exonString :: String -> Result builder Source #

exonWhitespace :: String -> Result builder Source #

class ExonSegment (result :: Type) (builder :: Type) where Source #

This class converts a Segment to a builder.

The default implementation performs the following conversions for the differnet segment variants:

Since: 1.0.0.0

Methods

exonSegment :: Segment builder -> Result builder Source #

Convert literal string segments to the result type.

Instances

Instances details
ExonString result builder => ExonSegment result builder Source # 
Instance details

Defined in Exon.Class.Exon

Methods

exonSegment :: Segment builder -> Result builder Source #

class ExonAppend (result :: Type) (builder :: Type) where Source #

This class handles concatenation of segments, which might be a builder or the result type.

The default instance simply uses (<>), and there is only one special instance for String -> String, the type used by showsPrec.

Since: 1.0.0.0

Minimal complete definition

exonAppend

Methods

exonAppend :: builder -> builder -> Result builder Source #

Concatenate two segments of the builder type.

exonConcat :: NonEmpty (Result builder) -> Result builder Source #

Concatenate a list of segments of the result type.

Folds the list over exonAppend, skipping over Empty segments.

A possible overload may implement lookahead to skip whitespace.

Since: 1.1.0.0

Instances

Instances details
Semigroup builder => ExonAppend result builder Source # 
Instance details

Defined in Exon.Class.Exon

Methods

exonAppend :: builder -> builder -> Result builder Source #

exonConcat :: NonEmpty (Result builder) -> Result builder Source #

ExonAppend result (String -> String) Source # 
Instance details

Defined in Exon.Class.Exon

class ExonBuild (result :: Type) (inner :: Type) where Source #

This class implements the Segment concatenation logic.

  1. Each Expression is converted to the builder type by ExonBuilder.
  2. Each String and Whitespace is converted to the builder type by ExonSegment and ExonString.
  3. The segments are folded over ExonAppend.
  4. The result is converted from the builder type to the original type by ExonBuilder.

Each step may be overridden individually

Since: 1.0.0.0

Methods

exonBuild :: NonEmpty (Segment inner) -> inner Source #

Concatenate a list of Segments.

Instances

Instances details
(ExonAppend result builder, ExonSegment result builder, ExonBuilder inner builder) => ExonBuild result inner Source # 
Instance details

Defined in Exon.Class.Exon

Methods

exonBuild :: NonEmpty (Segment inner) -> inner Source #

class Exon (result :: Type) where Source #

This class is the main entry point for Exon.

The default instance unwraps all newtypes that are Generic and passes the innermost type to ExonBuild.

The original type is also used as a parameter to ExonBuild, so customizations can be based on it.

Methods

exonProcess :: NonEmpty (Segment result) -> result Source #

Concatenate a list of Segments.

Since: 1.0.0.0

Instances

Instances details
(OverNewtypes result inner, ExonBuild result inner) => Exon result Source # 
Instance details

Defined in Exon.Class.Exon

Methods

exonProcess :: NonEmpty (Segment result) -> result Source #

exonProcessWith :: forall wrapped result. Exon wrapped => (result -> wrapped) -> (wrapped -> result) -> NonEmpty (Segment result) -> result Source #

Call exonProcess, but unwrap the arguments and rewrap the result using the supplied functions.

Since: 1.0.0.0