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

Exon.Class.ToSegment

Description

 
Synopsis

Documentation

class ToSegment a b where Source #

This class determines how an expression is converted to an interpolation quote's result type.

For a quote like [exon|a #{exp :: T} c|] :: R, the instance ToSegment T R is used to turn T into R. Aside from specialized instances for stringly types, the default implementation uses Generic to unwrap newtypes that either match the result type exactly, or uses fromString for result types that implement IsString.

So given:

>>> newtype T = T Text deriving newtype (Generic)
>>> newtype R = R Text deriving newtype (IsString, Semigroup, Monoid)

the quote from earlier would generically unwrap T and use fromString to construct an R.

Methods

toSegment :: a -> b Source #

Instances

Instances details
IsString a => ToSegment ByteString a Source # 
Instance details

Defined in Exon.Class.ToSegment

Methods

toSegment :: ByteString -> a Source #

IsString a => ToSegment LByteString a Source # 
Instance details

Defined in Exon.Class.ToSegment

Methods

toSegment :: LByteString -> a Source #

IsString a => ToSegment LText a Source # 
Instance details

Defined in Exon.Class.ToSegment

Methods

toSegment :: LText -> a Source #

IsString a => ToSegment Text a Source # 
Instance details

Defined in Exon.Class.ToSegment

Methods

toSegment :: Text -> a Source #

IsString a => ToSegment String a Source # 
Instance details

Defined in Exon.Class.ToSegment

Methods

toSegment :: String -> a Source #

(IsNewtype a wrapped, NewtypeSegment wrapped a b) => ToSegment a b Source # 
Instance details

Defined in Exon.Class.ToSegment

Methods

toSegment :: a -> b Source #