Skip to content

v0.18.0

Compare
Choose a tag to compare
@kevin-lee kevin-lee released this 17 Aug 14:47
· 26 commits to main since this release

0.18.0 - 2024-08-18

New Features

refined4s-chimney Add missing type-classes for Chimney

  • [refined4s-chimney] Add missing Transformer to unwrap value for ChimneyNewtype (#340)

    import refined4s.*
    import refined4s.modules.chimney.derivation.*
    
    final case class Person(name: Person.Name)
    object Person {
      type Name = Name.Type
      object Name extends Newtype[String], ChimneyNewtype[String]
    }
    
    final case class User(name: String)
    
    import io.scalaland.chimney.*
    import io.scalaland.chimney.dsl.*
    
    val person = Person(Person.Name("Wade Wilson"))
    
    val deadpool = person.transformInto[User] // This is currently not possible.

  • [refined4s-chimney] Add missing Transformer to unwrap value for ChimneyRefined (#341)

    import refined4s.*
    import refined4s.modules.chimney.derivation.*
    
    final case class Person(name: Person.NotEmptyStr)
    object Person {
      type NotEmptyStr = NotEmptyStr.Type
      object NotEmptyStr extends Refined[String], ChimneyRefined[String] {
        inline def invalidReason(a: String): String = "non-empty String"
    
        inline def predicate(a: String): Boolean = a != ""
      }
    }
    
    final case class User(name: String)
    
    import io.scalaland.chimney.*
    import io.scalaland.chimney.dsl.*
    
    val person = Person(Person.NotEmptyStr("Wade Wilson"))
    
    val deadpool = person.transformInto[User] // This was not possible.

  • [refined4s-chimney] Add PartialTransformer to transform Refined[A] to Newtype[Refined[A]] for ChimneyRefined (#342)

    import refined4s.*
    import refined4s.modules.chimney.derivation.*
    
    import io.scalaland.chimney.*
    import io.scalaland.chimney.dsl.*
    
    final case class XMen(name: XMen.NotEmptyStr)
    object XMen {
      type NotEmptyStr = NotEmptyStr.Type
      object NotEmptyStr extends Refined[String], ChimneyRefined[String] {
        inline def invalidReason(a: String): String = "non-empty String"
    
        inline def predicate(a: String): Boolean = a != ""
      }
    }
    
    
    import refined4s.types.all.*
    
    final case class MarvelCharacter(name: MarvelCharacter.Name)
    object MarvelCharacter {
      type Name = Name.Type
      object Name extends Newtype[NonEmptyString], ChimneyNewtype[NonEmptyString]
    }
    
    val logan = XMen(XMen.NotEmptyStr("James Howlett"))
    
    import refined4s.modules.chimney.derivation.types.all.*
    
    val wolverine = logan.transformIntoPartial[MarvelCharacter]

  • [refined4s-chimney] Add PartialTransformer to transform Newtype[A] to Newtype[Refined[A]] for ChimneyNewtype (#346)

    import refined4s.*
    import refined4s.modules.chimney.derivation.*
    
    import io.scalaland.chimney.*
    import io.scalaland.chimney.dsl.*
    
    final case class XMen(name: XMen.Name)
    object XMen {
      type Name = Name.Type
      object Name extends Newtype[String], ChimneyNewtype[String]
    }
    
    import refined4s.types.all.*
    
    final case class MarvelCharacter(name: MarvelCharacter.Name)
    object MarvelCharacter {
      type Name = Name.Type
      object Name extends Newtype[NonEmptyString], ChimneyNewtype[NonEmptyString]
    }
    
    val logan = XMen(XMen.Name("James Howlett"))
    
    import refined4s.modules.chimney.derivation.types.all.*
    
    val wolverine = logan.transformIntoPartial[MarvelCharacter]