tschuchort
01/22/2018, 10:54 PMtschuchort
01/22/2018, 10:57 PMraulraja
01/22/2018, 11:01 PMraulraja
01/22/2018, 11:01 PMtschuchort
01/22/2018, 11:03 PMrunA
and `runS`: are they even really needed? It's easy enough to extract the state/value from the result tuple (maybe a Pair alias should be used here). In any case, I think the docs should be kept as simple and self explanatory as possible. The more specialized cases/best practices can be explained further downraulraja
01/22/2018, 11:05 PMraulraja
01/22/2018, 11:06 PMraulraja
01/22/2018, 11:11 PMrunState()
and runValue()
tschuchort
01/22/2018, 11:18 PMraulraja
01/22/2018, 11:19 PMraulraja
01/22/2018, 11:19 PMrunState()
and runValue()
?cedric
01/22/2018, 11:20 PMsnd
is always “sound”, never “second”.tschuchort
01/22/2018, 11:23 PMcedric
01/22/2018, 11:24 PMfst
on the deskraulraja
01/22/2018, 11:24 PMfun run(): Tuple2<S, A>
fun runState(): S
fun runValue(): A
raulraja
01/22/2018, 11:24 PMtschuchort
01/22/2018, 11:25 PMtschuchort
01/22/2018, 11:26 PMraulraja
01/22/2018, 11:27 PMtschuchort
01/22/2018, 11:29 PMpakoito
01/22/2018, 11:29 PMpakoito
01/22/2018, 11:29 PMtschuchort
01/22/2018, 11:31 PMraulraja
01/22/2018, 11:35 PMState
value on each function such as map
flatMap
etc.tschuchort
01/22/2018, 11:37 PMraulraja
01/22/2018, 11:40 PMState Machine
is a well know pattern. For what is known chaning the data type and typeclasses names it's something most people are not a fun of https://github.com/Kotlin/KEEP/pull/87#issuecomment-333672535 specially when we are speaking about well known data types in many languages.tschuchort
01/22/2018, 11:45 PMtschuchort
01/22/2018, 11:47 PMItua
01/23/2018, 4:39 AMraulraja
01/23/2018, 9:40 AMState
. We also have MonadState
in the mtl module that is a typeclass that abstracts away from the data type since other datatypes could potentially implement the functions in State and provide an alternative implementation. Also State itself it's an alias to typealias State<A> = StateT<IdHK, S, A>
Since the State itself is not that useful over Id but other more powerful and commonly used ones such as IO. In practices most people would end up using StateT
unless they are using State for synchronous computations.