All Projects → bizzabo → typeless

bizzabo / typeless

Licence: Apache-2.0 license
running wild with shapeless

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to typeless

play-json-extensions
+22 field case class formatter and more for play-json
Stars: ✭ 193 (+1106.25%)
Mutual labels:  backend, rnd, xdotai
diff
Visually compare Scala data structures with out of the box support for arbitrary case classes.
Stars: ✭ 179 (+1018.75%)
Mutual labels:  backend, rnd, xdotai
Appy
🚀 A full stack boilerplate web app
Stars: ✭ 225 (+1306.25%)
Mutual labels:  backend
ITL
Sample Web API implementation with .NET Core and DDD using Clean Architecture.
Stars: ✭ 29 (+81.25%)
Mutual labels:  backend
nextjs-boilerplate
Jam3 NextJS Generator for SPA, SSG, SSR and JAMStack applications
Stars: ✭ 95 (+493.75%)
Mutual labels:  backend
Full Stack Fastapi Couchbase
Full stack, modern web application generator. Using FastAPI, Couchbase as database, Docker, automatic HTTPS and more.
Stars: ✭ 243 (+1418.75%)
Mutual labels:  backend
front-end
定位为非前端开发同学,科普前端
Stars: ✭ 33 (+106.25%)
Mutual labels:  backend
Ownphotos
Self hosted alternative to Google Photos
Stars: ✭ 2,587 (+16068.75%)
Mutual labels:  backend
kotlin-no-backend
Lista de empresas que utilizam Kotlin no Brasil.
Stars: ✭ 46 (+187.5%)
Mutual labels:  backend
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (+1481.25%)
Mutual labels:  backend
MultiplatformPlayground
Kotlin Multiplatform project in Jetpack Compose & SwiftUI with shared ViewModel layer and File upload
Stars: ✭ 72 (+350%)
Mutual labels:  backend
I18next Xhr Backend
[deprecated] can be replaced with i18next-http-backend
Stars: ✭ 252 (+1475%)
Mutual labels:  backend
Free Programming Resources
💎 免费的编程资源大全,持续更新!🔥 覆盖各种语言和方向(Java \ Python \ C++ \ JavaScript \ Golang \ 前端 \ 后端等)的学习路线、贴心教程、项目实战、编程书籍、面试合集、实用资源等,对程序员非常有帮助!
Stars: ✭ 225 (+1306.25%)
Mutual labels:  backend
exocore
A distributed private application framework
Stars: ✭ 50 (+212.5%)
Mutual labels:  backend
Terraform Aws Tfstate Backend
Terraform module that provision an S3 bucket to store the `terraform.tfstate` file and a DynamoDB table to lock the state file to prevent concurrent modifications and state corruption.
Stars: ✭ 229 (+1331.25%)
Mutual labels:  backend
random-network-distillation-pytorch
Random Network Distillation pytorch
Stars: ✭ 185 (+1056.25%)
Mutual labels:  rnd
Plumier
A TypeScript backend framework focuses on development productivity, uses dedicated reflection library to help you create a robust, secure and fast API delightfully.
Stars: ✭ 223 (+1293.75%)
Mutual labels:  backend
Yii2 Usuario
Highly customizable and extensible user management, authentication, and authorization Yii2 extension
Stars: ✭ 251 (+1468.75%)
Mutual labels:  backend
oh-my-backend
Что нужно знать бэкенд-разработчику web-приложений. Backend Roadmap (from Junior to Senior).
Stars: ✭ 657 (+4006.25%)
Mutual labels:  backend
todo
An example todo application with Go!
Stars: ✭ 61 (+281.25%)
Mutual labels:  backend

typeless

Some typeclasses inspired and powered by shapeless

Find[L <: HList, A]

Will allow to find a type A in an HList L, if the type is not present it returns None, otherwise Some[A]

Subset[L <: HList,S <: HList]

Similar to Find, but for a group of elements, if all the elements of the S are present in L it returns Some[S] otherwise None

ListToHList[L, H < HList]

Converts a List[L] to an Option[HList]. The ListToHList implicit class exposes two features.

.toProduct[A]: convert List[L] to an Option[A].

.findByType[B]: find type B within List[L]

  import ListToHList.Ops

  sealed trait A
  case class B() extends A
  case class C() extends A

  case class D(b: B, c: C)
  
  val listA: List[A] = List(B(), C())
  
  listA.toProduct[D] === Some(D(B(), C()))
  
  listA.findByType[B] === Some(B())

Convert[L <: Coproduct, S <: Coproduct]

For Coproducts L and S, Convert takes a value of type L and converts it to type S.

example

  type A = String :+: Double :+: CNil
  type B = Double :+: String :+: List[Int] :+: CNil

  Coproduct[A]("test").convert[B] === Some(Coproduct[B]("test"))

CoproductToHList[C <: Coproduct, L <: HList]

For a Seq of Coproducts C, convert to HList of type L

example

    type A = Int :+: String :+: CNil
    type L = String :: Int :: HNil

    Seq(Coproduct[A](1), Coproduct[A]("a")).toHList[L] === Some("a" :: 1 :: HNil))
    
    case class Foo(i:Int, s:String)
    
    Seq(Coproduct[A](1), Coproduct[A]("a")).toHList[Foo] === Some(Food("a", 1))

SelectFunctions[L <: HList, FF <: HList]

Takes an HList of functions FF and an HList of potential arguments Context. It applies the arguments to the functions for which all the arguments are present. It returns an HList with the results. It will not compile if there is a function that cannot be applied.

example

val functions =
    { (x: String, i: Int, d: Double) => d.toInt * i } ::
      { (x: String, i: Int) => s"$x + $i" } ::
      { (x: String, s: Char, i: Int) => i.toDouble } :: 
      { (x: String, s: Char, i: Int) => s.toInt + i * 2 + x.size } ::
      { (x: String) => x.size } ::
      { (x: Char) => x.toInt } ::
      HNil

SelectFunctions.applyAll(1, hi)(functions) // won't compile
SelectFunctions.applyAll(hi, 'a', 1)(functions) == "hi + 1" :: 1.0 :: 101 :: 2 :: 97 :: HNil

FlattenFunctions[Context <: HList, FFF <: HList]

Takes an HList of HLists of functions and an HList of potential arguments, and uses SelectFunctions[Context, FF] to calculate the resulting HList.

example

 val functions1 =
      { (x: String, i: Int) => (x.size + i) } ::
        { (x: String, s: Char, i: Int) => (s.toInt + i * 2 + x.size) } ::
        HNil
val functions2 =
      { (x: String, s: Char, i: Int) => (s.toInt + i + x.size) } ::
        { (i: Int) => i.toDouble } ::
        HNil

val functions = functions1 ::
      functions2 ::
      HNil

FlattenFunctions.applyAll(1, "a", 'a')(functions) === 2 :: 1.0 :: 99 :: HNil

EqualsIgnoringFields[T]

It compares two cases classes excluding specific field names rather than types.

example:

import typeless.hlist.EqualsIgnoringFields.Ops

sealed trait Monarch

case class Butterflies(
  _id: Long,
  date: Long,
  count: Int
) extends Monarch

case class Dictator(
  _id: Long,
  date: Long,
  count: Int
) extends Monarch

val butterfliesStation1 = Butterflies(
      _id = 1,
      date = 1131,
      count = 3
    )
val butterfliesStation2 = Butterflies(
      _id = 2,
      date = 1131,
      count = 2
    )

// the two objects are the same if we ignore those two fields
assert(butterfliesStation1.equalsIgnoringFields(field => field == '_id || field == 'count)(butterfliesStation2)) 
// the two objects are different if not ignoring `count`
assert(!butterfliesStation1.equalsIgnoringFields(_ == '_id)(butterfliesStation2))
// the two objects are different, period
assert(butterfliesStation1 != butterfliesStation2) 

Getting started

Scala 2.11/2.12

libraryDependencies += "ai.x" %% "typeless" % "0.6.0"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].