Skip to content

Instantly share code, notes, and snippets.

@sungkmi
Created October 23, 2020 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sungkmi/bacee474006ffde3925222925ac39773 to your computer and use it in GitHub Desktop.
Save sungkmi/bacee474006ffde3925222925ac39773 to your computer and use it in GitHub Desktop.
package lascala.sgs.ch5.invariants
import cats.data.State
import cats.implicits._
import eu.timepit.refined._
import eu.timepit.refined.api.Refined
import eu.timepit.refined.auto._
import eu.timepit.refined.numeric._
import shapeless._ ; import syntax.singleton._ ; import record._
import Container._
case class Container[GI <: GroupIndex](
group: Set[ContainerIndex[GI]],
amount: Double Refined NonNegative,
)
object Container {
type GroupIndex = Char
type ContainerIndex[GI <: GroupIndex] = Char
val world = {
('a' ->> Container['a']('a')) ::
('b' ->> Container['b']('b')) ::
('c' ->> Container['c']('c')) ::
('d' ->> Container['d']('d')) ::
HNil
}
def apply[GI <: GroupIndex](index: ContainerIndex[GI]): Container[GI] = {
new Container[GI](Set(index), 0.0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment