Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/afsalthaj/safe-string-interpolation
A type driven approach to string interpolation, aiming at consistent, secure, and only-human-readable logs and console outputs !
https://github.com/afsalthaj/safe-string-interpolation
automatic derviation fp functional-programming interpolation logging macros scala string string-manipulation typeclass typesafety
Last synced: 5 days ago
JSON representation
A type driven approach to string interpolation, aiming at consistent, secure, and only-human-readable logs and console outputs !
- Host: GitHub
- URL: https://github.com/afsalthaj/safe-string-interpolation
- Owner: afsalthaj
- License: mit
- Created: 2018-12-23T09:59:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-11T13:35:34.000Z (about 1 year ago)
- Last Synced: 2024-01-29T22:48:41.070Z (10 months ago)
- Topics: automatic, derviation, fp, functional-programming, interpolation, logging, macros, scala, string, string-manipulation, typeclass, typesafety
- Language: Scala
- Homepage: https://afsalthaj.github.io/safe-string-interpolation/
- Size: 1.22 MB
- Stars: 14
- Watchers: 3
- Forks: 5
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Typesafe Interpolation
[![Build Status](https://travis-ci.com/afsalthaj/safe-string-interpolation.svg?branch=master)](https://travis-ci.com/afsalthaj/safe-string-interpolation)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/safe-string-interpolation/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.afsalthaj/safe-string-interpolation_2.12.svg)](https://search.maven.org/artifact/io.github.afsalthaj/safe-string-interpolation_2.13/2.1.3/jar)An insanely simple type driven approach to string interpolation, aiming at consistent, secure, and only-human-readable logs and console outputs, and for safe string operations !
```scala
@ import $ivy.`io.github.afsalthaj::safe-string-interpolation:2.1.3`
import $ivy.$@ import com.thaj.safe.string.interpolator._
import com.thaj.safe.string.interpolator._@ case class Port(int: Int) extends AnyVal
defined class Port@ val port = Port(1)
port: Port = Port(1)@ ss"Db details: Port is ${port}"
cmd7.sc:1: could not find implicit value for parameter ev: com.thaj.safe.string.interpolator.Safe[ammonite.$sess.cmd5.Port]
val res7 = ss"Db details: Port is ${port}"
^
Compilation Failed@ ss"Db details: Port is ${port.int}"
res7: SafeString = SafeString("Db details: Port is 1")// Another example
@ case class Prefix(value: String)
defined class Prefix@ case class BucketName(value: String)
defined class BucketName@ val prefix = Prefix("foo")
prefix: Prefix = Prefix("foo")@ val bucketName = BucketName("6666-bucket")
bucketName: BucketName = BucketName("6666-bucket")@ val path = s"${bucketName}/${prefix}"
path: String = "BucketName(6666-bucket)/Prefix(foo)"@ val path = ss"${bucketName}/${prefix}"
cmd7.sc:1: could not find implicit value for parameter ev: com.thaj.safe.string.interpolator.Safe[ammonite.$sess.cmd2.BucketName]
val path = ss"${bucketName}/${prefix}"
^
Compilation Failed// Autoderivation module
@ import instances._
import instances._@ ss"Db details: Port is ${port}"
res9: SafeString = SafeString("Db details: Port is { int : 1 }")```
Checkout the project [website](https://afsalthaj.github.io/safe-string-interpolation/) for more features and possibilities.