Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
// Copyright 2019-2021 github.com/daenyth | |
// Under the MIT license | |
/* | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNE |
object Test { | |
case class User(name: String, age: Int) | |
case class UserDTO(name: Option[String], age: Option[Int]) | |
import conversions._ | |
def a = User("John", 24).convertTo[UserDTO](Set("name")) | |
// res0: Test.UserDTO = UserDTO(Some(John),None) | |
case class WrongFieldNames(surname: Option[String], age: Option[Int]) |
sealed trait Decidable[+Proof] | |
final case class Yes[Proof](proof: Proof) extends Decidable[Proof] | |
final case object No extends Decidable[Nothing] | |
sealed trait List[+A] { | |
def nonEmpty: Decidable[this.type <:< ::[A]] | |
def ::[AA >: A](value: AA): ::[AA] = new ::[AA](value, this) | |
} | |
final case object Nil extends List[Nothing] { | |
def nonEmpty: Decidable[this.type <:< ::[Nothing]] = No |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
import Control.Lens | |
import Prelude hiding (readFile, writeFile, print) | |
import qualified Prelude as Prelude(readFile, writeFile, print) |
import scala.language.higherKinds | |
object Lenses { | |
trait Profunctor[P[_, _]] { | |
def dimap[A, B, C, D](f: C => A, g: B => D)(p: P[A, B]): P[C, D] | |
} | |
object Profunctor { |
-- The meta-circular interpreter from section 5 of Reynolds's Definitional | |
-- Interpreters for Higher Order Programming Languages | |
-- (http://www.cs.uml.edu/~giam/91.531/Textbooks/definterp.pdf) | |
data EXP | |
= CONST Const | |
| VAR Var | |
| APPL Appl | |
| LAMBDA Lambda | |
| COND Cond |
Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).
The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject
typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA
sbt run
- Run the http service on localhost:8989.sbt ~re-start
- Run the http service as above, but whenever the code changes, recompile and relaunch the service.<project specific env setup>
Once the environment is configured, run
sbt test:compile
- Compile the tests without running thempackage shajra.extn.scalaz | |
import scalaz. | |
{ \/, Arrow, Applicative, Foldable, Functor, IsomorphismApplicative, | |
IsomorphismFunctor, IsomorphismMonoid, IsomorphismPlus, | |
IsomorphismSemigroup, Kleisli, Maybe, Monoid, NonEmptyList, Plus, | |
ProChoice, Semigroup, Validation } | |
import scalaz.Isomorphism. | |
{ <=>, <~>, <~~>, IsoBifunctorTemplate, IsoFunctorTemplate, IsoSet } |