packages feed

typist 0.1.0.0 → 0.1.0.1

raw patch · 6 files changed

+347/−3 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for safe-interpolate -## 0.1.0.0 -- YYYY-mm-dd+## 0.1.0.0 -- 2024-04-30  * First version. Released on an unsuspecting world.++## 0.1.0.1 -- 2024-04-30++* Added readme
+ README.md view
@@ -0,0 +1,32 @@+# Typist++Typist is a library for interpolation. It uses type-level strings (`Symbol`s) for template. It uses `UnconsSynbol` type family which is added in GHC-9.2, so you need GHC version 9.2 or higher to use it.   ++Core functionality is in `Typist.Internal.Format`: +* Type family `Format` which transforms `Symbol` to function which renders final _string_ +* `Arg` newtype over `Text.Lazy.Builder` which carries name of parameter and it's position in string on type-level (for perfomance goods)+* Type class `Interpolate` which renders final _string_ on term level++An example of wrapping it (and also ready to use interface) is located in `Typist.TextShow`:+* `Unquoted` newtype for interpolation strings without `\"`  +* `#=` set operator+Example (more examples can be found in `test/Test`):++```haskell+question = fmt @"Hello, #{name}, do you like #{dish}?" $ +  (#name #= Unquoted "Mike") .+  (#dish #= Unquoted "pasta")+```++Performance is comparable with bare concatenation with `<>`. Benches can be found at `test/Bench`+### O2+![Alt text](https://raw.githubusercontent.com/goosedb/typist/059006de73e88111571aad0fc3f841506d96d6ec/results_cpu_o2.svg)+### O1+![Alt text](https://raw.githubusercontent.com/goosedb/typist/059006de73e88111571aad0fc3f841506d96d6ec/results_cpu_o1.svg)+### O0+![Alt text](https://raw.githubusercontent.com/goosedb/typist/059006de73e88111571aad0fc3f841506d96d6ec/results_cpu_o0.svg) ++To run benchmark use+```+$ cabal bench --benchmark-options '--svg results_cpu.svg'+```
+ results_cpu_o0.svg view
@@ -0,0 +1,100 @@+<svg xmlns="http://www.w3.org/2000/svg" height="557" width="960.0" font-size="16" font-family="sans-serif" stroke-width="2">+<g transform="translate(10.0 0)">+<text fill="hsl(0, 100%, 40%)" y="22">Formatting.Formatting 1 strings.concat 2.47 μs</text>+<g>+<title>2.47 μs ± 186 ns</title>+<rect y="28" rx="5" height="22" width="0.051657106091131305" fill="hsl(0, 100%, 80%)" stroke="hsl(0, 100%, 55%)" />+<g stroke="hsl(0, 100%, 40%)"><line x1="0.04777243395329414" x2="0.05554177822896847" y1="39" y2="39" />+<line x1="0.04777243395329414" x2="0.04777243395329414" y1="33" y2="45" />+<line x1="0.05554177822896847" x2="0.05554177822896847" y1="33" y2="45" />+</g>+</g>+<text fill="hsl(36, 100%, 40%)" y="77">Formatting.Formatting 1 strings.format 3.95 μs</text>+<g>+<title>3.95 μs ± 167 ns</title>+<rect y="83" rx="5" height="22" width="0.08274700507277528" fill="hsl(36, 100%, 80%)" stroke="hsl(36, 100%, 55%)" />+<g stroke="hsl(36, 100%, 40%)"><line x1="0.07925595547747881" x2="0.08623805466807176" y1="94" y2="94" />+<line x1="0.07925595547747881" x2="0.07925595547747881" y1="88" y2="100" />+<line x1="0.08623805466807176" x2="0.08623805466807176" y1="88" y2="100" />+</g>+</g>+<text fill="hsl(72, 100%, 40%)" y="132">Formatting.Formatting 10 strings.concat 26.4 μs</text>+<g>+<title>26.4 μs ± 1.7 μs</title>+<rect y="138" rx="5" height="22" width="0.5520263004776513" fill="hsl(72, 100%, 80%)" stroke="hsl(72, 100%, 55%)" />+<g stroke="hsl(72, 100%, 40%)"><line x1="0.5171916477446611" x2="0.5868609532106416" y1="149" y2="149" />+<line x1="0.5171916477446611" x2="0.5171916477446611" y1="143" y2="155" />+<line x1="0.5868609532106416" x2="0.5868609532106416" y1="143" y2="155" />+</g>+</g>+<text fill="hsl(108, 100%, 40%)" y="187">Formatting.Formatting 10 strings.format 39.9 μs</text>+<g>+<title>39.9 μs ± 3.1 μs</title>+<rect y="193" rx="5" height="22" width="0.8354046921813619" fill="hsl(108, 100%, 80%)" stroke="hsl(108, 100%, 55%)" />+<g stroke="hsl(108, 100%, 40%)"><line x1="0.7708534848690617" x2="0.8999558994936622" y1="204" y2="204" />+<line x1="0.7708534848690617" x2="0.7708534848690617" y1="198" y2="210" />+<line x1="0.8999558994936622" x2="0.8999558994936622" y1="198" y2="210" />+</g>+</g>+<text fill="hsl(144, 100%, 40%)" y="242">Formatting.Formatting 100 strings.concat 256  μs</text>+<g>+<title>256  μs ±  24 μs</title>+<rect y="248" rx="5" height="22" width="5.362617406824535" fill="hsl(144, 100%, 80%)" stroke="hsl(144, 100%, 55%)" />+<g stroke="hsl(144, 100%, 40%)"><line x1="4.86329366369248" x2="5.86194114995659" y1="259" y2="259" />+<line x1="4.86329366369248" x2="4.86329366369248" y1="253" y2="265" />+<line x1="5.86194114995659" x2="5.86194114995659" y1="253" y2="265" />+</g>+</g>+<text fill="hsl(180, 100%, 40%)" y="297">Formatting.Formatting 100 strings.format 398  μs</text>+<g>+<title>398  μs ±  21 μs</title>+<rect y="303" rx="5" height="22" width="8.341774600982822" fill="hsl(180, 100%, 80%)" stroke="hsl(180, 100%, 55%)" />+<g stroke="hsl(180, 100%, 40%)"><line x1="7.895218055731995" x2="8.788331146233649" y1="314" y2="314" />+<line x1="7.895218055731995" x2="7.895218055731995" y1="308" y2="320" />+<line x1="8.788331146233649" x2="8.788331146233649" y1="308" y2="320" />+</g>+</g>+<text fill="hsl(216, 100%, 40%)" y="352">Formatting.Formatting 1000 strings.concat 2.71 ms</text>+<g>+<title>2.71 ms ± 244 μs</title>+<rect y="358" rx="5" height="22" width="56.66346243118535" fill="hsl(216, 100%, 80%)" stroke="hsl(216, 100%, 55%)" />+<g stroke="hsl(216, 100%, 40%)"><line x1="51.551406314432526" x2="61.77551854793818" y1="369" y2="369" />+<line x1="51.551406314432526" x2="51.551406314432526" y1="363" y2="375" />+<line x1="61.77551854793818" x2="61.77551854793818" y1="363" y2="375" />+</g>+</g>+<text fill="hsl(252, 100%, 40%)" y="407">Formatting.Formatting 1000 strings.format 4.13 ms</text>+<g>+<title>4.13 ms ± 231 μs</title>+<rect y="413" rx="5" height="22" width="86.54870929279238" fill="hsl(252, 100%, 80%)" stroke="hsl(252, 100%, 55%)" />+<g stroke="hsl(252, 100%, 40%)"><line x1="81.71048438887192" x2="91.38693419671284" y1="424" y2="424" />+<line x1="81.71048438887192" x2="81.71048438887192" y1="418" y2="430" />+<line x1="91.38693419671284" x2="91.38693419671284" y1="418" y2="430" />+</g>+</g>+<g fill="hsl(288, 100%, 40%)">+<text y="462">Formatting.Formatting 10000 strings.concat</text>+<text y="462" x="570.2240707481545" text-anchor="end">27.2 ms</text>+</g>+<g>+<title>27.2 ms ± 1.8 ms</title>+<rect y="468" rx="5" height="22" width="570.2240707481545" fill="hsl(288, 100%, 80%)" stroke="hsl(288, 100%, 55%)" />+<g stroke="hsl(288, 100%, 40%)"><line x1="531.7940645604568" x2="608.6540769358522" y1="479" y2="479" />+<line x1="531.7940645604568" x2="531.7940645604568" y1="473" y2="485" />+<line x1="608.6540769358522" x2="608.6540769358522" y1="473" y2="485" />+</g>+</g>+<g fill="hsl(324, 100%, 40%)">+<text y="517">Formatting.Formatting 10000 strings.format</text>+<text y="517" x="866.452950680609" text-anchor="end">41.4 ms</text>+</g>+<g>+<title>41.4 ms ± 3.5 ms</title>+<rect y="523" rx="5" height="22" width="866.452950680609" fill="hsl(324, 100%, 80%)" stroke="hsl(324, 100%, 55%)" />+<g stroke="hsl(324, 100%, 40%)"><line x1="792.905901361218" x2="940.0" y1="534" y2="534" />+<line x1="792.905901361218" x2="792.905901361218" y1="528" y2="540" />+<line x1="940.0" x2="940.0" y1="528" y2="540" />+</g>+</g>+</g>+</svg>
+ results_cpu_o1.svg view
@@ -0,0 +1,100 @@+<svg xmlns="http://www.w3.org/2000/svg" height="557" width="960.0" font-size="16" font-family="sans-serif" stroke-width="2">+<g transform="translate(10.0 0)">+<text fill="hsl(0, 100%, 40%)" y="22">Formatting.Formatting 1 strings.concat 1.01 μs</text>+<g>+<title>1.01 μs ±  76 ns</title>+<rect y="28" rx="5" height="22" width="0.07706488167513481" fill="hsl(0, 100%, 80%)" stroke="hsl(0, 100%, 55%)" />+<g stroke="hsl(0, 100%, 40%)"><line x1="0.07121874873459162" x2="0.082911014615678" y1="39" y2="39" />+<line x1="0.07121874873459162" x2="0.07121874873459162" y1="33" y2="45" />+<line x1="0.082911014615678" x2="0.082911014615678" y1="33" y2="45" />+</g>+</g>+<text fill="hsl(36, 100%, 40%)" y="77">Formatting.Formatting 1 strings.format 949  ns</text>+<g>+<title>949  ns ±  84 ns</title>+<rect y="83" rx="5" height="22" width="0.07265796527094834" fill="hsl(36, 100%, 80%)" stroke="hsl(36, 100%, 55%)" />+<g stroke="hsl(36, 100%, 40%)"><line x1="0.06625372346556976" x2="0.07906220707632691" y1="94" y2="94" />+<line x1="0.06625372346556976" x2="0.06625372346556976" y1="88" y2="100" />+<line x1="0.07906220707632691" x2="0.07906220707632691" y1="88" y2="100" />+</g>+</g>+<text fill="hsl(72, 100%, 40%)" y="132">Formatting.Formatting 10 strings.concat 10.5 μs</text>+<g>+<title>10.5 μs ± 1.0 μs</title>+<rect y="138" rx="5" height="22" width="0.8060573408296322" fill="hsl(72, 100%, 80%)" stroke="hsl(72, 100%, 55%)" />+<g stroke="hsl(72, 100%, 40%)"><line x1="0.7272278705090117" x2="0.8848868111502527" y1="149" y2="149" />+<line x1="0.7272278705090117" x2="0.7272278705090117" y1="143" y2="155" />+<line x1="0.8848868111502527" x2="0.8848868111502527" y1="143" y2="155" />+</g>+</g>+<text fill="hsl(108, 100%, 40%)" y="187">Formatting.Formatting 10 strings.format 9.86 μs</text>+<g>+<title>9.86 μs ± 391 ns</title>+<rect y="193" rx="5" height="22" width="0.754816898944421" fill="hsl(108, 100%, 80%)" stroke="hsl(108, 100%, 55%)" />+<g stroke="hsl(108, 100%, 40%)"><line x1="0.7248912394166056" x2="0.7847425584722365" y1="204" y2="204" />+<line x1="0.7248912394166056" x2="0.7248912394166056" y1="198" y2="210" />+<line x1="0.7847425584722365" x2="0.7847425584722365" y1="198" y2="210" />+</g>+</g>+<text fill="hsl(144, 100%, 40%)" y="242">Formatting.Formatting 100 strings.concat 102  μs</text>+<g>+<title>102  μs ± 5.8 μs</title>+<rect y="248" rx="5" height="22" width="7.824888475048651" fill="hsl(144, 100%, 80%)" stroke="hsl(144, 100%, 55%)" />+<g stroke="hsl(144, 100%, 40%)"><line x1="7.3833565324488735" x2="8.266420417648428" y1="259" y2="259" />+<line x1="7.3833565324488735" x2="7.3833565324488735" y1="253" y2="265" />+<line x1="8.266420417648428" x2="8.266420417648428" y1="253" y2="265" />+</g>+</g>+<text fill="hsl(180, 100%, 40%)" y="297">Formatting.Formatting 100 strings.format 99.4 μs</text>+<g>+<title>99.4 μs ± 5.7 μs</title>+<rect y="303" rx="5" height="22" width="7.61321324736154" fill="hsl(180, 100%, 80%)" stroke="hsl(180, 100%, 55%)" />+<g stroke="hsl(180, 100%, 40%)"><line x1="7.175234061960879" x2="8.051192432762202" y1="314" y2="314" />+<line x1="7.175234061960879" x2="7.175234061960879" y1="308" y2="320" />+<line x1="8.051192432762202" x2="8.051192432762202" y1="308" y2="320" />+</g>+</g>+<text fill="hsl(216, 100%, 40%)" y="352">Formatting.Formatting 1000 strings.concat 1.05 ms</text>+<g>+<title>1.05 ms ± 104 μs</title>+<rect y="358" rx="5" height="22" width="80.36092740005472" fill="hsl(216, 100%, 80%)" stroke="hsl(216, 100%, 55%)" />+<g stroke="hsl(216, 100%, 40%)"><line x1="72.38532909047625" x2="88.3365257096332" y1="369" y2="369" />+<line x1="72.38532909047625" x2="72.38532909047625" y1="363" y2="375" />+<line x1="88.3365257096332" x2="88.3365257096332" y1="363" y2="375" />+</g>+</g>+<text fill="hsl(252, 100%, 40%)" y="407">Formatting.Formatting 1000 strings.format 1.03 ms</text>+<g>+<title>1.03 ms ± 102 μs</title>+<rect y="413" rx="5" height="22" width="78.58766854483751" fill="hsl(252, 100%, 80%)" stroke="hsl(252, 100%, 55%)" />+<g stroke="hsl(252, 100%, 40%)"><line x1="70.76907215391427" x2="86.40626493576076" y1="424" y2="424" />+<line x1="70.76907215391427" x2="70.76907215391427" y1="418" y2="430" />+<line x1="86.40626493576076" x2="86.40626493576076" y1="418" y2="430" />+</g>+</g>+<g fill="hsl(288, 100%, 40%)">+<text y="462">Formatting.Formatting 10000 strings.concat</text>+<text y="462" x="881.795171304195" text-anchor="end">11.5 ms</text>+</g>+<g>+<title>11.5 ms ± 760 μs</title>+<rect y="468" rx="5" height="22" width="881.795171304195" fill="hsl(288, 100%, 80%)" stroke="hsl(288, 100%, 55%)" />+<g stroke="hsl(288, 100%, 40%)"><line x1="823.5903426083901" x2="940.0" y1="479" y2="479" />+<line x1="823.5903426083901" x2="823.5903426083901" y1="473" y2="485" />+<line x1="940.0" x2="940.0" y1="473" y2="485" />+</g>+</g>+<g fill="hsl(324, 100%, 40%)">+<text y="517">Formatting.Formatting 10000 strings.format</text>+<text y="517" x="862.8172803368927" text-anchor="end">11.3 ms</text>+</g>+<g>+<title>11.3 ms ± 708 μs</title>+<rect y="523" rx="5" height="22" width="862.8172803368927" fill="hsl(324, 100%, 80%)" stroke="hsl(324, 100%, 55%)" />+<g stroke="hsl(324, 100%, 40%)"><line x1="808.596692220259" x2="917.0378684535265" y1="534" y2="534" />+<line x1="808.596692220259" x2="808.596692220259" y1="528" y2="540" />+<line x1="917.0378684535265" x2="917.0378684535265" y1="528" y2="540" />+</g>+</g>+</g>+</svg>
+ results_cpu_o2.svg view
@@ -0,0 +1,100 @@+<svg xmlns="http://www.w3.org/2000/svg" height="557" width="960.0" font-size="16" font-family="sans-serif" stroke-width="2">+<g transform="translate(10.0 0)">+<text fill="hsl(0, 100%, 40%)" y="22">Formatting.Formatting 1 strings.concat 861  ns</text>+<g>+<title>861  ns ±  42 ns</title>+<rect y="28" rx="5" height="22" width="0.07605771223055076" fill="hsl(0, 100%, 80%)" stroke="hsl(0, 100%, 55%)" />+<g stroke="hsl(0, 100%, 40%)"><line x1="0.07239199090254896" x2="0.07972343355855256" y1="39" y2="39" />+<line x1="0.07239199090254896" x2="0.07239199090254896" y1="33" y2="45" />+<line x1="0.07972343355855256" x2="0.07972343355855256" y1="33" y2="45" />+</g>+</g>+<text fill="hsl(36, 100%, 40%)" y="77">Formatting.Formatting 1 strings.format 888  ns</text>+<g>+<title>888  ns ±  79 ns</title>+<rect y="83" rx="5" height="22" width="0.07843749908189664" fill="hsl(36, 100%, 80%)" stroke="hsl(36, 100%, 55%)" />+<g stroke="hsl(36, 100%, 40%)"><line x1="0.07142751796665447" x2="0.0854474801971388" y1="94" y2="94" />+<line x1="0.07142751796665447" x2="0.07142751796665447" y1="88" y2="100" />+<line x1="0.0854474801971388" x2="0.0854474801971388" y1="88" y2="100" />+</g>+</g>+<text fill="hsl(72, 100%, 40%)" y="132">Formatting.Formatting 10 strings.concat 9.13 μs</text>+<g>+<title>9.13 μs ± 689 ns</title>+<rect y="138" rx="5" height="22" width="0.806363666715931" fill="hsl(72, 100%, 80%)" stroke="hsl(72, 100%, 55%)" />+<g stroke="hsl(72, 100%, 40%)"><line x1="0.7455221245646595" x2="0.8672052088672024" y1="149" y2="149" />+<line x1="0.7455221245646595" x2="0.7455221245646595" y1="143" y2="155" />+<line x1="0.8672052088672024" x2="0.8672052088672024" y1="143" y2="155" />+</g>+</g>+<text fill="hsl(108, 100%, 40%)" y="187">Formatting.Formatting 10 strings.format 9.22 μs</text>+<g>+<title>9.22 μs ± 732 ns</title>+<rect y="193" rx="5" height="22" width="0.8138945215035388" fill="hsl(108, 100%, 80%)" stroke="hsl(108, 100%, 55%)" />+<g stroke="hsl(108, 100%, 40%)"><line x1="0.7492560239996581" x2="0.8785330190074195" y1="204" y2="204" />+<line x1="0.7492560239996581" x2="0.7492560239996581" y1="198" y2="210" />+<line x1="0.8785330190074195" x2="0.8785330190074195" y1="198" y2="210" />+</g>+</g>+<text fill="hsl(144, 100%, 40%)" y="242">Formatting.Formatting 100 strings.concat 91.1 μs</text>+<g>+<title>91.1 μs ± 7.9 μs</title>+<rect y="248" rx="5" height="22" width="8.046399616740127" fill="hsl(144, 100%, 80%)" stroke="hsl(144, 100%, 55%)" />+<g stroke="hsl(144, 100%, 40%)"><line x1="7.344387488344751" x2="8.748411745135503" y1="259" y2="259" />+<line x1="7.344387488344751" x2="7.344387488344751" y1="253" y2="265" />+<line x1="8.748411745135503" x2="8.748411745135503" y1="253" y2="265" />+</g>+</g>+<text fill="hsl(180, 100%, 40%)" y="297">Formatting.Formatting 100 strings.format 90.0 μs</text>+<g>+<title>90.0 μs ± 6.4 μs</title>+<rect y="303" rx="5" height="22" width="7.949166420334406" fill="hsl(180, 100%, 80%)" stroke="hsl(180, 100%, 55%)" />+<g stroke="hsl(180, 100%, 40%)"><line x1="7.3879606287452555" x2="8.510372211923556" y1="314" y2="314" />+<line x1="7.3879606287452555" x2="7.3879606287452555" y1="308" y2="320" />+<line x1="8.510372211923556" x2="8.510372211923556" y1="308" y2="320" />+</g>+</g>+<text fill="hsl(216, 100%, 40%)" y="352">Formatting.Formatting 1000 strings.concat 900  μs</text>+<g>+<title>900  μs ±  42 μs</title>+<rect y="358" rx="5" height="22" width="79.4790968233725" fill="hsl(216, 100%, 80%)" stroke="hsl(216, 100%, 55%)" />+<g stroke="hsl(216, 100%, 40%)"><line x1="75.75378959612782" x2="83.20440405061719" y1="369" y2="369" />+<line x1="75.75378959612782" x2="75.75378959612782" y1="363" y2="375" />+<line x1="83.20440405061719" x2="83.20440405061719" y1="363" y2="375" />+</g>+</g>+<text fill="hsl(252, 100%, 40%)" y="407">Formatting.Formatting 1000 strings.format 902  μs</text>+<g>+<title>902  μs ±  90 μs</title>+<rect y="413" rx="5" height="22" width="79.66369487676423" fill="hsl(252, 100%, 80%)" stroke="hsl(252, 100%, 55%)" />+<g stroke="hsl(252, 100%, 40%)"><line x1="71.72600507500306" x2="87.60138467852539" y1="424" y2="424" />+<line x1="71.72600507500306" x2="71.72600507500306" y1="418" y2="430" />+<line x1="87.60138467852539" x2="87.60138467852539" y1="418" y2="430" />+</g>+</g>+<g fill="hsl(288, 100%, 40%)">+<text y="462">Formatting.Formatting 10000 strings.concat</text>+<text y="462" x="873.3919879129453" text-anchor="end">9.89 ms</text>+</g>+<g>+<title>9.89 ms ± 723 μs</title>+<rect y="468" rx="5" height="22" width="873.3919879129453" fill="hsl(288, 100%, 80%)" stroke="hsl(288, 100%, 55%)" />+<g stroke="hsl(288, 100%, 40%)"><line x1="809.5071497496638" x2="937.2768260762268" y1="479" y2="479" />+<line x1="809.5071497496638" x2="809.5071497496638" y1="473" y2="485" />+<line x1="937.2768260762268" x2="937.2768260762268" y1="473" y2="485" />+</g>+</g>+<g fill="hsl(324, 100%, 40%)">+<text y="517">Formatting.Formatting 10000 strings.format</text>+<text y="517" x="908.7738533103181" text-anchor="end">10.3 ms</text>+</g>+<g>+<title>10.3 ms ± 354 μs</title>+<rect y="523" rx="5" height="22" width="908.7738533103181" fill="hsl(324, 100%, 80%)" stroke="hsl(324, 100%, 55%)" />+<g stroke="hsl(324, 100%, 40%)"><line x1="877.5477066206363" x2="940.0" y1="534" y2="534" />+<line x1="877.5477066206363" x2="877.5477066206363" y1="528" y2="540" />+<line x1="940.0" x2="940.0" y1="528" y2="540" />+</g>+</g>+</g>+</svg>
typist.cabal view
@@ -1,14 +1,22 @@ cabal-version:      3.0 name:               typist-version:            0.1.0.0+version:            0.1.0.1  license:            MIT license-file:       LICENSE author:             Danil Berestov maintainer:         goosedb@yandex.ru+homepage:           https://github.com/goosedb/typist + category:           Text-extra-source-files: CHANGELOG.md+extra-source-files: +  CHANGELOG.md+  README.md+  results_cpu_o0.svg+  results_cpu_o1.svg+  results_cpu_o2.svg+ synopsis: Typelevel printf  library