add plain fromString interpolation [for FilePath]
This commit is contained in:
parent
b4a939f364
commit
acc476d8a3
1 changed files with 7 additions and 0 deletions
|
@ -17,6 +17,7 @@ data ChunkType = Lit | Var VarType deriving Show
|
||||||
data VarType =
|
data VarType =
|
||||||
Plain
|
Plain
|
||||||
| FromText
|
| FromText
|
||||||
|
| FromString
|
||||||
| Show
|
| Show
|
||||||
| Reindent !Int
|
| Reindent !Int
|
||||||
| ReindentList !Int
|
| ReindentList !Int
|
||||||
|
@ -66,6 +67,11 @@ chunks = reverse . go "" [] . trimEnd where
|
||||||
go "" ((Var FromText, var) : lit acc : cs) rest2
|
go "" ((Var FromText, var) : lit acc : cs) rest2
|
||||||
where (var, rest2) = splitVar rest
|
where (var, rest2) = splitVar rest
|
||||||
|
|
||||||
|
-- $@var: expands to (fromString $var)
|
||||||
|
go acc cs ('$' :. '@' :. rest) =
|
||||||
|
go "" ((Var FromString, var) : lit acc : cs) rest2
|
||||||
|
where (var, rest2) = splitVar rest
|
||||||
|
|
||||||
-- $^var: expands to (fromString (show $var))
|
-- $^var: expands to (fromString (show $var))
|
||||||
go acc cs ('$' :. '^' :. rest) =
|
go acc cs ('$' :. '^' :. rest) =
|
||||||
go "" ((Var Show, var) : lit acc : cs) rest2
|
go "" ((Var Show, var) : lit acc : cs) rest2
|
||||||
|
@ -119,6 +125,7 @@ chunksToExpQ cs = [|$expr :: Builder|] where
|
||||||
chunk1 (Var t, name) = case t of
|
chunk1 (Var t, name) = case t of
|
||||||
Plain -> var
|
Plain -> var
|
||||||
FromText -> [|fromText $var|]
|
FromText -> [|fromText $var|]
|
||||||
|
FromString -> [|fromString $var|]
|
||||||
Show -> [|fromString $ show $var|]
|
Show -> [|fromString $ show $var|]
|
||||||
Reindent n -> [|reindent n $var|]
|
Reindent n -> [|reindent n $var|]
|
||||||
ReindentList n -> [|reindentList n $var|]
|
ReindentList n -> [|reindentList n $var|]
|
||||||
|
|
Loading…
Reference in a new issue