Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
.
Instances
IsString a => ToSegment ByteString a Source # | |
Defined in Exon.Class.ToSegment toSegment :: ByteString -> a Source # | |
IsString a => ToSegment LByteString a Source # | |
Defined in Exon.Class.ToSegment toSegment :: LByteString -> a Source # | |
IsString a => ToSegment LText a Source # | |
Defined in Exon.Class.ToSegment | |
IsString a => ToSegment Text a Source # | |
Defined in Exon.Class.ToSegment | |
IsString a => ToSegment String a Source # | |
Defined in Exon.Class.ToSegment | |
(IsNewtype a wrapped, NewtypeSegment wrapped a b) => ToSegment a b Source # | |
Defined in Exon.Class.ToSegment |