brandonchinn178 / brandonchinn178/ghc-string-interpolation-prototypes

text and implicit-only-string

Open
#4 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
20
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Trying to convert `pack (show taxTypeRate) <> "% " <> taxTypeName ` using implicit-only-string. `taxTypeName` and the result is a `Text`. The obvious conversiot

``` haskell
"${taxTypeRate}%${taxTypeName}
```

Does not work out of the box; the only way I found to make it work is to use `unpack` (either explicitely or instanciating

``` haskell
instance Interpolate Text where
interpolate = unpack
```

In both the cases the codes result in somethingsimilar to

``` haksell
mconcat [ fromString (show taxTypeRate
, fromString "% "
, fromString (unpack taxTypeName)
]
```

This `fromString (unpack ...)` seems inefficient, unless there is a rule converting `fromString . upnack` to `id` ???

Contributor guide

No contributing guide indexed for this repository

Research direction

No files or tests are named. Start by reproducing the Text interpolation example from the issue and inspect the Interpolate Text instance and generated expression; determine whether the implementation can preserve Text without unpacking and converting it through fromString. Done means the example works without an explicit unpack or custom instance and the resulting conversion is not needlessly round-tripped.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.