Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 21 12:39
    scala-steward closed #118
  • Oct 21 12:39
    scala-steward commented #118
  • Oct 21 12:39
    scala-steward opened #122
  • Oct 17 12:20
    scala-steward closed #117
  • Oct 17 12:20
    scala-steward commented #117
  • Oct 17 12:20
    scala-steward opened #121
  • Sep 17 12:10
    scala-steward closed #119
  • Sep 17 12:10
    scala-steward commented #119
  • Sep 17 12:10
    scala-steward commented #106
  • Sep 17 12:10
    scala-steward opened #120
  • Jul 06 11:48
    scala-steward closed #106
  • Jul 06 11:48
    scala-steward commented #106
  • Jul 06 11:48
    scala-steward opened #119
  • Jan 22 17:03
    scala-steward closed #108
  • Jan 22 17:03
    scala-steward commented #108
  • Jan 22 17:03
    scala-steward opened #118
  • Jan 13 05:05
    scala-steward closed #113
  • Jan 13 05:05
    scala-steward commented #113
  • Jan 13 05:05
    scala-steward opened #117
  • Dec 21 2021 11:08
    scala-steward closed #115
Afsal Thaj
@afsalthaj
This channel discuss about safe string interpolation and consistent logging in scala
Afsal Thaj
@afsalthaj

SafeStr now works for complex data types and GADTs..

case class Something[A](n : A)

This was more of a bugfix, that allows michael's suggestion to do Secret[A]

Following tasks remaining before we announce in twitter
https://github.com/afsalthaj/safe-string-interpolation/issues
Afsal Thaj
@afsalthaj
Made the safe-string-interpolation far more simple in terms of usage and in terms of internal implementation code
Macros are simple
and there will be an integration with scalaz show and cats show soon
Afsal Thaj
@afsalthaj
Please use v 1.3.0 !
Afsal Thaj
@afsalthaj
Please use v 1.4.1
Now it supports products and coproducts
Afsal Thaj
@afsalthaj
Released version 2.1.1
Philippe Derome
@phderome
Hi there. I have heard of you from ZIO community with ZIO.config and @guizmaii on Twitter. Is safe-string-interpolation a project you still enjoy and recommend?
Afsal Thaj
@afsalthaj
Hi there
Philippe Derome
@phderome
One usage I would not mind trying out is to use essentially as in products/coproducts but select which of my product/coproducts may be used with the interpolation (opt-in only) and I'd control in the type how to render. Imagine that the type T must support a Show[T] instance and if so the interpolator calls show on it.
Maybe there are simpler avenues?
Maybe ZIO.prelude Debug does what I have in mind actually.
What I have in mind is an interim solution for SQL statement construction prior to migrating to something quite more powerful, something that is better than Scala default s interpolator but very easy to introduce in a code base.
Afsal Thaj
@afsalthaj
Safe string interplation works with Safe typeclass. Just similar to Show and Debug. With optional autoderivation (through instances._) through direct macros (than shapeless/magnolia)
Philippe Derome
@phderome
All right, thanks. Going to bed shortly. I'll probably have a closer look this weekend.
Afsal Thaj
@afsalthaj
Interplator here (which is ss”...”) internally calls Safe.value (similar to
Show.shows)
Philippe Derome
@phderome
nice. It seems like it could be a good fit.
We protect Scala strings (say s= foo rendered as $$foo$$ or something like that I don't remember the details to protect against SQL injection in JDBC). So I could instruct how a Safe behaves for regular Scala Strings to introduce such special characters?
Afsal Thaj
@afsalthaj
Yea. Thsts right. custom
Yea. Thats right. Custom Safe instances and we are good to go.
this was bult 2 years before probably. When there was no big use of magnolia and shapeless being terribly slow for my products and coproducts. And also my default behaviour is safe instances for only primitives and not for products/coproducts (as i have written in README)
I personally
Maintain and use it in my little programs and has avoided numerous bugs
Philippe Derome
@phderome
sounds awesome Afsal.
Afsal Thaj
@afsalthaj
Anyway, if you are using this library just make sure you are passing only “SafeString” type all over the place and the only way to construct it is ss”foo”. However I would recommend a Sql data. That would mean ss”
ss”$sql”. Something along those lines
anyway thanks @phderome for looking at this.
Philippe Derome
@phderome
I was building manually plenty of toSql: String methods on types and doing this s"${a.toSql},${b.toSql}" and it is getting tiresome and silly.
Afsal Thaj
@afsalthaj
Yea. And we can easily mess up. This is a good usecase for it
Philippe Derome
@phderome
I found a simple way to do same with Prelude.Debug (though not dealing with secret string masking or annoying data showing such as hashes, which I didn't need right away). Given that I want to use Prelude more and more, I'll probably go with that. Thanks for the feedback!
Afsal Thaj
@afsalthaj
Nice. safe-string-interpolation was built way before prelude. I think now it makes more sense to go with Debug in prelude.
Philippe Derome
@phderome
+1