hackerham
04/03/2017, 4:01 PMhackerham
04/03/2017, 4:01 PMcedric
04/03/2017, 9:21 PMReader
, the first one is that it modifies all the signatures of the methods that need to read something from the config, e.g. from Int
to Reader[C,Int]
. That’s a huge breach in encapsulation that ripples through your whole coderoberto.guerra
04/03/2017, 9:23 PMmap
function that will lift those functions.roberto.guerra
04/03/2017, 9:23 PMroberto.guerra
04/03/2017, 9:23 PMReader.map(f)
should do thatcedric
04/03/2017, 9:23 PMcedric
04/03/2017, 9:23 PMcedric
04/03/2017, 9:24 PMC
.cedric
04/03/2017, 9:24 PMroberto.guerra
04/03/2017, 9:24 PMroberto.guerra
04/03/2017, 9:24 PMcedric
04/03/2017, 9:25 PMInt
but actually, it needs a config file to return that value, so it’s not pure. In order to be pure, that function needs to be passed a Config parameter so it can return an Int
from it. Hence the return type becomes Reader[C, Int]
cedric
04/03/2017, 9:26 PMC -> Int
)roberto.guerra
04/03/2017, 9:26 PMcedric
04/03/2017, 9:27 PMgetPort() = 1234
. One day you decide “Ok now this comes from a config fille`. With Reader
, your function is now getPort() : Reader[C, Int]
and you need to modify all the callerscedric
04/03/2017, 9:27 PMConfig
parameter to pass it deep down to getPort()
.cedric
04/03/2017, 9:28 PMcedric
04/03/2017, 9:28 PMcedric
04/03/2017, 9:29 PM@Inject private config: Config
fun getPort() = config.port
cedric
04/03/2017, 9:29 PMInt
return typecedric
04/03/2017, 9:29 PMroberto.guerra
04/03/2017, 9:30 PMroberto.guerra
04/03/2017, 9:30 PMroberto.guerra
04/03/2017, 9:30 PMcedric
04/03/2017, 9:30 PMReader
is that it makes your code referentially transparent. But at an unacceptable price in my opinionroberto.guerra
04/03/2017, 9:31 PMcomponent
cedric
04/03/2017, 9:31 PMroberto.guerra
04/03/2017, 9:31 PMcomponent
, but other people seem to complain about that.roberto.guerra
04/03/2017, 9:31 PM