typist-0.1.0.0: Typelevel printf
Safe HaskellSafe-Inferred
LanguageHaskell2010

Typist.Internal.Format

Synopsis

Documentation

type family Format (str :: Symbol) where ... Source #

Equations

Format str = ContFormat 0 (UnconsSymbol str) 

newtype Arg (n :: Nat) (s :: Symbol) Source #

Constructors

Arg Builder 

Instances

Instances details
(Interpolate args, KnownNat i) => Interpolate (Arg i n ': args) Source # 
Instance details

Defined in Typist.Internal.Format

Methods

interpolate :: Rec (Arg i n ': args) -> Int -> String -> Builder -> Builder Source #

data Rec as where Source #

Constructors

RNil :: Rec '[] 
(:&) :: Arg n s -> Rec ns -> Rec (Arg n s ': ns) 

type family ContFormat (n :: Nat) (a :: Maybe (Char, Symbol)) where ... Source #

Equations

ContFormat n ('Just '('\\', rest)) = SkipOne (n + 1) (UnconsSymbol rest) 
ContFormat n ('Just '('#', rest)) = TryGetArg n (UnconsSymbol rest) 
ContFormat n ('Just '(a, rest)) = ContFormat (n + 1) (UnconsSymbol rest) 
ContFormat n 'Nothing = '[] 

type family SkipOne (n :: Nat) (s :: Maybe (Char, Symbol)) where ... Source #

Equations

SkipOne n 'Nothing = ContFormat n 'Nothing 
SkipOne n ('Just '(a, rest)) = ContFormat (n + 1) (UnconsSymbol rest) 

type family TryGetArg n rest where ... Source #

Equations

TryGetArg n ('Just '('{', rest)) = Arg n (TakeName (UnconsSymbol rest)) ': ContFormat (n + 2) (UnconsSymbol (SkipName (UnconsSymbol rest))) 
TryGetArg n 'Nothing = ContFormat n 'Nothing 
TryGetArg n ('Just '(a, rest)) = ContFormat (n + 2) (UnconsSymbol rest) 

type family TakeName (a :: Maybe (Char, Symbol)) :: Symbol where ... Source #

Equations

TakeName ('Just '('}', rest)) = "" 
TakeName ('Just '(a, rest)) = ConsSymbol a (TakeName (UnconsSymbol rest)) 
TakeName 'Nothing = TypeError ('Text "Expected '}' but EOF found. Close placeholder with '}'. Example: #{name}") 

type family SkipName (a :: Maybe (Char, Symbol)) :: Symbol where ... Source #

Equations

SkipName ('Just '('}', rest)) = rest 
SkipName ('Just '(a, rest)) = SkipName (UnconsSymbol rest) 
SkipName 'Nothing = "" 

class Interpolate args where Source #

Methods

interpolate :: Rec args -> Int -> String -> Builder -> Builder Source #

Instances

Instances details
Interpolate ('[] :: [Type]) Source # 
Instance details

Defined in Typist.Internal.Format

Methods

interpolate :: Rec '[] -> Int -> String -> Builder -> Builder Source #

(Interpolate args, KnownNat i) => Interpolate (Arg i n ': args) Source # 
Instance details

Defined in Typist.Internal.Format

Methods

interpolate :: Rec (Arg i n ': args) -> Int -> String -> Builder -> Builder Source #

fmt :: forall str. (KnownSymbol str, Interpolate (Format str)) => (Rec '[] -> Rec (Format str)) -> Builder Source #

See usage example next to #= at Typist.TextShow