Created
October 23, 2020 12:37
-
-
Save sungkmi/bacee474006ffde3925222925ac39773 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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